/[suikacvs]/messaging/manakai/lib/Message/Util/PerlCode.dis
Suika

Contents of /messaging/manakai/lib/Message/Util/PerlCode.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.49 - (hide annotations) (download)
Sat Jan 21 07:06:09 2006 UTC (19 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.48: +4 -2 lines
++ manakai/t/ChangeLog	21 Jan 2006 07:06:03 -0000
2006-01-21  Wakaba  <wakaba@suika.fam.cx>

	* Makefile: |dom-xmlparser.t| added.

++ manakai/bin/ChangeLog	21 Jan 2006 06:58:44 -0000
2006-01-12  Wakaba  <wakaba@suika.fam.cx>

	* dac2test.pl: |test:ParserTestSet| and |test:ParserTest|
	test types are implemented.

++ manakai/lib/Message/Util/ChangeLog	21 Jan 2006 07:02:03 -0000
2006-01-19  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCPackage.stringify): Appends a string
	representation of non-|pc:*| element children for
	the stringified value.

++ manakai/lib/Message/Util/DIS/ChangeLog	21 Jan 2006 07:04:28 -0000
2006-01-20  Wakaba  <wakaba@suika.fam.cx>

	* DPG.dis (plCodeFragment): Sets |param| value of default
	for default parse error handler to avoid array dereference error.

	* Test.dis (assertDOMTreeEquals): New method.

2006-01-11  Wakaba  <wakaba@suika.fam.cx>

	* Test.dis (TDTParser): New.
	(PARSE_ERR): New exception type.

++ manakai/lib/Message/DOM/ChangeLog	21 Jan 2006 07:00:52 -0000
2006-01-21  Wakaba  <wakaba@suika.fam.cx>

	* DOMFeature.dis (featuresParamToFeaturesHash): New block
	code (seprated from |InputProcessor|).  Now
	a |features| parameter's version can be specified by
	an array reference that contains a set of version
	numbers.  A test added.

	* XMLParser.dis: A test added.

++ manakai/lib/manakai/ChangeLog	21 Jan 2006 07:05:39 -0000
2006-01-11  Wakaba  <wakaba@suika.fam.cx>

	* Test.dis (test:ParserTestSet, test:ParserTest): New types.
	(test:Entity, test:RootEntity): New types.
	(lang:tdt): New lextype.

1 wakaba 1.1 Module:
2     @QName:
3     Util:PerlCode
4     @FullName:
5     @@lang: en
6     @@@:
7     Perl Code Constructor
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#
10    
11     @Description:
12     @@lang:en
13     @@@:
14     This module provides an object-oriented interface to construct
15     Perl code.
16    
17 wakaba 1.30 @DISCore:author: DISCore|Wakaba
18 wakaba 1.1 @License:
19     @@@:
20     license:Perl+MPL
21     @@Original:
22     @@@FullName:
23     manakai <CODE::lib/manakai/genlib.pl>
24     @@@Year:2004
25 wakaba 1.30 @@@DISCore:author: DISCore|Wakaba
26 wakaba 1.1 @Date:
27     @@@:
28 wakaba 1.49 $Date: 2005/12/28 03:50:17 $
29 wakaba 1.1 @@ContentType:
30     dis:Date.RCS
31    
32     @Require:
33     @@Module:
34 wakaba 1.35 @@@QName: MDOM|DOMCore
35     @@@WithFor: ManakaiDOM|ManakaiDOMLatest
36 wakaba 1.1
37 wakaba 1.35 @DefaultFor: ManakaiDOM|ManakaiDOMLatest
38 wakaba 1.1
39     Namespace:
40     @DIS:
41     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
42     @dis:
43     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
44 wakaba 1.20 @dx:
45     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#
46 wakaba 1.33 @ecore:
47     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/Core/
48     @f:
49     http://suika.fam.cx/~wakaba/archive/2004/dom/feature#
50     @idl:
51     http://suika.fam.cx/~wakaba/archive/2004/dis/IDL#
52 wakaba 1.25 @kwd:
53     http://suika.fam.cx/~wakaba/archive/2005/rfc2119/
54 wakaba 1.1 @lang:
55     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
56     @license:
57     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
58     @ManakaiDOM:
59     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
60 wakaba 1.5 @MDOM:
61     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.
62 wakaba 1.1 @MDOMX:
63     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
64 wakaba 1.30 @mn:
65     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
66 wakaba 1.1 @pc:
67     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#
68 wakaba 1.44 @pc2:
69     http://suika.fam.cx/~wakaba/archive/2005/12/pc/
70 wakaba 1.1 @rdf:
71     http://www.w3.org/1999/02/22-rdf-syntax-ns#
72     @rdfs:
73     http://www.w3.org/2000/01/rdf-schema#
74 wakaba 1.35 @s:
75     http://suika.fam.cx/~wakaba/archive/2004/dis/Markup#
76 wakaba 1.42 @test:
77     http://suika.fam.cx/~wakaba/archive/2004/dis/Test#
78 wakaba 1.1 @Util:
79     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
80    
81 wakaba 1.35 ## -- Module sets
82    
83     ResourceDef:
84     @QName: Util|
85     @For: ManakaiDOM|DOM
86     @rdf:type: dis|ModuleGroup
87     @FullName:
88     @@lang:en
89     @@@:
90     Manakai support modules
91     @DISPerl:packageName:
92     Message::Util::
93     @DISPerl:interfacePackageName:
94     @@@:
95     Message::Util::IF::
96     @@For: ManakaiDOM|ManakaiDOM !ManakaiDOM|ManakaiDOMLatest
97     @DISPerl:interfacePackageName:
98     @@@:
99     Message::Util::IFLatest::
100     @@For: ManakaiDOM|ManakaiDOMLatest
101     @ImplNote:
102     @@lang:en
103     @@@:
104     Resources <Q::Util|> for <Q::ManakaiDOM|all> and for <Q::ManakaiDOM|Perl>
105     is defined in module <Module::Util|ManakaiNode>.
106    
107 wakaba 1.1 ## -- Features
108    
109     ElementTypeBinding:
110     @Name: FeatureDef
111     @ElementType:
112     dis:ResourceDef
113     @ShadowContent:
114 wakaba 1.29 @@rdf:type: DOMFeature|Feature
115 wakaba 1.27 @@For: =ManakaiDOM|all
116 wakaba 1.1
117     ElementTypeBinding:
118     @Name: FeatureVerDef
119     @ElementType:
120     dis:ResourceDef
121     @ShadowContent:
122 wakaba 1.29 @@rdf:type: DOMFeature|Feature
123 wakaba 1.1
124     ElementTypeBinding:
125     @Name: featureQName
126     @ElementType:
127 wakaba 1.29 DOMFeature:name
128 wakaba 1.1 @ShadowContent:
129 wakaba 1.29 @@ContentType: DISCore|QName
130 wakaba 1.1
131     FeatureDef:
132     @QName: CoreFeature
133     @featureQName:
134     Util:PerlCode
135     @FeatureVerDef:
136     @@QName: CoreFeature10
137     @@Version: 1.0
138     @@ISA: CoreFeature
139     @@FullName:
140     @@@lang:en
141     @@@@:
142     Perl Code Constructor, version 1.0
143     @@Description:
144     @@@lang:en
145     @@@@:
146     Perl Code Constructor, version 1.0.
147    
148 wakaba 1.25 ElementTypeBinding:
149     @Name: IFClsDef
150     @ElementType:
151     dis:ResourceDef
152     @ShadowContent:
153     @@rdf:type:
154     @@@@: dis|MultipleResource
155     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
156     @@resourceFor: ManakaiDOM|ForIF
157 wakaba 1.36 @@resourceFor: ManakaiDOM|ForClass
158     @@For: ManakaiDOM|ManakaiDOM
159 wakaba 1.35
160     @@rdf:type:
161     @@@@: DISLang|Interface
162     @@@ForCheck: ManakaiDOM|ForIF
163    
164     @@rdf:type:
165     @@@@: DISLang|Class
166     @@@ForCheck: ManakaiDOM|ForClass
167     @@Implement:
168     @@@@: ||ManakaiDOM|ManakaiDOM||ManakaiDOM|ForIF
169     @@@ContentType: DISCore|TFPQNames
170     @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOM
171     @@Implement:
172     @@@@: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
173     @@@ContentType: DISCore|TFPQNames
174     @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOMLatest
175    
176     @@f:implements: pc|CoreFeature10
177    
178     ElementTypeBinding:
179     @Name: IFClsETDef
180     @ElementType:
181     dis:ResourceDef
182     @ShadowContent:
183     @@rdf:type:
184     @@@@: dis|MultipleResource
185     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass !s|ForML
186     @@resourceFor: ManakaiDOM|ForIF
187 wakaba 1.36 @@resourceFor: ManakaiDOM|ForClass
188 wakaba 1.35 @@resourceFor: s|ForML
189 wakaba 1.36 @@For: ManakaiDOM|ManakaiDOM
190 wakaba 1.25
191     @@rdf:type:
192 wakaba 1.35 @@@@: DISLang|Interface
193     @@@ForCheck: ManakaiDOM|ForIF
194 wakaba 1.25
195     @@rdf:type:
196 wakaba 1.35 @@@@: DISLang|Class
197 wakaba 1.25 @@@ForCheck: ManakaiDOM|ForClass
198     @@Implement:
199 wakaba 1.35 @@@@: ||ManakaiDOM|ManakaiDOM||ManakaiDOM|ForIF
200     @@@ContentType: DISCore|TFPQNames
201     @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOM
202     @@Implement:
203     @@@@: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
204 wakaba 1.25 @@@ContentType: DISCore|TFPQNames
205 wakaba 1.35 @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOMLatest
206 wakaba 1.36
207 wakaba 1.35 @@s:elementType:
208     @@@@: ||+||s|ForML
209     @@@ContentType: DISCore|TFPQNames
210     @@@DISCore:stopISARecursive:1
211    
212     @@rdf:type:
213     @@@@: s|ElementType
214     @@@ForCheck: s|ForML
215 wakaba 1.25
216 wakaba 1.35 @@f:implements: pc|CoreFeature10
217 wakaba 1.25
218     ElementTypeBinding:
219     @Name: IFQName
220     @ElementType:
221     dis:QName
222     @ShadowContent:
223     @@ForCheck: ManakaiDOM|ForIF
224    
225     ElementTypeBinding:
226 wakaba 1.35 @Name: CQName
227     @ElementType:
228     dis:QName
229     @ShadowContent:
230 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
231 wakaba 1.25
232     ElementTypeBinding:
233     @Name: IFISA
234     @ElementType:
235     dis:ISA
236     @ShadowContent:
237     @@ForCheck: ManakaiDOM|ForIF
238    
239     ElementTypeBinding:
240 wakaba 1.35 @Name: CISA
241     @ElementType:
242     dis:ISA
243     @ShadowContent:
244 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
245 wakaba 1.25
246 wakaba 1.1 ## -- Classes
247    
248 wakaba 1.25 IFClsDef:
249     @IFQName: PerlCode
250 wakaba 1.35 @CQName: ManakaiPCCode
251 wakaba 1.25
252 wakaba 1.35 @CISA: DOMCore|ManakaiDOMElement
253 wakaba 1.25
254 wakaba 1.1 @enDesc:
255     A class on which another Perl code classes are constructed based.
256    
257     @Attr:
258 wakaba 1.6 @@Name: fileNode
259     @@enDesc:
260     The root <QUOTE::file> node of the tree to which this node belongs.
261 wakaba 1.25 @@Type: PerlCode
262 wakaba 1.6 @@Get:
263     @@@enDesc:
264     The <QUOTE::file> node of the tree.
265     @@@nullCase:
266     @@@@enDesc:
267     This node does not belong to any file tree.
268     @@@PerlDef:
269 wakaba 1.35 __DEEP{
270     $r = $self-><AG::Node.ownerDocument>
271     -><AG::Document.documentElement>;
272     if ($r) {
273     unless (defined $r-><AG::Node.namespaceURI> and
274     $r-><AG::Node.namespaceURI> eq <Q::pc:> and
275     $r-><AG::Node.localName> eq 'file') {
276     $r = null;
277     }
278     }
279     }__;
280 wakaba 1.6
281     @Method:
282     @@Name: replaceVariable
283     @@enDesc:
284     Replaces a variable.
285     \
286     {NOTE:: For objects of type <Class::ManakaiPerlFile>,
287 wakaba 1.11 <Class::ManakaiPerlPackageScope>,
288     <Class::ManakaiPerlSub> and
289     <Class::ManakaiPerlVariable>, the result is undefined.
290 wakaba 1.6 \
291     }
292     @@Param:
293     @@@Name: originalVariable
294     @@@Type:
295     lang:Perl::ManakaiDOM:all
296     @@@enDesc:
297     Original variable specification, including prefix.
298     \
299     {NOTE:: Qualified name variable and hash key is not supported.
300     \
301     }
302     @@Param:
303     @@@Name: newValue
304 wakaba 1.11 @@@Type:
305     DOMMain:any::ManakaiDOM:all
306 wakaba 1.6 @@@enDesc:
307     New value to replace.
308 wakaba 1.11 @@@InCase:
309 wakaba 1.25 @@@@Type: PerlCode
310 wakaba 1.11 @@@@enDesc:
311     New Perl code fragment to replace by.
312     @@@InCase:
313     @@@@Type:
314     lang:Perl::ManakaiDOM:all
315     @@@@enDesc:
316     Inline Perl code fragment string to replace by.
317 wakaba 1.6 @@Return:
318     @@@PerlDef:
319 wakaba 1.35 my $ln = $self-><AG::Node.localName>;
320     if ($ln eq 'unparsed' or
321     $ln eq 'inlineUnparsed') {
322     my $new_var = ref $newValue ? $newValue->stringify : ''.$newValue;
323     my $val = $self-><AG::Node.textContent>;
324     $val =~ s/\Q$originalVariable\E\b/$new_var/g;
325     $self-><AS::Node.textContent> ($val);
326     } elsif ($ln eq 'stringLiteral' or $ln eq 'atom' or
327     $ln eq 'tokens') {
328     #
329     } elsif ($self-><M::Node.hasChildNodes>) {
330     __DEEP{
331     my @child_nodes = @{$self-><AG::Node.childNodes>};
332     for my $child_node (@child_nodes) {
333     if (defined $child_node-><AG::Node.namespaceURI> and
334     $child_node-><AG::Node.namespaceURI> eq <Q::pc:>) {
335     if ($child_node-><AG::Node.localName> eq 'variable') {
336     if (substr ($originalVariable, 0, 1) eq
337     $child_node-><AG::PerlVariable.variableType> and
338     not defined $child_node-><AG::PerlVariable.packageName> and
339     substr ($originalVariable, 1) eq
340     $child_node-><AG::PerlVariable.pcLocalName> and
341     not defined $child_node-><AG::PerlVariable.hashKey>) {
342     if (ref $newValue) {
343     $self-><M::Node.replaceChild> ($child_node => $newValue);
344     } else { ## ISSUE: Is this correct?
345     $child_node-><M::PerlCodeInlines.appendCode> ($newValue);
346     }
347     }
348     } else { ## Non-variable child
349     $child_node-><M::PerlCode.replaceVariable>
350     ($originalVariable => $newValue);
351     }
352     } else {
353     #
354     }
355     }
356     }__;
357     } # has child
358    
359     @ResourceDef:
360 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
361 wakaba 1.35 @@QName: addNameListAttr
362     @@rdf:type: DISPerl|BlockCode
363     @@PerlDef:
364     my %__mn = map {$_ => true}
365     split /\s+/, $node-><M::Element.getAttributeNS>
366     (<Q::pc:>, $attrName);
367     $__mn{$newName} = true;
368     $node-><M::Element.setAttributeNS>
369     (<Q::pc:>, 'pc:'.$attrName => join ' ', keys %__mn);
370    
371 wakaba 1.13
372     @Method:
373     @@Name: addUsePerlModuleName
374     @@enDesc:
375     Adds a Perl module into the list of Perl modules
376     <Perl::use>d by this code fragment.
377     @@Param:
378     @@@Name: moduleName
379 wakaba 1.35 @@@Type: DOMString
380 wakaba 1.13 @@@enDesc:
381     The name of the module package that should be <Perl::use>d.
382     @@Return:
383     @@@PerlDef:
384 wakaba 1.35 __DEEP{
385     __CODE{addNameListAttr::
386     $node => {$self},
387     $attrName => 'useModuleName',
388     $newName => {$moduleName},
389     }__;
390     }__;
391 wakaba 1.13
392     @Method:
393 wakaba 1.22 @@Name: addUseCharClassName
394     @@enDesc:
395     Adds a Perl module into the list of Perl character classes
396     <Perl::use>d by this code fragment.
397     @@Param:
398     @@@Name: moduleName
399 wakaba 1.35 @@@Type: DOMString
400 wakaba 1.22 @@@enDesc:
401     The name of the module package that should be <Perl::use>d.
402     @@Param:
403     @@@Name: charClassName
404 wakaba 1.35 @@@Type: DOMString
405 wakaba 1.22 @@@enDesc:
406     The name of the character class.
407     @@Return:
408     @@@PerlDef:
409 wakaba 1.35 __DEEP{
410     __CODE{addNameListAttr::
411     $node => {$self},
412     $attrName => 'useCharClassName',
413     $newName => {$moduleName.'.'.$charClassName},
414     }__;
415     }__;
416 wakaba 1.22
417     @Method:
418 wakaba 1.19 @@Name: addRequirePerlModuleName
419     @@enDesc:
420     Adds a Perl module into the list of Perl modules
421     <Perl::require>d by this code fragment.
422     @@Param:
423     @@@Name: moduleName
424 wakaba 1.35 @@@Type: DOMString
425 wakaba 1.19 @@@enDesc:
426     The name of the module package that should be <Perl::require>d.
427     @@Return:
428     @@@PerlDef:
429 wakaba 1.35 __DEEP{
430     __CODE{addNameListAttr::
431     $node => {$self},
432     $attrName => 'requireModuleName',
433     $newName => {$moduleName},
434     }__;
435     }__;
436 wakaba 1.19
437     @Method:
438 wakaba 1.33 @@Name: addExceptionInterfacePackageName
439     @@enDesc:
440     Adds a Perl exception interface into the list of Perl packages.
441     @@Param:
442     @@@Name: moduleName
443 wakaba 1.35 @@@Type: DOMString
444 wakaba 1.33 @@@enDesc:
445     The name of the interface package.
446     @@Return:
447     @@@PerlDef:
448 wakaba 1.35 __DEEP{
449     __CODE{addNameListAttr::
450     $node => {$self},
451     $attrName => 'exceptionInterfaceName',
452     $newName => {$moduleName},
453     }__;
454     }__;
455    
456     @ResourceDef:
457 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
458 wakaba 1.35 @@QName: getNameListAttrR
459     @@rdf:type: DISPerl|BlockCode
460     @@PerlDef:
461     my @__nodes = ($node);
462     my %__result;
463     while (@__nodes) {
464     my $__cnode = shift @__nodes;
465     if ($__cnode-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
466     defined $__cnode-><AG::Node.namespaceURI> and
467     $__cnode-><AG::Node.namespaceURI> eq <Q::pc:>) {
468     for (split /\s+/, $__cnode-><M::Element.getAttributeNS>
469     (<Q::pc:>, $attrName)) {
470     $__result{$_} = true;
471     }
472     push @__nodes, @{$__cnode-><AG::Node.childNodes>};
473     }
474     }
475     $result = [sort {$a cmp $b} keys %__result];
476     @ResourceDef:
477 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
478 wakaba 1.35 @@QName: getNameListAttr
479     @@rdf:type: DISPerl|BlockCode
480     @@PerlDef:
481     my %__result;
482     for (split /\s+/,
483     $node-><M::Element.getAttributeNS> (<Q::pc:>, $attrName)) {
484     $__result{$_} = true;
485     }
486     $result = [sort {$a cmp $b} keys %__result];
487 wakaba 1.33
488     @Method:
489 wakaba 1.15 @@Name: getUsePerlModuleNameList
490     @@enDesc:
491     Returns a list of Perl modules names that is <Perl::use>d
492     by this code fragment, including all descendant nodes.
493     @@Return:
494 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
495 wakaba 1.15 @@@enDesc:
496     A list of module names. Note that the list is <EM::dead>;
497     any modification to it does not affect to the code fragment
498     and vice versa.
499     @@@PerlDef:
500 wakaba 1.35 __DEEP{
501     __CODE{getNameListAttrR::
502     $node => {$self},
503     $attrName => 'useModuleName',
504     $result => {$r},
505     }__;
506     }__;
507 wakaba 1.15
508     @Method:
509 wakaba 1.22 @@Name: getUseCharClassNameList
510     @@enDesc:
511     Returns a list of Perl character class names that is <Perl::use>d
512     by this code fragment, including all descendant nodes.
513     @@Return:
514 wakaba 1.35 @@@Type: DISPerl|HASH||ManakaiDOM|all
515 wakaba 1.22 @@@enDesc:
516     A list of module names. Note that the list is <EM::dead>;
517     any modification to it does not affect to the code fragment
518     and vice versa.
519     @@@PerlDef:
520 wakaba 1.35 my $mc;
521     __DEEP{
522     __CODE{getNameListAttrR::
523     $node => {$self},
524     $attrName => 'useCharClassName',
525     $result => {$mc},
526     }__;
527     }__;
528     for (@$mc) {
529     my ($m, $c) = split /\./, $_, 2;
530     $r->{$m}->{$c} = true;
531     }
532 wakaba 1.22
533     @Method:
534 wakaba 1.19 @@Name: getRequirePerlModuleNameList
535     @@enDesc:
536     Returns a list of Perl modules names that is <Perl::require>d
537     by this code fragment, including all descendant nodes.
538     @@Return:
539 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
540 wakaba 1.19 @@@enDesc:
541     A list of module names. Note that the list is <EM::dead>;
542     any modification to it does not affect to the code fragment
543     and vice versa.
544     @@@PerlDef:
545 wakaba 1.35 __DEEP{
546     __CODE{getNameListAttrR::
547     $node => {$self},
548     $attrName => 'requireModuleName',
549     $result => {$r},
550     }__;
551     }__;
552 wakaba 1.19
553     @Method:
554 wakaba 1.33 @@Name: getExceptionInterfacePackageNameList
555     @@enDesc:
556     Returns a list of Perl exception interface package names
557     by this code fragment, including all descendant nodes.
558     @@Return:
559 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
560 wakaba 1.33 @@@enDesc:
561     A list of package names. Note that the list is <EM::dead>;
562     any modification to it does not affect to the code fragment
563     and vice versa.
564     @@@PerlDef:
565 wakaba 1.35 __DEEP{
566     __CODE{getNameListAttrR::
567     $node => {$self},
568     $attrName => 'exceptionInterfaceName',
569     $result => {$r},
570     }__;
571     }__;
572 wakaba 1.33
573     @Method:
574 wakaba 1.13 @@Name: disAddRequireURI
575     @@enDesc:
576     Adds a <QUOTE::dis> resource into the list of <Perl::require>d
577     resources of this code fragment.
578     @@Param:
579     @@@Name: uriArg
580 wakaba 1.35 @@@Type: DOMString
581 wakaba 1.13 @@@enDesc:
582     The URI reference of the resource to add.
583     @@Return:
584     @@@PerlDef:
585 wakaba 1.35 __DEEP{
586     __CODE{addNameListAttr::
587     $node => {$self},
588     $attrName => 'requireResourceURI',
589     $newName => {$uriArg},
590     }__;
591     }__;
592 wakaba 1.15
593     @Method:
594     @@Name: disGetRequireURIList
595     @@enDesc:
596     Returns a list of <QUOTE::dis> resource URI references that is
597     <Perl::require>d by this code fragment, including all descendant nodes.
598     @@Return:
599 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
600 wakaba 1.15 @@@enDesc:
601     A list of resource URI references. Note that the list is <EM::dead>;
602     any modification to it does not affect to the code fragment
603     and vice versa.
604     @@@PerlDef:
605 wakaba 1.35 __DEEP{
606     __CODE{getNameListAttrR::
607     $node => {$self},
608     $attrName => 'requireResourceURI',
609     $result => {$r},
610     }__;
611     }__;
612    
613     @Method:
614 wakaba 1.36 @@ForCheck: ManakaiDOM|ForClass
615 wakaba 1.35 @@Operator: DISPerl|CloneMethod
616     @@Return:
617     @@@Type: PerlCode
618     @@@PerlDef:
619     __DEEP{
620     $r = $self-><M::Node.cloneNode> (true);
621     }__;
622 wakaba 1.25 ##PerlCode
623 wakaba 1.1
624 wakaba 1.13 PropDef:
625     @QName: useModuleName
626     @enDesc:
627     The list of modules.
628    
629     PropDef:
630 wakaba 1.33 @QName: pc|exceptionInterfaceName
631     @enDesc:
632     The list of exception interface packages.
633    
634     PropDef:
635 wakaba 1.22 @QName: useCharClassName
636     @enDesc:
637     The list of modules.
638    
639     PropDef:
640 wakaba 1.13 @QName: requireResourceURI
641     @enDesc:
642     The list of resources.
643    
644 wakaba 1.35 ElementTypeBinding:
645     @Name: ETQName
646     @ElementType:
647     dis:AppName
648     @ShadowContent:
649     @@ForCheck: s|ForML
650     @@ContentType: DISCore|QName
651    
652     IFClsETDef:
653 wakaba 1.25 @IFQName: PerlFile
654 wakaba 1.35 @CQName: ManakaiPCFile
655     @ETQName: pc|file
656 wakaba 1.41 @QName:
657     @@@: pc|file
658     @@ForCheck: s|ForML
659 wakaba 1.25
660     @IFISA: PerlCode
661    
662     @IFISA: PerlCodeStatements
663 wakaba 1.35 @CISA: ManakaiPCCodeStatements
664 wakaba 1.25
665 wakaba 1.1 @enDesc:
666     Perl source code files.
667    
668     @Method:
669     @@Name: appendNewPackage
670     @@enDesc:
671     Appends a new package scope block.
672     @@Param:
673     @@@Name: packageName
674 wakaba 1.35 @@@Type: DOMString
675 wakaba 1.1 @@@enDesc:
676     The fully-qualified name of the package to create.
677     @@Return:
678 wakaba 1.25 @@@Type: PerlPackage
679 wakaba 1.1 @@@enDesc:
680     The newly created package scope object.
681     @@@PerlDef:
682 wakaba 1.35 __DEEP{
683     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
684     (<Q::pc:>, 'package');
685     $r-><AS::PerlPackage.packageName> ($packageName);
686     $self-><M::Node.appendChild> ($r);
687     }__;
688 wakaba 1.1
689     @Method:
690 wakaba 1.13 @@Name: appendPackage
691     @@enDesc:
692     Appends a Perl package scope object.
693     @@Param:
694     @@@Name: codeArg
695 wakaba 1.25 @@@Type: PerlPackage
696 wakaba 1.13 @@@enDesc:
697     The package to append.
698     @@Return:
699     @@@RaiseException:
700     @@@@@:IN_USE_NODE_ERR
701     @@@@enDesc:
702     An attempt is made to set a subroutine that is
703     already used elsewhere.
704     @@@PerlDef:
705 wakaba 1.35 if ($codeArg-><AG::Node.parentNode>) {
706     __EXCEPTION{IN_USE_NODE_ERR::
707     pc:childNode => {$codeArg},
708     MDOMX:param-name => 'codeArg',
709     }__;
710 wakaba 1.1 }
711     __DEEP{
712 wakaba 1.35 $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($codeArg);
713     $self-><M::Node.appendChild> ($codeArg);
714 wakaba 1.1 }__;
715    
716     @Method:
717     @@Name: getLastPackage
718     @@enDesc:
719     Gets the last package scope block of a name.
720     @@Param:
721     @@@Name: packageName
722 wakaba 1.36 @@@@Type: DOMString
723 wakaba 1.1 @@@@enDesc:
724     The fully-qualified name of the package to get.
725     @@NamedParam:
726     @@@Name: makeNewPackage
727 wakaba 1.36 @@@Type: idl|boolean||ManakaiDOM|all
728 wakaba 1.1 @@@enDesc:
729     Whether a new package scope object should be created if
730     no package of <P::packageName> found.
731     @@@TrueCase:
732     @@@@enDesc:
733     Makes a new object if not found.
734     @@@FalseCase:
735     @@@@enDesc:
736     Don't make a new object.
737     @@Return:
738 wakaba 1.25 @@@Type: PerlPackage
739 wakaba 1.1 @@@enDesc:
740     The last package scope object whose name is equal to
741     <P::packageName>.
742     @@@nullCase:
743     @@@@enDesc:
744     There is no <P::packageName> package object and
745     the <P::makeNewPackage> parameter is set to <DOM::false>.
746     @@@PerlDef:
747 wakaba 1.35 __DEEP{
748     for my $child (@{$self-><AG::Node.childNodes>}) {
749     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
750     defined $child-><AG::Node.namespaceURI> and
751     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
752     $child-><AG::Node.localName> eq 'package') {
753     if ($child-><M::Element.getAttributeNS>
754     (<Q::pc:>, 'packageName') eq $packageName) {
755     $r = $child;
756     }
757     }
758     }
759     if (not $r and $makeNewPackage) {
760     $r = $self-><M::PerlFile.appendNewPackage> ($packageName);
761     }
762     }__;
763 wakaba 1.1
764 wakaba 1.35 @ATTR:
765 wakaba 1.1 @@Name: sourceFile
766 wakaba 1.35 @@ATTRQName: pc|sourceFile
767 wakaba 1.1 @@enDesc:
768     The file name of the source file from which this
769     Perl code is primary generated.
770 wakaba 1.35 @@ReflectCDATA:
771 wakaba 1.1 @@Get:
772     @@Set:
773    
774 wakaba 1.35 @ATTR:
775 wakaba 1.1 @@Name: sourceModule
776 wakaba 1.35 @@ATTRQName: pc|sourceModule
777 wakaba 1.1 @@enDesc:
778     The name URI reference of the source module that this package defines.
779 wakaba 1.35 @@ReflectCDATA:
780 wakaba 1.1 @@Get:
781     @@Set:
782    
783 wakaba 1.35 @ATTR:
784 wakaba 1.1 @@Name: sourceFor
785 wakaba 1.35 @@ATTRQName: pc|sourceFor
786 wakaba 1.1 @@enDesc:
787     The URI reference of the source module <QUOTE::for> for which this
788     package is.
789 wakaba 1.35 @@ReflectCDATA:
790 wakaba 1.1 @@Get:
791     @@Set:
792    
793     @ToStringMethod:
794     @@Return:
795 wakaba 1.35 @@@Type: DOMString
796 wakaba 1.1 @@@enDesc:
797     The Perl code generated.
798     @@@PerlDef:
799 wakaba 1.35 __DEEP{
800     ## -- Header
801     $r = qq<#!/usr/bin/perl \n>;
802 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
803 wakaba 1.35 (q<This file is automatically generated>);
804 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
805     (q< at >.<ClassM::ManakaiPCImplementation
806 wakaba 1.35 .rfc3339DateTime> (time).q<,>);
807 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
808 wakaba 1.35 (q< from file ">.$self-><AG::PerlFile.sourceFile>.q<",>);
809 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
810 wakaba 1.35 (q[ module <].$self-><AG::PerlFile.sourceModule>.q[>,]);
811 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
812 wakaba 1.35 (q[ for <].$self-><AG::PerlFile.sourceFor>.q[>.]);
813 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
814 wakaba 1.35 (q<Don't edit by hand!>);
815     $r .= qq<use strict;\n>;
816     $self-><AS::PerlFile.currentPackage> ('main');
817     $self-><AS::PerlFile.currentChunkNumber> (0);
818    
819     ## -- Requires
820     my $req = $self-><M::PerlCode.getRequirePerlModuleNameList>;
821     for my $pack (sort {$a cmp $b} @$req) {
822     $r .= qq<require $pack;\n>;
823     }
824    
825     ## -- Packages and global objects
826     my $pack = {};
827     for my $child (@{$self-><AG::Node.childNodes>}) {
828     $r .= $child->stringify;
829     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
830     defined $child-><AG::Node.namespaceURI> and
831     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
832     $child-><AG::Node.localName> eq 'package') {
833     for my $ipack (@{$child-><M::PerlPackage
834     .getImplementPackageNameList>}) {
835     $pack->{$ipack} ||= true; # not defined
836     }
837     $pack->{$child-><AG::PerlPackage.packageName>} = []; # defined
838     }
839     }
840    
841     ## -- Exception interface packages
842     for (sort {$a cmp $b} @{$self-><M::PerlCode
843     .getExceptionInterfacePackageNameList>}) {
844     next if ref $pack->{$_};
845     $pack->{$_} = [];
846     $r .= sprintf q<push @%s::ISA, 'Message::Util::Error' >.
847     q<unless @%s::ISA;%s>, $_, $_, "\n";
848     }
849    
850     ## -- Enables interface packages
851     my @packs = map {'$' . $_ . '::'}
852     sort {$a cmp $b}
853     grep {not ref $pack->{$_} and $pack->{$_}}
854     keys %$pack;
855     $r .= q<for (>. join (', ', @packs) . qq<){}\n> if @packs;
856    
857     ## -- Footer
858 wakaba 1.36 $r .= <ClassM::ManakaiPCImplementation.perlComment>
859 wakaba 1.35 (q[License: <].$self-><AG::PerlFile.licenseURI>.qq[>\n]);
860     $r .= qq<1;\n>;
861     }__;
862 wakaba 1.1
863     @Attr:
864     @@Name: currentPackage
865     @@enDesc:
866     The current Perl package (used in stringify method).
867 wakaba 1.35
868     {NOTE:: This attribute is not preserved by the <Perl::clone> operation.
869     }
870     @@Type: DOMString
871 wakaba 1.1 @@Get:
872     @@@disDef:
873     @@@@GetProp: currentPackage
874     @@Set:
875     @@@disDef:
876     @@@@SetProp: currentPackage
877    
878     @Attr:
879 wakaba 1.6 @@Name: currentChunkNumber
880 wakaba 1.1 @@enDesc:
881 wakaba 1.6 The current code chunk number (used in stringify method).
882 wakaba 1.35
883     {NOTE:: This attribute is not preserved by the <Perl::clone> operation.
884     }
885     @@Type: idl|unsignedLong||ManakaiDOM|all
886 wakaba 1.1 @@Get:
887     @@@disDef:
888     @@@@GetProp: currentChunk
889     @@Set:
890     @@@disDef:
891     @@@@SetProp: currentChunk
892 wakaba 1.6
893     @Method:
894     @@Name: getNextChunkNumber
895     @@enDesc:
896     Increments the current chunk number of this file
897     and returns it.
898     @@Return:
899 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
900 wakaba 1.6 @@@enDesc:
901     The next chunk number.
902     @@@PerlDef:
903 wakaba 1.30 $r = ++$self->{<H::mn:node>}->{<H::pc:currentChunk>};
904 wakaba 1.2
905 wakaba 1.35 @ATTR:
906 wakaba 1.2 @@Name: licenseURI
907 wakaba 1.36 @@ATTRQName: pc|license
908 wakaba 1.2 @@enDesc:
909     The license term URI reference for this code.
910 wakaba 1.35 @@ReflectCDATA:
911 wakaba 1.2 @@Get:
912     @@Set:
913 wakaba 1.1 ##PerlFile
914    
915     PropDef:
916 wakaba 1.36 @QName: pc|currentChunk
917 wakaba 1.1 @enDesc:
918 wakaba 1.36 The current chunk number.
919 wakaba 1.1
920     PropDef:
921 wakaba 1.36 @QName: pc|currentPackage
922 wakaba 1.1 @enDesc:
923 wakaba 1.36 The current package fully qualified name.
924 wakaba 1.1
925 wakaba 1.35 ElementTypeBinding:
926     @Name: ReflectCDATA
927     @ElementType:
928     dis:Type
929     @ShadowContent:
930     @@@: DOMString
931     @ShadowSibling:
932     @@actualType: CDATADOMString
933    
934     ResourceDef:
935     @QName: DOMString
936     @For: ManakaiDOM|Perl
937     @AliasFor: DOMMain|DOMString||ManakaiDOM|ManakaiDOMLatest
938    
939     ReflectTypeDef:
940     @QName: CDATADOMString
941     @enDesc:
942     <IF::DOMMain:DOMString> for DOM attributes reflecting
943     <SGML::CDATA> element attributes.
944     @rdfs:subClassOf: DOMString
945     @ResourceDef:
946     @@rdf:type: DOMMain|ReflectGet
947     @@enDesc:
948     The DOM attribute returns the current value of the element attribute
949     in a transparent, case-sensitive manner.
950     \
951     If the element attribute is absent, the default value, if any,
952     or an empty string is returned.
953     @@PerlCDef:
954 wakaba 1.37 my $attr_stem;
955     __CODE{DOMCore:selectAttrNodeObjectNS::
956     $namespaceURI => $NS_URI_NO_NULL,
957     $localName => $LOCAL_NAME,
958     $r => $attr_stem,
959 wakaba 1.35 }__;
960 wakaba 1.37 if ($attr_stem) {
961     my $attr;
962     __CODE{ManakaiNode:getWeakReference||ManakaiDOM:Perl::
963     $object => $attr_stem,
964     $ref => $attr,
965     $class => {<ClassName::DOMCore:ManakaiDOMAttr>},
966     }__;
967     __CODE{DOMCore:getNodeTextContent::
968     $node => $attr,
969     $result => $r,
970     }__;
971     }
972     # else : default : empty string
973    
974 wakaba 1.35 @ResourceDef:
975     @@QName: CDATADOMStringSet
976     @@rdf:type: DOMMain|ReflectSet
977     @@enDesc:
978     The corresponding element attribute is set to the given value,
979     in a transparent, case-sensitive manner.
980     @@ImplNote:
981     @@@lang:en
982     @@@@:
983     What will happen if the <DOM::null> value is given?
984     @@PerlCDef:
985 wakaba 1.37 if (defined $given) {
986     my $prefix;
987     __CODE{DOMCore:setAttrValueNS::
988     $namespaceURI => $NS_URI_NO_NULL,
989     $localName => $LOCAL_NAME,
990     $prefix => $prefix,
991     $element => $self,
992     $value => $given,
993     }__;
994     } else {
995     __DEEP{
996 wakaba 1.35 $self-><M::Element.removeAttributeNS> ($NS_URI_NO_NULL, $LOCAL_NAME);
997 wakaba 1.37 }__;
998     }
999 wakaba 1.35
1000     ElementTypeBinding:
1001     @Name: ReflectTypeDef
1002     @ElementType:
1003     dis:ResourceDef
1004     @ShadowContent:
1005     @@rdf:type: DISLang|DataType
1006     @@ForCheck: !ManakaiDOM|IDL
1007     @@For: ManakaiDOM|DOM
1008    
1009     ElementTypeBinding:
1010     @Name: ATTR
1011     @ElementType:
1012     dis:ResourceDef
1013     @ShadowContent:
1014     @@rdf:type:
1015     @@@@: s|Attribute
1016     @@@ForCheck: s|ForML
1017     @@rdf:type:
1018     @@@@: DISLang|Attribute
1019     @@@ForCheck: ManakaiDOM|ForClass
1020     @@rdf:type:
1021     @@@@: DISLang|Attribute
1022     @@@ForCheck: ManakaiDOM|ForIF
1023     @@DocAttr:
1024     @@@@: ||+||s|ForML
1025     @@@ContentType: DISCore|TFPQNames
1026     @@@ForCheck: ManakaiDOM|ForClass
1027     @@DocAttr:
1028     @@@@: ||+||s|ForML
1029     @@@ContentType: DISCore|TFPQNames
1030     @@@ForCheck: ManakaiDOM|ForIF
1031     @@ForCheck: !=ManakaiDOM|ManakaiDOM
1032    
1033     ElementTypeBinding:
1034     @Name: ATTRQName
1035     @ElementType:
1036     dis:AppName
1037     @ShadowContent:
1038     @@ForCheck: s|ForML
1039     @@ContentType: DISCore|QName
1040    
1041     IFClsETDef:
1042 wakaba 1.25 @IFQName: PerlPackage
1043 wakaba 1.35 @CQName: ManakaiPCPackage
1044     @ETQName: pc|package
1045 wakaba 1.25
1046     @IFISA: PerlCode
1047    
1048     @IFISA: PerlCodeStatements
1049 wakaba 1.35 @CISA: ManakaiPCCodeStatements
1050 wakaba 1.16
1051     @enDesc:
1052     A Perl lexical lines for which a <Perl::package> declaration
1053     in effect.
1054 wakaba 1.1
1055 wakaba 1.35 @ATTR:
1056 wakaba 1.1 @@Name: packageName
1057 wakaba 1.35 @@ATTRQName: pc|packageName
1058     @@ReflectCDATA:
1059 wakaba 1.1 @@enDesc:
1060     The fully-qualified package name.
1061     @@Get:
1062 wakaba 1.35 @@Set:
1063 wakaba 1.1
1064     @Method:
1065     @@Name: getSub
1066     @@enDesc:
1067     Gets a subroutine.
1068     @@Param:
1069     @@@Name: subName
1070 wakaba 1.36 @@@Type: DOMString
1071 wakaba 1.1 @@@enDesc:
1072     The name of subroutine to get.
1073     @@NamedParam:
1074     @@@Name: makeNewNode
1075 wakaba 1.36 @@@Type: idl|boolean||ManakaiDOM|all
1076 wakaba 1.1 @@@enDesc:
1077     Whether a new subroutine object should be created,
1078     if it is not exist, or not.
1079     @@Return:
1080 wakaba 1.25 @@@Type: PerlSub
1081 wakaba 1.1 @@@enDesc:
1082     The subroutine object.
1083 wakaba 1.4 @@@nullCase:
1084     @@@@enDesc:
1085     Either the specified subroutine is not found and
1086     the <P::makeNewNode> parameter is set to <DOM::false> or
1087     the subroutine is defined as an alias.
1088 wakaba 1.1 @@@PerlDef:
1089 wakaba 1.35 __DEEP{
1090     F: {
1091     for my $child (@{$self-><AG::Node.childNodes>}) {
1092     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
1093     defined $child-><AG::Node.namespaceURI> and
1094     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
1095     $child-><AG::Node.localName> eq 'sub') {
1096     if ($child-><M::PerlSub.hasPerlName> ($subName)) {
1097     $r = $child;
1098     last F;
1099     }
1100     }
1101     }
1102     if ($makeNewNode) {
1103     $r = $self-><AG::Node.ownerDocument>
1104     -><M::Document.createElementNS>
1105     (<Q::pc:>, 'sub');
1106     $r-><M::PerlSub.addPerlName> ($subName);
1107     $self-><M::Node.appendChild> ($r);
1108     }
1109     } # F
1110     }__;
1111 wakaba 1.1
1112 wakaba 1.4 @Method:
1113 wakaba 1.35 @@Name: setSubNode
1114     @@enDesc:
1115     Sets a subrotine.
1116     @@Param:
1117     @@@Name: subArg
1118     @@@Type: PerlSub
1119     @@@enDesc:
1120     The subroutine object.
1121     @@Return:
1122     @@@RaiseException:
1123     @@@@@:IN_USE_NODE_ERR
1124     @@@@enDesc:
1125     An attempt is made to set a subroutine that is
1126     already used elsewhere.
1127     @@@PerlDef:
1128     __DEEP{
1129     if ($subArg-><AG::Node.parentNode>) {
1130     __UNDEEP{__EXCEPTION{IN_USE_NODE_ERR::
1131     pc:childNode => {$subArg},
1132     }__}__;
1133     }
1134     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($subArg);
1135     $self-><M::Node.appendChild> ($subArg);
1136     }__;
1137    
1138     @Method:
1139 wakaba 1.4 @@Name: getOverloadSub
1140     @@enDesc:
1141     Gets an overloading subroutine.
1142     @@Param:
1143     @@@Name: opName
1144     @@@Type:
1145     DISLang:String::ManakaiDOM:all
1146     @@@enDesc:
1147     The name of the overloaded operator.
1148     @@NamedParam:
1149     @@@Name: makeNewNode
1150     @@@Type:
1151 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
1152 wakaba 1.4 @@@enDesc:
1153     Whether a new subroutine object should be created,
1154     if it is not exist, or not.
1155     @@Return:
1156 wakaba 1.25 @@@Type: PerlSub
1157 wakaba 1.4 @@@enDesc:
1158     The subroutine object.
1159     @@@nullCase:
1160     @@@@enDesc:
1161     Either the specified subroutine is not found and
1162     the <P::makeNewNode> parameter is set to <DOM::false> or
1163     the specified operator is overloaded by specifying method name.
1164     @@@UnknownOperatorException:
1165     @@@PerlDef:
1166 wakaba 1.35 unless (<Code::operatorNameList>->{$opName}) {
1167     __EXCEPTION{UNSUPPORTED_OPERATOR_ERR::
1168     pc:operator => {$opName},
1169     MDOMX:param-name => 'opName',
1170     }__;
1171     }
1172     __DEEP{
1173     F: {
1174     for my $child (@{$self-><AG::Node.childNodes>}) {
1175     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
1176     defined $child-><AG::Node.namespaceURI> and
1177     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
1178     $child-><AG::Node.localName> eq 'sub') {
1179     if ($child-><M::PerlSub.hasPerlOperator> ($opName)) {
1180     $r = $child;
1181     last F;
1182     }
1183     }
1184     }
1185     if ($makeNewNode) {
1186     $r = $self-><AG::Node.ownerDocument>
1187     -><M::Document.createElementNS>
1188     (<Q::pc:>, 'sub');
1189     $r-><M::PerlSub.addPerlOperator> ($opName);
1190     $self-><M::Node.appendChild> ($r);
1191     }
1192     } # F
1193     }__;
1194 wakaba 1.4
1195     @Method:
1196 wakaba 1.13 @@Name: addISAPackage
1197 wakaba 1.1 @@enDesc:
1198     Adds a class package that this class inherits.
1199     @@Param:
1200     @@@Name: packageName
1201 wakaba 1.35 @@@Type: DOMString
1202 wakaba 1.1 @@@enDesc:
1203     The name of package to add.
1204     @@Return:
1205     @@@PerlDef:
1206 wakaba 1.35 __DEEP{
1207     $self-><M::Element.setAttributeNS>
1208     (<Q::pc:>, 'pc:extends' =>
1209     join ' ', (split /\s+/, $self-><M::Element.getAttributeNS>
1210     (<Q::pc:>, 'extends')), $packageName);
1211     }__;
1212    
1213     @Method:
1214     @@Name: getISAPackageNameList
1215     @@enDesc:
1216     Returns a list of names of packages extended by the package.
1217     @@Return:
1218     @@@Type: DISPerl|ARRAY||ManakaiDOM|all
1219     @@@enDesc:
1220     An ordered snapshot list of superpackage names.
1221     @@@PerlDef:
1222     __DEEP{
1223     $r = [split /\s+/, $self-><M::Element.getAttributeNS>
1224     (<Q::pc:>, 'extends')];
1225     }__;
1226 wakaba 1.1
1227     @Method:
1228     @@Name: addImplementPackage
1229     @@enDesc:
1230     Adds a interface package that this class implements.
1231     @@Param:
1232     @@@Name: packageName
1233 wakaba 1.35 @@@Type: DOMString
1234 wakaba 1.1 @@@enDesc:
1235     The name of package to add.
1236     @@Return:
1237     @@@PerlDef:
1238 wakaba 1.35 __DEEP{
1239     __CODE{addNameListAttr::
1240     $node => {$self},
1241     $attrName => 'implements',
1242     $newName => {$packageName},
1243     }__;
1244     }__;
1245    
1246     @Method:
1247     @@Name: getImplementPackageNameList
1248     @@enDesc:
1249     Returns a list of names of packages implemented by the package.
1250     @@Return:
1251     @@@Type: DISPerl|ARRAY||ManakaiDOM|all
1252     @@@enDesc:
1253     An unordered snapshot list of interface packages.
1254     @@@PerlDef:
1255     __DEEP{
1256     __CODE{getNameListAttr::
1257     $node => {$self},
1258     $attrName => 'implements',
1259     $result => {$r},
1260     }__;
1261     }__;
1262 wakaba 1.1
1263     @ToStringMethod:
1264     @@Return:
1265 wakaba 1.35 @@@Type: DOMString
1266 wakaba 1.1 @@@enDesc:
1267     Perl code.
1268     @@@PerlDef:
1269 wakaba 1.35 __DEEP{
1270     my $file = $self-><AG::PerlCode.fileNode>;
1271    
1272     ## Package name
1273     my $pn = $self-><AG::PerlPackage.packageName>;
1274     $r .= q<package > . $pn . ";\n";
1275     $file-><AS::PerlFile.currentPackage> ($pn) if $file;
1276    
1277     ## Package version
1278     $r .= 'our $VERSION = '.
1279 wakaba 1.36 <ClassM::ManakaiPCImplementation.versionDateTime> (time).
1280 wakaba 1.35 ";\n";
1281    
1282     ## Inheritance
1283     my @isa = (@{$self-><M::PerlPackage.getISAPackageNameList>},
1284     sort {$a cmp $b} @{$self-><M::PerlPackage
1285     .getImplementPackageNameList>});
1286     if (@isa) {
1287     $r .= 'push our @ISA, ' .
1288 wakaba 1.36 <ClassM::ManakaiPCImplementation.perlList> (\@isa) .
1289 wakaba 1.35 ";\n";
1290     }
1291    
1292     ## Use'ing modules
1293     for my $pack (sort {$a cmp $b} @{$self-><M::PerlCode
1294     .getUsePerlModuleNameList>}) {
1295     $r .= 'use ' . $pack . ";\n";
1296     }
1297    
1298     my $cls = $self-><M::PerlCode.getUseCharClassNameList>;
1299     for my $pack (sort {$a cmp $b} keys %$cls) {
1300     $r .= 'use ' . $pack . ' ' .
1301 wakaba 1.36 <ClassM::ManakaiPCImplementation.perlList>
1302 wakaba 1.35 ([sort {$a cmp $b} grep {$cls->{$pack}->{$_}}
1303     keys %{$cls->{$pack}}]) . ";\n";
1304     }
1305    
1306     ## Package-scope objects
1307     my $has_bool;
1308     my $op = '';
1309     for my $child (@{$self-><AG::Node.childNodes>}) {
1310     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
1311     defined $child-><AG::Node.namespaceURI> and
1312     $child-><AG::Node.namespaceURI> eq <Q::pc:>) {
1313     my $ln = $child-><AG::Node.localName>;
1314     if ($ln eq 'sub') {
1315     my $names = $child-><M::PerlSub.getPerlNameList>;
1316     my $ops = $child-><M::PerlSub.getPerlOperatorList>;
1317     if (@$names) {
1318     $r .= $child->stringify;
1319     if (@$names > 1) {
1320     $r .= sprintf q<*%s = \&%s;%s>,
1321     $_, $names->[0], "\n" for @$names[1..$#$names];
1322     }
1323     for (@$ops) {
1324     $op .= sprintf q['%s' => '%s', %s],
1325     $_ => $names->[0], "\n";
1326     $has_bool = true if $_ eq 'bool';
1327     }
1328     } else {
1329     my $v = $child->stringify;
1330     for (@$ops) {
1331     $op .= sprintf q['%s' => %s, %s], $_ => $v, "\n";
1332     $has_bool = true if $_ eq 'bool';
1333     }
1334     }
1335     } else {
1336     $r .= $child->stringify;
1337     }
1338 wakaba 1.49 } elsif ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>) {
1339     $r .= $child;
1340     }
1341 wakaba 1.35 } # children
1342    
1343     if (length $op) {
1344     $r .= "use overload \n";
1345     $r .= "bool => sub () {1}, \n" unless $has_bool;
1346     $r .= $op . "fallback => 1;\n";
1347     }
1348    
1349     ## -- Exports
1350     my $xport = $self-><M::PerlPackage.getExportList>;
1351     if (map {values %$_} values %$xport) {
1352     $r .= q[our %EXPORT_TAG = (] .
1353 wakaba 1.36 <ClassM::ManakaiPCImplementation.perlList>
1354 wakaba 1.35 ([map {$_ => [sort {$a cmp $b} keys %{$xport->{$_}}]}
1355     sort {$a cmp $b} grep {length}
1356     keys %$xport]) . qq[);\n];
1357     $r .= q[our @EXPORT_OK = (] .
1358 wakaba 1.36 <ClassM::ManakaiPCImplementation.perlList>
1359 wakaba 1.35 ([map {sort {$a cmp $b} keys %{$xport->{$_}}}
1360     sort {$a cmp $b} keys %$xport]) . qq[);\n];
1361     $r .= q[use Exporter; push our @ISA, 'Exporter';] . qq[\n];
1362     }
1363     }__;
1364    
1365     @Method:
1366     @@Name: getExportList
1367     @@enDesc:
1368     Returns a list of export tag and names.
1369     @@Return:
1370     @@@Type: DISPerl|HASH||ManakaiDOM|all
1371     @@@enDesc:
1372     Snapshot list of lists.
1373     @@@PerlDef:
1374     my $mc;
1375     __DEEP{
1376     __CODE{getNameListAttr::
1377     $node => {$self},
1378     $attrName => 'export',
1379     $result => {$mc},
1380     }__;
1381     }__;
1382     for (@$mc) {
1383     my ($m, $c) = split /\./, $_, 2;
1384     $r->{$m}->{$c} = true;
1385     }
1386 wakaba 1.18
1387     @Method:
1388     @@Name: addExport
1389     @@enDesc:
1390 wakaba 1.26 Adds a name to the list of exported items (<Perl::@EXPORT_OK>).
1391 wakaba 1.18 @@Param:
1392     @@@Name: exportTag
1393 wakaba 1.35 @@@Type: DOMString
1394 wakaba 1.18 @@@enDesc:
1395     The name of the tag (without <CHAR::COLON> prefix).
1396     The <P::exportName> is added both to <Perl::@EXPORT_OK>
1397     and <Perl::$EXPORT_OK{<P::exportTag>}>.
1398     @@@nullCase:
1399     @@@@enDesc:
1400     The <P::exportName> is added only to the <Perl::@EXPORT_OK>.
1401     @@Param:
1402     @@@Name: exportName
1403 wakaba 1.35 @@@Type: DOMString
1404 wakaba 1.18 @@@enDesc:
1405     The name to be exported.
1406     @@Return:
1407     @@@PerlDef:
1408 wakaba 1.35 __DEEP{
1409     __CODE{addNameListAttr::
1410     $node => {$self},
1411     $attrName => 'export',
1412     $newName => {$exportTag.'.'.$exportName},
1413     }__;
1414     }__;
1415 wakaba 1.36 ##PCPackage
1416 wakaba 1.4
1417     ElementTypeBinding:
1418     @Name: UnknownOperatorException
1419     @ElementType:
1420     ManakaiDOM:raises
1421     @ShadowContent:
1422     @@@:UNSUPPORTED_OPERATOR_ERR
1423     @@enDesc:
1424     An attempt is made to overload an unknown operator.
1425    
1426     XParamDef:
1427     @QName:
1428     pc:operator
1429     @enDesc:
1430     An operator to overload.
1431    
1432     ResourceDef:
1433 wakaba 1.28 @For: ManakaiDOM|Perl
1434 wakaba 1.4 @QName: operatorNameList
1435     @enDesc:
1436     The list of valid operators for <PerlModule::operator> pragma.
1437 wakaba 1.36 @rdf:type: DISPerl|InlineCode
1438 wakaba 1.28 @PerlCDef:
1439 wakaba 1.4 {qw[
1440     + 1 - 1 * 1 / 1 % 1 ** 1 << 1 >> 1 x 1 . 1
1441     += 1 -= 1 *= 1 /= 1 %= 1 **= 1 <<= 1 >>= 1 x= 1 .= 1
1442     < 1 <= 1 > 1 >= 1 == 1 != 1 <=> 1
1443     lt 1 le 1 gt 1 ge 1 eq 1 ne 1 cmp 1
1444     & 1 | 1 ^ 1 neg 1 ! 1 ~ 1
1445     ++ 1 -- 1 = 1
1446     atan2 1 cos 1 sin 1 exp 1 abs 1 log 1 sqrt 1
1447     bool 1 "" 1 0+ 1 ${} 1 @{} 1 %{} 1 &{} 1 *{} 1 <> 1
1448     nomethod 1
1449     ]}
1450    
1451 wakaba 1.35 IFClsETDef:
1452 wakaba 1.25 @IFQName: PerlCodeStatements
1453 wakaba 1.35 @CQName: ManakaiPCCodeStatements
1454     @ETQName:
1455     @@@: pc|statementContainer
1456     @@ImplNote:
1457     @@@lang:en
1458     @@@@: Dummy.
1459 wakaba 1.25
1460     @IFISA: PerlCodeUnits
1461 wakaba 1.35 @CISA: ManakaiPCCodeUnits
1462 wakaba 1.36
1463 wakaba 1.1 @enDesc:
1464 wakaba 1.6 A base class for node types that contains zero or more
1465     statements and/or blocks.
1466 wakaba 1.1
1467 wakaba 1.35 @ATTR:
1468 wakaba 1.10 @@Name: sourceFile
1469 wakaba 1.35 @@ATTRQName: pc|sourceFile
1470 wakaba 1.10 @@enDesc:
1471     The source file name of this fragment.
1472 wakaba 1.35 @@ReflectCDATA:
1473 wakaba 1.10 @@Get:
1474     @@@enDesc:
1475     Any string identifying the source.
1476     @@@nullCase:
1477     @@@@enDesc: No source file name is set.
1478     @@Set:
1479     @@@nullCase:
1480     @@@@enDesc: No (or unknown) source file.
1481    
1482 wakaba 1.35 @ATTR:
1483 wakaba 1.10 @@Name: sourceLine
1484 wakaba 1.35 @@ATTRQName: pc|sourceLine
1485 wakaba 1.10 @@enDesc:
1486     Source file line number of the first line of this fragment.
1487 wakaba 1.35 @@ReflectCDATA:
1488 wakaba 1.10 @@Get:
1489     @@Set:
1490    
1491 wakaba 1.35 @ATTR:
1492 wakaba 1.1 @@Name: currentSourceFile
1493 wakaba 1.35 @@ATTRQName: pc|currentSourceFile
1494 wakaba 1.1 @@enDesc:
1495     The current source file name that is referred when
1496     a code fragment is added.
1497 wakaba 1.35 @@ReflectCDATA:
1498 wakaba 1.1 @@Get:
1499     @@@nullCase:
1500     @@@@enDesc: No source file name is set.
1501     @@Set:
1502     @@@nullCase:
1503     @@@@enDesc: No (or unknown) source file.
1504    
1505 wakaba 1.35 @ATTR:
1506 wakaba 1.1 @@Name: currentSourceLine
1507 wakaba 1.35 @@ATTRQName: pc|currentSourceLine
1508 wakaba 1.1 @@enDesc:
1509     The current line number in source file that is referred when
1510     a code fragment is added.
1511 wakaba 1.35 @@ReflectCDATA:
1512 wakaba 1.1 @@Get:
1513     @@Set:
1514    
1515     @Method:
1516 wakaba 1.5 @@Name: appendCodeFragment
1517     @@enDesc:
1518     Appends a <Class::ManakaiPerlCodeFragment> object.
1519     @@Param:
1520     @@@Name: codeArg
1521 wakaba 1.25 @@@Type: PerlCode
1522 wakaba 1.5 @@@enDesc:
1523     A code fragment object.
1524     @@Return:
1525     @@@RaiseException:
1526     @@@@@:BAD_CHILD_ERR
1527     @@@@enDesc:
1528     An attempt is made to append a child
1529     that is not a <Class::ManakaiPerlUnparsedCode>.
1530     @@@RaiseException:
1531     @@@@@:IN_USE_NODE_ERR
1532     @@@@enDesc:
1533     An attempt is made to append a node that is
1534     already used elsewhere.
1535     @@@PerlDef:
1536 wakaba 1.35 if ({
1537     unparsed => 1, if => 1, statement => 1, block => 1,
1538 wakaba 1.43 choose => true,
1539 wakaba 1.35 blockContainer => true,
1540     inlineUnparsed => 1, variable => 1, tokens => 1, atom => 1,
1541     inlineContainer => 1, stringLiteral => 1, assignment => 1,
1542 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
1543 wakaba 1.35 }->{$codeArg-><AG::Node.localName>}) {
1544     if ($codeArg-><AG::Node.parentNode>) {
1545     __EXCEPTION{IN_USE_NODE_ERR::
1546     pc:childNode => {$codeArg},
1547     MDOMX:param-name => 'codeArg',
1548     }__;
1549     }
1550     __DEEP{
1551     $self-><AG::Node.ownerDocument>
1552     -><M::Document.adoptNode> ($codeArg);
1553     $self-><M::Node.appendChild> ($codeArg);
1554     }__;
1555     } else {
1556     __EXCEPTION{BAD_CHILD_ERR::
1557     pc:parentNode => {$self},
1558     pc:childNode => {$codeArg},
1559     MDOMX:param-name => 'codeArg',
1560     }__;
1561     }
1562 wakaba 1.5
1563     @Method:
1564 wakaba 1.1 @@Name: appendCode
1565     @@enDesc:
1566     Appends an unparsed Perl code fragment.
1567     @@Param:
1568     @@@Name: codeArg
1569 wakaba 1.35 @@@Type: DOMString
1570 wakaba 1.1 @@@enDesc:
1571     An unparsed Perl code fragment.
1572     @@Return:
1573 wakaba 1.25 @@@Type: PerlUnparsedCode
1574 wakaba 1.1 @@@enDesc:
1575     The newly created Perl code object.
1576     @@@PerlDef:
1577 wakaba 1.35 __DEEP{
1578     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
1579     (<Q::pc:>, 'unparsed');
1580     $r-><AS::Node.textContent> ($codeArg);
1581     $r-><AS::PerlCodeStatements.sourceFile>
1582     ($self-><AG::PerlCodeStatements.currentSourceFile>);
1583     my $sl = $self-><AG::PerlCodeStatements.currentSourceLine>;
1584     $r-><AS::PerlCodeStatements.sourceLine> ($sl);
1585     $self-><AG::PerlCodeStatements.currentSourceLine>
1586     ($sl + ($codeArg =~ tr/\x0A/\x0A/));
1587     $self-><M::Node.appendChild> ($r);
1588     }__;
1589 wakaba 1.1
1590     @Method:
1591     @@Name: skipLines
1592     @@enDesc:
1593     Skips lines in a code.
1594     @@Param:
1595     @@@Name: codeArg
1596 wakaba 1.35 @@@Type: DOMString
1597 wakaba 1.1 @@@enDesc:
1598     A code fragment, which is counted lines.
1599     @@Return:
1600     @@@PerlDef:
1601 wakaba 1.30 $self->{<H::mn:node>}->{<H::pc:currentSourceLine>}
1602 wakaba 1.1 += ($codeArg =~ tr/\x0A/\x0A/);
1603 wakaba 1.4
1604 wakaba 1.35 @ATTR:
1605 wakaba 1.8 @@Name: label
1606 wakaba 1.35 @@ATTRQName: pc|label
1607 wakaba 1.8 @@enDesc:
1608     Label for this block.
1609 wakaba 1.35 @@ReflectCDATA:
1610 wakaba 1.8 @@Get:
1611     @@@nullCase:
1612     @@@@enDesc:
1613     No label.
1614     @@Set:
1615     @@@nullCase:
1616     @@@@enDesc:
1617     No label.
1618    
1619     @Method:
1620     @@Name: appendBlock
1621     @@enDesc:
1622     Appends a Perl block code.
1623     @@Return:
1624 wakaba 1.25 @@@Type: PerlBlock
1625 wakaba 1.8 @@@enDesc:
1626     The newly created Perl code object.
1627     @@@PerlDef:
1628 wakaba 1.35 __DEEP{
1629     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
1630     (<Q::pc:>, 'block');
1631     $self-><M::Node.appendChild> ($r);
1632     }__;
1633 wakaba 1.8
1634     @Method:
1635     @@Name: appendStatement
1636     @@enDesc:
1637     Appends a Perl statement.
1638     @@Param:
1639     @@@Name: codeArg
1640 wakaba 1.36 @@@Type: DOMString
1641 wakaba 1.8 @@@enDesc:
1642     A Perl statement without terminating <Perl::;>.
1643     @@@nullCase:
1644     @@@@enDesc:
1645     No initial content.
1646     @@Return:
1647 wakaba 1.25 @@@Type: PerlStatement
1648 wakaba 1.8 @@@enDesc:
1649     The newly created Perl code object.
1650     @@@PerlDef:
1651 wakaba 1.35 __DEEP{
1652     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
1653     (<Q::pc:>, 'statement');
1654     if (defined $codeArg) {
1655     $r-><M::PerlCodeUnits.appendBare> ($codeArg);
1656     }
1657     $self-><M::Node.appendChild> ($r);
1658     }__;
1659 wakaba 1.12
1660     @Method:
1661 wakaba 1.44 @@Name: appendNewPCBlock
1662     @@enDesc:
1663     Creates a <Q::pc2:block> and appends it to the node.
1664     @@Return:
1665     @@@Type: PCBlock
1666     @@@enDesc:
1667     The newly created block element.
1668     @@@PerlDef:
1669     __DEEP{
1670     $r = $self-><AG::Node.ownerDocument>-><M::PCDocument.createPCBlock>;
1671     $self-><M::Node.appendChild> ($r);
1672     }__;
1673    
1674     @Method:
1675     @@Name: appendNewPCChoose
1676     @@enDesc:
1677     Creates a <Q::pc:choose> and appends it to the node.
1678     @@Return:
1679     @@@Type: PCChoose
1680     @@@enDesc:
1681     The newly created choose element.
1682     @@@PerlDef:
1683     __DEEP{
1684     $r = $self-><AG::Node.ownerDocument>-><M::PCDocument.createPCChoose>;
1685     $self-><M::Node.appendChild> ($r);
1686     }__;
1687    
1688     @Method:
1689 wakaba 1.45 @@Name: appendNewPCWhile
1690     @@enDesc:
1691     Creates a <Q::pc:while> and appends it to the node.
1692     @@Return:
1693     @@@Type: PCWhile
1694     @@@enDesc:
1695     The newly created while element.
1696     @@@PerlDef:
1697     __DEEP{
1698     $r = $self-><AG::Node.ownerDocument>-><M::PCDocument.createPCWhile>;
1699     $self-><M::Node.appendChild> ($r);
1700     }__;
1701    
1702     @Method:
1703 wakaba 1.12 @@Name: appendNewIf
1704     @@enDesc:
1705     Appends a newly created <Class::ManakaiPerlIf> object.
1706     @@Param:
1707     @@@Name: conditionArg
1708 wakaba 1.25 @@@Type: PerlCode
1709 wakaba 1.12 @@@enDesc:
1710     Conditoon code fragment object.
1711     @@Param:
1712     @@@Name: trueArg
1713 wakaba 1.25 @@@Type: PerlCode
1714 wakaba 1.12 @@@enDesc:
1715     A true code fragment object.
1716     @@@nullCase:
1717     @@@@enDesc: No true code.
1718     @@Param:
1719     @@@Name: falseArg
1720 wakaba 1.25 @@@Type: PerlCode
1721 wakaba 1.12 @@@enDesc:
1722     A false code fragment object.
1723     @@@nullCase:
1724     @@@@enDesc: No false code.
1725     @@Return:
1726 wakaba 1.36 @@@Type: PerlIf
1727 wakaba 1.35 @@@enDesc:
1728     The newly created element.
1729 wakaba 1.12 @@@RaiseException:
1730     @@@@@:BAD_CHILD_ERR
1731     @@@@enDesc:
1732     An attempt is made to append a child
1733     that is not valid type.
1734     @@@RaiseException:
1735     @@@@@:IN_USE_NODE_ERR
1736     @@@@enDesc:
1737     An attempt is made to append a node that is
1738     already used elsewhere.
1739     @@@PerlDef:
1740 wakaba 1.35 for my $arg ([conditionArg => $conditionArg]) {
1741     if ({
1742     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
1743     inlineUnparsed => 1, variable => 1, stringLiteral => true,
1744 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
1745 wakaba 1.35 }->{$arg->[1]-><AG::Node.localName>}) {
1746     if ($arg->[1]-><AG::Node.parentNode>) {
1747     __EXCEPTION{IN_USE_NODE_ERR::
1748     pc:childNode => {$arg->[1]},
1749     MDOMX:param-name => {$arg->[0]},
1750     }__;
1751     }
1752     } else {
1753     __EXCEPTION{BAD_CHILD_ERR::
1754     pc:parentNode => {$self},
1755     pc:childNode => {$arg->[1]},
1756     MDOMX:param-name => {$arg->[0]},
1757     }__;
1758     }
1759     } # c
1760 wakaba 1.6
1761 wakaba 1.35 for my $arg ([trueArg => $trueArg],
1762     [falseArg => $falseArg]) {
1763     next unless $arg->[1];
1764     if ({
1765     blockContainer => true,
1766     }->{$arg->[1]-><AG::Node.localName>}) {
1767     if ($arg->[1]-><AG::Node.parentNode>) {
1768     __EXCEPTION{IN_USE_NODE_ERR::
1769     pc:childNode => {$arg->[1]},
1770     MDOMX:param-name => {$arg->[0]},
1771     }__;
1772     }
1773     } else {
1774     __EXCEPTION{BAD_CHILD_ERR::
1775     pc:parentNode => {$self},
1776     pc:childNode => {$arg->[1]},
1777     MDOMX:param-name => {$arg->[0]},
1778     }__;
1779     }
1780     } # t/f
1781    
1782     __DEEP{
1783     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
1784     (<Q::pc:>, 'if');
1785     $r-><AS::PerlIf.condition> ($conditionArg);
1786     $r-><AS::PerlIf.trueCode> ($trueArg) if $trueArg;
1787     $r-><AS::PerlIf.falseCode> ($falseArg) if $falseArg;
1788     $self-><M::Node.appendChild> ($r);
1789     }__;
1790     ##PCIf
1791    
1792     IFClsETDef:
1793 wakaba 1.25 @IFQName: PerlSub
1794 wakaba 1.35 @CQName: ManakaiPCSub
1795     @ETQName: pc|sub
1796 wakaba 1.25
1797     @IFISA: PerlCode
1798    
1799     @IFISA: PerlCodeStatements
1800 wakaba 1.35 @CISA: ManakaiPCCodeStatements
1801 wakaba 1.25
1802 wakaba 1.6 @enDesc:
1803 wakaba 1.36 Perl subroutines.
1804 wakaba 1.20
1805 wakaba 1.6 @Attr:
1806 wakaba 1.35 @@Name: pcLocalName
1807 wakaba 1.6 @@enDesc:
1808     The name of this subroutine.
1809 wakaba 1.35 @@Type: DOMString
1810 wakaba 1.6 @@Get:
1811     @@@nullCase:
1812     @@@@enDesc:
1813     This subroutine has no name.
1814 wakaba 1.35 @@@PerlDef:
1815     __DEEP{
1816     $r = $self-><M::PerlSub.getPerlNameList>->[0];
1817     }__;
1818 wakaba 1.6
1819 wakaba 1.35 @Method:
1820     @@Name: addPerlName
1821     @@enDesc:
1822     Adds a subroutine name.
1823     @@Param:
1824     @@@Name: subName
1825     @@@Type: DOMString
1826     @@@enDesc: The name to add.
1827     @@Return:
1828     @@@PerlDef:
1829     __DEEP{
1830     __CODE{addNameListAttr::
1831     $node => {$self},
1832     $attrName => 'localName',
1833     $newName => {$subName},
1834     }__;
1835     }__;
1836    
1837     @Method:
1838     @@Name: getPerlNameList
1839     @@enDesc:
1840     Returns a list of names of the subroutine.
1841     @@Return:
1842     @@@Type: DISPerl|ARRAY||ManakaiDOM|all
1843     @@@enDesc:
1844     An unordered snapshot list of names.
1845     @@@PerlDef:
1846     __DEEP{
1847     __CODE{getNameListAttr::
1848     $node => {$self},
1849     $attrName => 'localName',
1850     $result => {$r},
1851     }__;
1852     }__;
1853    
1854     @Method:
1855     @@Name: hasPerlName
1856     @@enDesc:
1857     Returns whether the subroutine has a name or not.
1858     @@Param:
1859     @@@Name: subName
1860     @@@Type: DOMString
1861     @@@enDesc: The name.
1862     @@Return:
1863     @@@Type: idl|boolean||ManakaiDOM|all
1864     @@@PerlDef:
1865     __DEEP{
1866     my $l;
1867     __CODE{getNameListAttr::
1868     $node => {$self},
1869     $attrName => 'localName',
1870     $result => {$l},
1871     }__;
1872     F: for (@$l) {
1873     if ($_ eq $subName) {
1874     $r = true;
1875     last F;
1876     }
1877     }
1878     }__;
1879    
1880     @Method:
1881 wakaba 1.47 @@Name: clearPerlName
1882     @@enDesc:
1883     Removes all Perl name associated to the <IF::PerlSub>.
1884     @@Return:
1885     @@@PerlDef:
1886     __DEEP{
1887     $self-><M::Element.removeAttributeNS> (<Q::pc:>, 'localName');
1888     }__;
1889    
1890     @Method:
1891 wakaba 1.35 @@Name: addPerlOperator
1892     @@enDesc:
1893     Adds an operator overloaded by the method.
1894     @@Param:
1895     @@@Name: op
1896     @@@Type: DOMString
1897     @@@enDesc: The operator to add.
1898     @@Return:
1899     @@@PerlDef:
1900     __DEEP{
1901     __CODE{addNameListAttr::
1902     $node => {$self},
1903     $attrName => 'operator',
1904     $newName => {$op},
1905     }__;
1906     }__;
1907    
1908     @Method:
1909     @@Name: getPerlOperatorList
1910     @@enDesc:
1911     Returns a list of operators of the subroutine.
1912     @@Return:
1913     @@@Type: DISPerl|ARRAY||ManakaiDOM|all
1914     @@@enDesc:
1915     An unordered snapshot list of operators.
1916     @@@PerlDef:
1917     __DEEP{
1918     __CODE{getNameListAttr::
1919     $node => {$self},
1920     $attrName => 'operator',
1921     $result => {$r},
1922     }__;
1923     }__;
1924    
1925     @Method:
1926     @@Name: hasPerlOperator
1927     @@enDesc:
1928     Returns whether the subroutine has an operator or not.
1929     @@Param:
1930     @@@Name: op
1931     @@@Type: DOMString
1932     @@@enDesc: The operator.
1933     @@Return:
1934     @@@Type: idl|boolean||ManakaiDOM|all
1935     @@@PerlDef:
1936     __DEEP{
1937     my $l;
1938     __CODE{getNameListAttr::
1939     $node => {$self},
1940     $attrName => 'operator',
1941     $result => {$l},
1942     }__;
1943     F: for (@$l) {
1944     if ($_ eq $op) {
1945     $r = true;
1946     last F;
1947     }
1948     }
1949     }__;
1950    
1951     @ATTR:
1952 wakaba 1.6 @@Name: prototype
1953 wakaba 1.35 @@ATTRQName: pc|prototype
1954 wakaba 1.6 @@enDesc:
1955     The prototype of this subroutine.
1956 wakaba 1.35 @@ReflectCDATA:
1957 wakaba 1.6 @@Get:
1958     @@@nullCase:
1959     @@@@enDesc:
1960     No prototype is set.
1961     @@Set:
1962     @@@nullCase:
1963     @@@@enDesc:
1964     No prototype declaration.
1965 wakaba 1.42
1966     @@Test:
1967     @@@ForCheck: ManakaiDOM|ForClass
1968     @@@enDesc:
1969     Getting value after setting empty value must return an empty string.
1970     @@@PerlDef:
1971     my $impl = <Class::ManakaiPCImplementation>->_new;
1972     my $sub = $impl-><M::PCImplementation.createPerlSub> ("sub_name");
1973     $test->assert_not_null ($sub);
1974    
1975     $sub-><AS::PerlSub.prototype> ('');
1976     $test->assert_string (actual_value => $sub-><AG::PerlSub.prototype>,
1977     expected_value => '');
1978     $test->assert_true ($sub->stringify =~ /^sub sub_name \(\)/);
1979 wakaba 1.6
1980 wakaba 1.4 @ToStringMethod:
1981     @@Return:
1982 wakaba 1.35 @@@Type: DOMString
1983 wakaba 1.4 @@@enDesc:
1984     Perl code.
1985     @@@PerlDef:
1986 wakaba 1.35 __DEEP{
1987     $r = q<sub>;
1988     my $nm = $self-><M::PerlSub.getPerlNameList>;
1989     $r .= q< > . $nm->[0] if @$nm;
1990 wakaba 1.42 if ($self-><M::Element.hasAttributeNS> (<Q::pc:>, 'prototype')) {
1991     $r .= q< (> . $self-><AG::PerlSub.prototype> . q<)>;
1992     }
1993 wakaba 1.35 $r .= qq< {\n>;
1994     for my $child (@{$self-><AG::Node.childNodes>}) {
1995     $r .= $child->stringify;
1996     }
1997     $r .= qq<}\n>;
1998     }__;
1999 wakaba 1.14
2000     @NumValMethod:
2001     @@Return:
2002 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2003 wakaba 1.14 @@@PerlDef:
2004 wakaba 1.35 __DEEP{
2005     $r = 0 + $self-><AG::Node.lastChild>;
2006     }__;
2007 wakaba 1.47 ##PerlSub
2008 wakaba 1.1
2009 wakaba 1.42 ElementTypeBinding:
2010     @Name: Test
2011     @ElementType:
2012     dis:ResourceDef
2013     @ShadowContent:
2014     @@rdf:type: test|StandaloneTest
2015    
2016 wakaba 1.5 XParamDef:
2017     @QName: parentNode
2018     @enDesc:
2019     Parent node.
2020    
2021     XParamDef:
2022     @QName: childNode
2023     @enDesc:
2024     Child node.
2025    
2026 wakaba 1.35 IFClsETDef:
2027 wakaba 1.25 @IFQName: PerlUnparsedCode
2028 wakaba 1.35 @CQName: ManakaiPCUnparsedCode
2029     @ETQName: pc|unparsed
2030 wakaba 1.25
2031     @IFISA: PerlCode
2032 wakaba 1.35 @CISA: ManakaiPCCode
2033 wakaba 1.25
2034 wakaba 1.1 @enDesc:
2035     Unparsed Perl code fragments.
2036 wakaba 1.5
2037 wakaba 1.35 @ATTR:
2038 wakaba 1.5 @@Name: sourceFile
2039 wakaba 1.35 @@ATTRQName: pc|sourceFile
2040 wakaba 1.5 @@enDesc:
2041     The source file name of this fragment.
2042 wakaba 1.35 @@ReflectCDATA:
2043 wakaba 1.5 @@Get:
2044     @@@enDesc:
2045     Any string identifying the source.
2046     @@@nullCase:
2047     @@@@enDesc: No source file name is set.
2048     @@Set:
2049     @@@nullCase:
2050     @@@@enDesc: No (or unknown) source file.
2051    
2052 wakaba 1.35 @ATTR:
2053 wakaba 1.5 @@Name: sourceLine
2054 wakaba 1.35 @@ATTRQName: pc|sourceLine
2055 wakaba 1.5 @@enDesc:
2056     Source file line number of the first line of this fragment.
2057 wakaba 1.35 @@ReflectCDATA:
2058 wakaba 1.5 @@Get:
2059     @@Set:
2060 wakaba 1.6
2061     @ToStringMethod:
2062     @@Return:
2063 wakaba 1.35 @@@Type: DOMString
2064 wakaba 1.6 @@@enDesc:
2065     Perl code.
2066     @@@PerlDef:
2067 wakaba 1.35 __DEEP{
2068 wakaba 1.39 $r = "\x0A" . $self-><AG::Node.textContent> . "\x0A";
2069 wakaba 1.35 my $file = $self-><AG::PerlCode.fileNode>;
2070 wakaba 1.38 my $src_file = $file ? $file-><AG::PerlFile.sourceFile>
2071     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
2072 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
2073     -><AG::Document.domConfig>
2074     -><M::DOMCore:DOMConfiguration.getParameter>
2075     (<Q::pc:line>)) {
2076     my $nxt_cnum = $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
2077     $r = sprintf qq<\n#line %d "%s [u] (Chunk #%d)"%s>.
2078     qq<#line 1 "%s [/u] (Chunk #%d)"\n>,
2079 wakaba 1.35 $self-><AG::PerlUnparsedCode.sourceLine> || 1,
2080     $self-><AG::PerlUnparsedCode.sourceFile> || $src_file,
2081     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
2082 wakaba 1.39 $r,
2083 wakaba 1.35 $src_file,
2084     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
2085 wakaba 1.39 }
2086 wakaba 1.35 }__;
2087 wakaba 1.1 ##PerlUnparsedCode
2088    
2089 wakaba 1.35 IFClsETDef:
2090 wakaba 1.25 @IFQName: PerlInlineUnparsedCode
2091 wakaba 1.35 @CQName: ManakaiPCInlineUnparsedCode
2092     @ETQName: pc|inlineUnparsed
2093 wakaba 1.25
2094     @IFISA: PerlCode
2095 wakaba 1.35 @CISA: ManakaiPCCode
2096 wakaba 1.25
2097 wakaba 1.6 @enDesc:
2098 wakaba 1.36 Unparsed Perl inline code fragments.
2099 wakaba 1.6
2100 wakaba 1.36 @ToStringMethod:
2101 wakaba 1.9 @@Return:
2102 wakaba 1.36 @@@Type: DOMString
2103     @@@enDesc:
2104     Perl code.
2105 wakaba 1.35 @@@disDef:
2106     @@@@DISPerl:cloneCode: DOMCore|ManakaiDOMNode.textContent.get
2107 wakaba 1.36 ##PCInlineUnparsedCode
2108 wakaba 1.6
2109 wakaba 1.35 IFClsETDef:
2110 wakaba 1.44 @IFQName: PCNumberLiteral
2111     @CQName: ManakaiPCNumberLiteral
2112     @ETQName: pc|numberLiteral
2113    
2114     @IFISA: PerlCode
2115     @CISA: ManakaiPCCode
2116    
2117     @enDesc:
2118     A <IF::PCNumberLiteral> object represents a Perl number literal.
2119     The <A::Node.textContent> of a <IF::PCNumberLiteral> object
2120     is a Perl source code representation of the number for the object.
2121    
2122     @ToStringMethod:
2123     @@Return:
2124     @@@Type: DOMString
2125     @@@PerlDef:
2126     __DEEP{
2127     $r = $self-><AG::Node.textContent>;
2128     }__;
2129     ##PCNumberLiteral
2130    
2131     IFClsETDef:
2132 wakaba 1.25 @IFQName: PerlStringLiteral
2133 wakaba 1.35 @CQName: ManakaiPCPerlStringLiteral
2134     @ETQName: pc|stringLiteral
2135 wakaba 1.25
2136     @IFISA: PerlCode
2137 wakaba 1.35 @CISA: ManakaiPCCode
2138 wakaba 1.25
2139 wakaba 1.6 @enDesc:
2140 wakaba 1.36 Perl string literal.
2141 wakaba 1.6
2142 wakaba 1.14 @NumValMethod:
2143     @@Return:
2144 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2145 wakaba 1.14 @@@enDesc:
2146     Numeric value of the Perl code.
2147     @@@PerlDef:
2148 wakaba 1.35 __DEEP{
2149     $r = 0 + $self-><AG::Node.textContent>;
2150     }__;
2151 wakaba 1.14
2152 wakaba 1.6 @ToStringMethod:
2153     @@Return:
2154 wakaba 1.35 @@@Type: DOMString
2155 wakaba 1.6 @@@enDesc:
2156     Perl code.
2157     @@@PerlDef:
2158 wakaba 1.35 __DEEP{
2159     $r = $self-><AG::Node.textContent>;
2160     $r =~ s/(['\\])/\\$1/g;
2161     $r = q<'> . $r . q<'>;
2162     }__;
2163 wakaba 1.6 ##PerlStringLiteral
2164    
2165 wakaba 1.35 IFClsETDef:
2166 wakaba 1.41 @IFQName: PCList
2167     @CQName: ManakaiPCList
2168     @ETQName: pc|list
2169    
2170     @IFISA: PerlCode
2171 wakaba 1.42 @CISA: ManakaiPCCode
2172 wakaba 1.41
2173     @enDesc:
2174     A <IF::PCList> is a Perl list, i.e. <CHAR::COMMA> separated
2175     list of values.
2176    
2177     @Method:
2178     @@Name: item
2179     @@enDesc:
2180     Returns the <P::index>th item in the list.
2181     @@Param:
2182     @@@Name: index
2183     @@@Type: unsignedLong
2184     @@@enDesc:
2185     The ordinal index of the item.
2186     @@Return:
2187     @@@Type: PerlCodeInlines
2188     @@@enDesc:
2189     The <P::index>th item in the list.
2190     @@@nullCase:
2191     @@@@enDesc:
2192     Either <P::index> is negative or the <P::index> is
2193     greater than the number of the items in the list.
2194     @@@PerlDef:
2195     __DEEP{
2196     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index);
2197     }__;
2198    
2199     @Attr:
2200     @@Name: length
2201     @@enDesc:
2202     The number of items in the list.
2203     @@Type: unsignedLong
2204     @@Get:
2205     @@@PerlDef:
2206     __DEEP{
2207     $r = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2208     }__;
2209    
2210     @ToStringMethod:
2211     @@Return:
2212     @@@Type: DOMString
2213     @@@enDesc:
2214     Perl code.
2215     @@@PerlDef:
2216     __DEEP{
2217     my @r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2218     $r = '(' . join (', ', @r) . ')';
2219     }__;
2220     ##PCList
2221    
2222     IFClsETDef:
2223     @IFQName: PCArrayRefLiteral
2224     @CQName: ManakaiPCArrayRefLiteral
2225 wakaba 1.44 @ETQName: pc|arrayRefLiteral
2226 wakaba 1.41
2227     @IFISA: PerlCode
2228 wakaba 1.42 @CISA: ManakaiPCCode
2229 wakaba 1.41
2230     @enDesc:
2231     A <IF::PCArrayRefLiteral> is a Perl array reference literal.
2232    
2233     @Method:
2234     @@Name: item
2235     @@enDesc:
2236     Returns the <P::index>th item in the list.
2237     @@Param:
2238     @@@Name: index
2239     @@@Type: unsignedLong
2240     @@@enDesc:
2241     The ordinal index of the item.
2242     @@Return:
2243     @@@Type: PerlCodeInlines
2244     @@@enDesc:
2245     The <P::index>th item in the list.
2246     @@@nullCase:
2247     @@@@enDesc:
2248     Either <P::index> is negative or the <P::index> is
2249     greater than the number of the items in the list.
2250     @@@PerlDef:
2251     __DEEP{
2252     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index);
2253     }__;
2254    
2255     @Attr:
2256     @@Name: length
2257     @@enDesc:
2258     The number of items in the list.
2259     @@Type: unsignedLong
2260     @@Get:
2261     @@@PerlDef:
2262     __DEEP{
2263     $r = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2264     }__;
2265    
2266     @ToStringMethod:
2267     @@Return:
2268     @@@Type: DOMString
2269     @@@enDesc:
2270     Perl code.
2271     @@@PerlDef:
2272     __DEEP{
2273     my @r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2274     $r = '[' . join (', ', @r) . ']';
2275     }__;
2276     ##PCArrayRefLiteral
2277    
2278     IFClsETDef:
2279     @IFQName: PCHashRefLiteral
2280     @CQName: ManakaiPCHashRefLiteral
2281 wakaba 1.44 @ETQName: pc|hashRefLiteral
2282 wakaba 1.41
2283     @IFISA: PerlCode
2284 wakaba 1.42 @CISA: ManakaiPCCode
2285 wakaba 1.41
2286     @enDesc:
2287     A <IF::PCHashRefLiteral> is a Perl hash reference literal.
2288    
2289     @Method:
2290     @@Name: key
2291     @@enDesc:
2292     Returns the <P::index>th key in the list.
2293    
2294     {NOTE:: Although the order of key-value pairs is
2295     preserved in the object, it is not preserved
2296     in Perl source codes and in Perl language.
2297     }
2298     @@Param:
2299     @@@Name: index
2300     @@@Type: unsignedLong
2301     @@@enDesc:
2302     The ordinal index of the key.
2303     @@Return:
2304     @@@Type: PerlCodeInlines
2305     @@@enDesc:
2306     The <P::index>th key in the list.
2307     @@@nullCase:
2308     @@@@enDesc:
2309     Either <P::index> is negative or the <P::index> is
2310     greater than the number of the keys in the list.
2311     @@@PerlDef:
2312     __DEEP{
2313     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index * 2);
2314     }__;
2315    
2316     @Method:
2317     @@Name: value
2318     @@enDesc:
2319     Returns the <P::index>th value in the list.
2320    
2321     {NOTE:: Although the order of key-value pairs is
2322     preserved in the object, it is not preserved
2323     in Perl source codes and in Perl language.
2324     }
2325     @@Param:
2326     @@@Name: index
2327     @@@Type: unsignedLong
2328     @@@enDesc:
2329     The ordinal index of the value.
2330     @@Return:
2331     @@@Type: PerlCodeInlines
2332     @@@enDesc:
2333     The <P::index>th value in the list.
2334     @@@nullCase:
2335     @@@@enDesc:
2336     Either <P::index> is negative or the <P::index> is
2337     greater than the number of the values in the list.
2338    
2339     {NOTE:: <MATH::<A::PCHashRefLiteral.length> - 1>th
2340     value might not be found.
2341     }
2342     @@@PerlDef:
2343     __DEEP{
2344     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index * 2 + 1);
2345     }__;
2346    
2347     @Attr:
2348     @@Name: length
2349     @@enDesc:
2350     The number of key-value pairs in the list.
2351     @@Type: unsignedLong
2352     @@Get:
2353     @@@PerlDef:
2354     __DEEP{
2355     my $length = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2356     $r = int ($length / 2) + ($length % 2);
2357     }__;
2358    
2359     @Method:
2360     @@Name: setNamedItem
2361     @@enDesc:
2362     Set a named item.
2363     @@Param:
2364     @@@Name: key
2365     @@@Type: DOMString
2366     @@@enDesc:
2367     The key.
2368     @@Param:
2369     @@@Name: value
2370     @@@Type: PerlCodeInlines
2371     @@@enDesc:
2372     The value.
2373     @@Return:
2374     @@@PerlDef:
2375     __DEEP{
2376     my @children = @{$self-><AG::Node.childNodes>};
2377     R: {
2378     while (@children) {
2379     my $ckey = shift @children;
2380     my $cval = shift @children;
2381     if ($ckey-><AG::Node.textContent> eq $key) {
2382     $self-><M::Node.replaceChild> ($value, $cval);
2383     last R;
2384     }
2385     }
2386    
2387     $self-><M::Node.appendChild>
2388     ($self-><AG::Node.ownerDocument>
2389     -><M::Document.createElementNS>
2390     (<Q::pc:>, 'stringLiteral'))
2391     -><AS::Node.textContent> ($key);
2392     $self-><M::Node.appendChild> ($value);
2393     } # R
2394     }__;
2395    
2396     @ToStringMethod:
2397     @@Return:
2398     @@@Type: DOMString
2399     @@@enDesc:
2400     Perl code.
2401     @@@PerlDef:
2402     __DEEP{
2403     my %r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2404     ## Different values with same key are not preserved.
2405     $r = '{' . join (', ', map {$_ => $r{$_}}
2406     sort {$a cmp $b} keys %r) . '}';
2407     }__;
2408     ##PCHashRefLiteral
2409    
2410     ResourceDef:
2411     @QName: unsignedLong
2412     @AliasFor: idl|unsignedLong||ManakaiDOM|all
2413     @For: ManakaiDOM|DOM
2414    
2415     IFClsETDef:
2416 wakaba 1.25 @IFQName: PerlTokens
2417 wakaba 1.35 @CQName: ManakaiPCTokens
2418     @ETQName: pc|tokens
2419 wakaba 1.12
2420 wakaba 1.25 @IFISA: PerlCode
2421 wakaba 1.35 @CISA: ManakaiPCCode
2422 wakaba 1.25
2423 wakaba 1.6 @enDesc:
2424 wakaba 1.36 Unparsed Perl inline code fragments.
2425 wakaba 1.6
2426     @ToStringMethod:
2427     @@Return:
2428 wakaba 1.43 @@@Type: DOMString
2429 wakaba 1.6 @@@PerlDef:
2430 wakaba 1.35 __DEEP{
2431     $r = $self-><AG::Node.textContent>;
2432     }__;
2433     ##PCTokens
2434 wakaba 1.6
2435 wakaba 1.35 IFClsETDef:
2436 wakaba 1.25 @IFQName: PerlAtom
2437 wakaba 1.35 @CQName: ManakaiPCAtom
2438     @ETQName: pc|atom
2439 wakaba 1.25
2440     @IFISA: PerlCode
2441 wakaba 1.35 @CISA: ManakaiPCTokens
2442 wakaba 1.25
2443 wakaba 1.6 @enDesc:
2444     Unparsed Perl atomic code fragments (such as numeric literal).
2445    
2446 wakaba 1.14 @NumValMethod:
2447     @@Return:
2448 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2449 wakaba 1.14 @@@enDesc:
2450     Numeric value of the Perl code.
2451     @@@PerlDef:
2452 wakaba 1.35 __DEEP{
2453     $r = 0 + $self-><AG::Node.textContent>;
2454     }__;
2455 wakaba 1.9
2456 wakaba 1.6 @ToStringMethod:
2457     @@Return:
2458 wakaba 1.35 @@@Type: DOMString
2459 wakaba 1.6 @@@enDesc:
2460     Perl code.
2461     @@@PerlDef:
2462 wakaba 1.35 __DEEP{
2463     $r = $self-><AG::Node.textContent>;
2464     }__;
2465 wakaba 1.6 ##PerlAtom
2466    
2467 wakaba 1.35 IFClsETDef:
2468 wakaba 1.25 @IFQName: PerlVariable
2469 wakaba 1.35 @CQName: ManakaiPCVariable
2470     @ETQName: pc|variable
2471 wakaba 1.25
2472     @IFISA: PerlCode
2473 wakaba 1.35 @CISA: ManakaiPCCode
2474 wakaba 1.25
2475 wakaba 1.6 @enDesc:
2476     Unparsed Perl variable.
2477     \
2478     {NOTE:: Future version of the implementation may
2479     support to specify array index or hash key.
2480     \
2481 wakaba 1.36 }
2482 wakaba 1.6
2483 wakaba 1.35 @ATTR:
2484 wakaba 1.6 @@Name: variableType
2485 wakaba 1.35 @@ATTRQName: pc|variableType
2486 wakaba 1.6 @@enDesc:
2487     Perl variable type (<CODE::$>, <CODE::@>, <CODE::%>,
2488     <CODE::&> or empty string).
2489 wakaba 1.35 @@ReflectCDATA:
2490 wakaba 1.6 @@Get:
2491     @@Set:
2492    
2493 wakaba 1.35 @ATTR:
2494 wakaba 1.6 @@Name: packageName
2495 wakaba 1.35 @@ATTRQName: pc|packageName
2496 wakaba 1.6 @@enDesc:
2497     The name of the package to which this variable belongs.
2498 wakaba 1.35 @@ReflectCDATA:
2499 wakaba 1.6 @@Get:
2500     @@@nullCase:
2501     @@@@enDesc:
2502     This package belongs to the current package or
2503     does not belong to any package.
2504     @@Set:
2505     @@@nullCase:
2506     @@@@enDesc:
2507     This package belongs to the current package or
2508     does not belong to any package.
2509    
2510 wakaba 1.35 @ATTR:
2511 wakaba 1.36 @@Name: pcLocalName
2512 wakaba 1.35 @@ATTRQName: pc|localName
2513 wakaba 1.6 @@enDesc:
2514     The local variable name.
2515 wakaba 1.35 @@ReflectCDATA:
2516 wakaba 1.6 @@Get:
2517     @@Set:
2518    
2519 wakaba 1.35 @ATTR:
2520 wakaba 1.6 @@Name: variableScope
2521 wakaba 1.35 @@ATTRQName: pc|variableScope
2522 wakaba 1.6 @@enDesc:
2523     Scope modifier (<CODE::my> or <CODE::our> or <CODE::local>).
2524 wakaba 1.35 @@ReflectCDATA:
2525 wakaba 1.6 @@Get:
2526     @@@nullCase:
2527     @@@@enDesc:
2528     This variable does not have scope modifier.
2529     @@Set:
2530     @@@nullCase:
2531     @@@@enDesc:
2532     This variable does not have scope modifier.
2533    
2534     @ToStringMethod:
2535     @@Return:
2536 wakaba 1.35 @@@Type: DOMString
2537 wakaba 1.6 @@@enDesc:
2538     Perl code.
2539     @@@PerlDef:
2540 wakaba 1.35 __DEEP{
2541     my $t = $self-><AG::PerlVariable.variableScope>;
2542     $r .= $t . ' ' if length $t;
2543     $r .= $self-><AG::PerlVariable.variableType>;
2544     my $v = $self-><AG::PerlVariable.packageName>;
2545     $r .= $v . '::' if length $v;
2546     $r .= $self-><AG::PerlVariable.pcLocalName>;
2547     $v = $self-><AG::PerlVariable.hashKey>;
2548     if ($t eq '$' and length $v) {
2549     $v =~ s/(['\\])/\\$1/g;
2550     $r .= q<{'> . $v . q<'}>;
2551     }
2552     }__;
2553 wakaba 1.6
2554 wakaba 1.35 @ATTR:
2555 wakaba 1.6 @@Name: hashKey
2556 wakaba 1.35 @@ATTRQName: pc|hashKey
2557 wakaba 1.6 @@enDesc:
2558     The key for hash.
2559     \
2560     {NOTE:: Using Perl code for key is not supported in the current
2561     version of the implementation.
2562     \
2563     }
2564 wakaba 1.35 @@ReflectCDATA:
2565 wakaba 1.6 @@Get:
2566     @@@nullCase:
2567     @@@@enDesc:
2568     This variable is not for hash value access.
2569     @@Set:
2570     @@@nullCase:
2571     @@@@enDesc:
2572     This variable is not for hash value access.
2573 wakaba 1.15 ##PerlVariable
2574 wakaba 1.6
2575 wakaba 1.25 IFClsDef:
2576     @IFQName: PerlCodeUnits
2577 wakaba 1.35 @CQName: ManakaiPCCodeUnits
2578 wakaba 1.25
2579 wakaba 1.35 @CISA: ManakaiPCCode
2580 wakaba 1.25
2581 wakaba 1.6 @enDesc:
2582     A base class implemented by both inline container and
2583     block-level container.
2584    
2585     @Attr:
2586     @@Name: length
2587     @@enDesc:
2588     The number of child code fragments.
2589 wakaba 1.35 @@Type: idl|unsignedLong||ManakaiDOM|all
2590 wakaba 1.6 @@Get:
2591     @@@PerlDef:
2592 wakaba 1.35 __DEEP{
2593     $r = @{$self-><AG::Node.childNodes>};
2594     }__;
2595 wakaba 1.6
2596     @Method:
2597     @@Name: appendStringLiteral
2598     @@enDesc:
2599     Appends a Perl string literal (<CODE::q>).
2600     @@Param:
2601     @@@Name: stringArg
2602 wakaba 1.35 @@@Type: DOMString
2603 wakaba 1.6 @@@enDesc:
2604     A string.
2605     @@Return:
2606 wakaba 1.35 @@@Type: PerlStringLiteral
2607 wakaba 1.6 @@@enDesc:
2608     The newly created Perl string literal object.
2609     @@@PerlDef:
2610 wakaba 1.35 __DEEP{
2611     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2612     (<Q::pc:>, 'stringLiteral');
2613     $r-><AS::Node.textContent> ($stringArg);
2614     $self-><M::Node.appendChild> ($r);
2615     }__;
2616 wakaba 1.6
2617     @Method:
2618 wakaba 1.41 @@Name: appendNewPCLiteral
2619     @@enDesc:
2620     Creates a <IF::PCLiteral> object and appends it to the node.
2621     @@Param:
2622     @@@Name: value
2623     @@@Type: DISPerl|Any
2624     @@@enDesc: The value.
2625     @@Return:
2626     @@@Type: PerlCode
2627     @@@enDesc:
2628     The newly created object.
2629     @@@PerlDef:
2630     __DEEP{
2631     $r = $self-><AG::Node.ownerDocument>
2632     -><M::PCDocument.createPCLiteral> ($value);
2633     $self-><M::Node.appendChild> ($r);
2634     }__;
2635    
2636     @Method:
2637 wakaba 1.44 @@Name: appendNewPCNumberLiteral
2638     @@enDesc:
2639     Creates a <IF::PCNumberLiteral> object and appends it to the node.
2640     @@Param:
2641     @@@Name: value
2642     @@@Type: DISPerl|NumberValue
2643     @@@enDesc:
2644     The value.
2645     @@Return:
2646     @@@Type: PCNumberLiteral
2647     @@@enDesc:
2648     The newly created node.
2649     @@@PerlDef:
2650     __DEEP{
2651     $r = $self-><AG::Node.ownerDocument>
2652     -><M::PCDocument.createPCNumberLiteral> ($value);
2653     $self-><M::Node.appendChild> ($r);
2654     }__;
2655    
2656     @Method:
2657 wakaba 1.6 @@Name: appendAtom
2658     @@enDesc:
2659     Appends a Perl atomic code fragment.
2660     @@Param:
2661     @@@Name: codeArg
2662 wakaba 1.35 @@@Type: DOMString
2663 wakaba 1.6 @@@enDesc:
2664     An atom.
2665     @@Return:
2666 wakaba 1.35 @@@Type: PerlAtom
2667 wakaba 1.6 @@@enDesc:
2668     The newly created Perl code object.
2669     @@@PerlDef:
2670 wakaba 1.35 __DEEP{
2671     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2672     (<Q::pc:>, 'atom');
2673     $r-><AS::Node.textContent> ($codeArg);
2674     $self-><M::Node.appendChild> ($r);
2675     }__;
2676 wakaba 1.6
2677     @Method:
2678     @@Name: appendBare
2679     @@enDesc:
2680     Appends a Perl bare code fragment.
2681     @@Param:
2682     @@@Name: codeArg
2683 wakaba 1.35 @@@Type: DOMString
2684 wakaba 1.6 @@@enDesc:
2685 wakaba 1.7 An bare code.
2686 wakaba 1.6 @@Return:
2687 wakaba 1.35 @@@Type: PerlBare
2688 wakaba 1.6 @@@enDesc:
2689     The newly created Perl code object.
2690     @@@PerlDef:
2691 wakaba 1.35 __DEEP{
2692     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2693     (<Q::pc:>, 'tokens');
2694     $r-><AS::Node.textContent> ($codeArg);
2695     $self-><M::Node.appendChild> ($r);
2696     }__;
2697 wakaba 1.11
2698     @Method:
2699 wakaba 1.44 @@Name: appendNewPCVariable
2700     @@enDesc:
2701     Creates a variable object and appends it to the children list of
2702     the node.
2703     @@Param:
2704     @@@Name: variableTypeArg
2705     @@@Type: DOMString
2706     @@@enDesc:
2707     The variable type prefix such as <Perl::$>, if any, or an empty string.
2708     @@Param:
2709     @@@Name: packageNameArg
2710     @@@Type: DOMString
2711     @@@enDesc:
2712     The name of the package to which the variable belongs.
2713     @@@nullCase:
2714     @@@@enDesc:
2715     The variable does not belong to any package or belongs
2716     to the current package.
2717     @@Param:
2718     @@@Name: localNameArg
2719     @@@Type: DOMString
2720     @@@enDesc:
2721     The local part of the variable name.
2722     @@Return:
2723     @@@Type: PerlVariable
2724     @@@enDesc:
2725     The newly created variable object.
2726     @@@PerlDef:
2727     __DEEP{
2728     $r = $self-><AG::Node.ownerDocument>
2729     -><M::PCDocument.createPCVariable>
2730     ($variableTypeArg, $packageNameArg, $localNameArg);
2731     $self-><M::Node.appendChild> ($r);
2732     }__;
2733    
2734     @Method:
2735     @@Name: appendNewPCDereference
2736     @@enDesc:
2737     Creates a <IF::PCDereference> object and appends it to the child
2738     node list of the node.
2739     @@Param:
2740     @@@Name: variableTypeArg
2741     @@@Type: DOMString
2742     @@@enDesc:
2743     The type of the referenced value, such as <Perl::$>.
2744     @@Return:
2745     @@@Type: PCDereference
2746     @@@enDesc:
2747     The newly created element node.
2748     @@@PerlDef:
2749     __DEEP{
2750     $r = $self-><AG::Node.ownerDocument>
2751 wakaba 1.48 -><M::PCDocument.createPCDereference>
2752     ($variableTypeArg);
2753     $self-><M::Node.appendChild> ($r);
2754     }__;
2755    
2756     @Method:
2757     @@Name: appendNewPCReference
2758     @@enDesc:
2759     Creates a <IF::PCReference> object and appends it to the child
2760     node list of the node.
2761     @@Return:
2762     @@@Type: PCReference
2763     @@@enDesc:
2764     The newly created element node.
2765     @@@PerlDef:
2766     __DEEP{
2767     $r = $self-><AG::Node.ownerDocument>
2768     -><M::PCDocument.createPCReference>;
2769 wakaba 1.44 $self-><M::Node.appendChild> ($r);
2770     }__;
2771    
2772     @Method:
2773 wakaba 1.43 @@Name: appendNewPCExpression
2774     @@enDesc:
2775     Appends a newly created <IF::PCExpression> node.
2776     @@Param:
2777     @@@Name: operatorArg
2778     @@@Type: DOMString
2779     @@@enDesc:
2780     The operator of the expression.
2781     @@Return:
2782     @@@Type: PCExpression
2783     @@@enDesc:
2784     The newly created expression object.
2785     @@@PerlDef:
2786     __DEEP{
2787     $r = $self-><AG::Node.ownerDocument>
2788     -><M::PCDocument.createPCExpression> ($operatorArg);
2789     $self-><M::Node.appendChild> ($r);
2790     }__;
2791    
2792     @Method:
2793 wakaba 1.11 @@Name: appendNewAssignment
2794     @@enDesc:
2795     Appends a newly created <Class::ManakaiPerlAssign> object.
2796     @@Param:
2797     @@@Name: leftArg
2798 wakaba 1.35 @@@Type: PerlCode
2799 wakaba 1.11 @@@enDesc:
2800     A left hand side code fragment object.
2801     @@Param:
2802     @@@Name: rightArg
2803 wakaba 1.35 @@@Type: PerlCode
2804 wakaba 1.11 @@@enDesc:
2805     A right hand side code fragment object.
2806     @@Return:
2807 wakaba 1.36 @@@Type: PerlAssignment
2808 wakaba 1.11 @@@RaiseException:
2809     @@@@@:BAD_CHILD_ERR
2810     @@@@enDesc:
2811     An attempt is made to append a child
2812     that is not valid type.
2813     @@@RaiseException:
2814     @@@@@:IN_USE_NODE_ERR
2815     @@@@enDesc:
2816     An attempt is made to append a node that is
2817     already used elsewhere.
2818     @@@PerlDef:
2819 wakaba 1.35 for my $arg ([leftArg => $leftArg], [rightArg => $rightArg]) {
2820     if ({
2821     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
2822     inlineUnparsed => 1, variable => 1, stringLiteral => true,
2823 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
2824 wakaba 1.35 }->{$arg->[1]-><AG::Node.localName>}) {
2825     if ($arg->[1]-><AG::Node.parentNode>) {
2826     __EXCEPTION{IN_USE_NODE_ERR::
2827     pc:childNode => {$arg->[1]},
2828     MDOMX:param-name => {$arg->[0]},
2829     }__;
2830     }
2831     } else {
2832     __EXCEPTION{BAD_CHILD_ERR::
2833     pc:parentNode => {$self},
2834     pc:childNode => {$arg->[1]},
2835     MDOMX:param-name => {$arg->[0]},
2836     }__;
2837     }
2838     } # left/right
2839    
2840     __DEEP{
2841     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2842     (<Q::pc:>, 'assignment');
2843     $r-><AS::PerlAssignment.leftCode> ($leftArg);
2844     $r-><AS::PerlAssignment.rightCode> ($rightArg);
2845     $self-><M::Node.appendChild> ($r);
2846     }__;
2847 wakaba 1.43
2848     @Method:
2849 wakaba 1.44 @@Name: appendNewPCApply
2850     @@enDesc:
2851     Creates a <IF::PCApply> object and appends it to the children list
2852     of the node.
2853     @@Return:
2854     @@@Type: PCApply
2855     @@@enDesc: The newly created node.
2856     @@@PerlDef:
2857     __DEEP{
2858     $r = $self-><AG::Node.ownerDocument>-><M::PCDocument.createPCApply>;
2859     $self-><M::Node.appendChild> ($r);
2860     }__;
2861    
2862     @Method:
2863 wakaba 1.43 @@Name: appendNewPCFunctionCall
2864     @@enDesc:
2865     Appends a newly created <IF::PCFunctionCall> node.
2866     @@Param:
2867     @@@Name: packageArg
2868     @@@Type: DOMString
2869     @@@enDesc:
2870     The package name of the function.
2871     @@@nullCase:
2872     @@@@enDesc: No package name.
2873     @@Param:
2874     @@@Name: localNameArg
2875     @@@Type: DOMString
2876     @@@enDesc:
2877     The local part of the function name.
2878     @@Return:
2879     @@@Type: PCFunctionCall
2880     @@@enDesc:
2881     The newly created functin call object.
2882     @@@PerlDef:
2883     __DEEP{
2884     $r = $self-><AG::Node.ownerDocument>
2885     -><M::PCDocument.createPCFunctionCall>
2886     ($packageArg, $localNameArg);
2887     $self-><M::Node.appendChild> ($r);
2888     }__;
2889     ##PCCodeUnits
2890 wakaba 1.6
2891 wakaba 1.35 IFClsETDef:
2892 wakaba 1.25 @IFQName: PerlStatement
2893 wakaba 1.35 @CQName: ManakaiPCStatement
2894     @ETQName: pc|statement
2895 wakaba 1.25
2896     @IFISA: PerlCode
2897     @IFISA: PerlCodeInlines
2898 wakaba 1.35 @CISA: ManakaiPCCodeInlines
2899 wakaba 1.25
2900 wakaba 1.8 @enDesc:
2901 wakaba 1.36 Perl statements.
2902 wakaba 1.8
2903     @ToStringMethod:
2904     @@Return:
2905 wakaba 1.35 @@@Type: DOMString
2906 wakaba 1.8 @@@enDesc:
2907     Perl code.
2908     @@@PerlDef:
2909     $r = $self->SUPER::stringify;
2910 wakaba 1.16 $r .= ";\n" if length $r;
2911 wakaba 1.8 ##PerlStatement
2912 wakaba 1.6
2913 wakaba 1.35 IFClsETDef:
2914 wakaba 1.25 @IFQName: PerlCodeInlines
2915 wakaba 1.35 @CQName: ManakaiPCCodeInlines
2916     @ETQName: pc|inlineContainer
2917 wakaba 1.25
2918 wakaba 1.35 @CISA: ManakaiPCCodeUnits
2919 wakaba 1.25
2920 wakaba 1.6 @enDesc:
2921 wakaba 1.41 Perl inline code block.
2922 wakaba 1.6
2923     @Method:
2924     @@Name: appendCodeFragment
2925     @@enDesc:
2926 wakaba 1.35 Appends a <IF::PerlCode> object.
2927 wakaba 1.6 @@Param:
2928     @@@Name: codeArg
2929 wakaba 1.25 @@@Type: PerlCode
2930 wakaba 1.6 @@@enDesc:
2931     A code fragment object.
2932     @@Return:
2933     @@@RaiseException:
2934     @@@@@:BAD_CHILD_ERR
2935     @@@@enDesc:
2936     An attempt is made to append a child
2937     that is not a <Class::ManakaiPerlUnparsedCode>.
2938     @@@RaiseException:
2939     @@@@@:IN_USE_NODE_ERR
2940     @@@@enDesc:
2941     An attempt is made to append a node that is
2942     already used elsewhere.
2943     @@@PerlDef:
2944 wakaba 1.35 if ({
2945     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
2946     inlineUnparsed => 1, variable => 1, stringLiteral => true,
2947 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
2948 wakaba 1.35 }->{$codeArg-><AG::Node.localName>}) {
2949     if ($codeArg-><AG::Node.parentNode>) {
2950     __EXCEPTION{IN_USE_NODE_ERR::
2951     pc:childNode => {$codeArg},
2952     }__;
2953     }
2954     __DEEP{
2955     $self-><AG::Node.ownerDocument>
2956     -><M::Document.adoptNode> ($codeArg);
2957     $self-><M::Node.appendChild> ($codeArg);
2958     }__;
2959     } else {
2960     __EXCEPTION{BAD_CHILD_ERR::
2961     pc:parentNode => {$self},
2962     pc:childNode => {$codeArg},
2963     }__;
2964     }
2965 wakaba 1.6
2966     @Method:
2967     @@Name: appendCode
2968     @@enDesc:
2969     Appends an unparsed Perl code fragment.
2970     @@Param:
2971     @@@Name: codeArg
2972 wakaba 1.35 @@@Type: DOMString
2973 wakaba 1.6 @@@enDesc:
2974     An unparsed Perl code fragment.
2975     @@Return:
2976 wakaba 1.25 @@@Type: PerlInlineUnparsedCode
2977 wakaba 1.6 @@@enDesc:
2978     The newly created Perl code object.
2979     @@@PerlDef:
2980 wakaba 1.35 __DEEP{
2981     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2982     (<Q::pc:>, 'inlineUnparsed');
2983     $r-><AS::Node.textContent> ($codeArg);
2984     $self-><M::Node.appendChild> ($r);
2985     }__;
2986 wakaba 1.6
2987     @ToStringMethod:
2988     @@Return:
2989 wakaba 1.35 @@@Type: DOMString
2990 wakaba 1.6 @@@enDesc:
2991     Perl code.
2992     @@@PerlDef:
2993 wakaba 1.35 __DEEP{
2994     my @child = @{$self-><AG::Node.childNodes>};
2995     for my $child (@child) {
2996     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
2997     $child-><AG::Node.localName> eq 'inlineContainer' and
2998     1 == @child) {
2999     $r .= '(' . $child->stringify . ')';
3000     } else {
3001     $r .= $child->stringify;
3002     }
3003     }
3004     }__;
3005     ##PCCodeInlines
3006 wakaba 1.6
3007 wakaba 1.35 IFClsETDef:
3008 wakaba 1.25 @IFQName: PerlBlock
3009 wakaba 1.44 @CQName: ManakaiPerlBlock
3010 wakaba 1.35 @ETQName: pc|block
3011 wakaba 1.25
3012     @IFISA: PerlCode
3013     @IFISA: PerlCodeStatements
3014 wakaba 1.35 @CISA: ManakaiPCCodeStatements
3015 wakaba 1.25
3016 wakaba 1.8 @enDesc:
3017 wakaba 1.36 Perl block-level code block.
3018 wakaba 1.8
3019     @ToStringMethod:
3020     @@Return:
3021 wakaba 1.35 @@@Type: DOMString
3022 wakaba 1.8 @@@enDesc:
3023     Perl code.
3024     @@@PerlDef:
3025 wakaba 1.43 __DEEP{
3026 wakaba 1.35 my @child = @{$self-><AG::Node.childNodes>};
3027 wakaba 1.43 my $label = $self-><AG::PerlCodeStatements.label>;
3028     if (not $label and @child == 1 and
3029 wakaba 1.35 $child[0]-><AG::Node.localName> eq 'block') {
3030 wakaba 1.39 $r = "\x0A" . $child[0]->stringify . "\x0A";
3031 wakaba 1.43 } elsif (not $label and @child == 1 and
3032 wakaba 1.35 $child[0]-><AG::Node.localName> eq 'unparsed' and
3033     $child[0]-><AG::Node.textContent> =~ /^\s*$/) {
3034     #
3035     } else {
3036 wakaba 1.39 $r = "\x0A";
3037 wakaba 1.35 for my $child (@child) {
3038     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3039     1 == @child) {
3040     $r .= '(' . $child->stringify . ')';
3041     } else {
3042     $r .= $child->stringify;
3043     }
3044     }
3045 wakaba 1.39 $r .= "\x0A";
3046 wakaba 1.35
3047 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
3048     -><AG::Document.domConfig>
3049     -><M::DOMCore:DOMConfiguration.getParameter>
3050     (<Q::pc:line>)) {
3051     my $file = $self-><AG::PerlCode.fileNode>;
3052     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3053     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3054     $r = sprintf qq<\n{\n#line %d "%s [b] (Chunk #%d)"%s>.
3055     qq<#line 1 "%s [/b] (Chunk #%d)"\n;}\n>,
3056 wakaba 1.35 $self-><AG::PerlCodeStatements.sourceLine> || 1,
3057     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3058     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3059     $r,
3060     $sfile,
3061     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0
3062 wakaba 1.39 if 2 < length $r;
3063 wakaba 1.41 } else {
3064     $r = "\n{\n$r\n;}\n" if 2 < length $r;
3065 wakaba 1.39 }
3066 wakaba 1.43
3067     $r = "\n" . $label . ':' . $r if $label;
3068     }
3069     }__;
3070 wakaba 1.44 ##PerlBlock
3071 wakaba 1.8
3072 wakaba 1.35 IFClsETDef:
3073 wakaba 1.25 @IFQName: PerlCodeBlocks
3074 wakaba 1.35 @CQName: ManakaiPCCodeBlocks
3075     @ETQName: pc|blockContainer
3076 wakaba 1.25
3077     @IFISA: PerlCodeStatements
3078 wakaba 1.35 @CISA: ManakaiPCCodeStatements
3079 wakaba 1.25
3080 wakaba 1.9 @enDesc:
3081     Perl block-level code container whose content may or may
3082     not semantically be self-contained.
3083    
3084     @ToStringMethod:
3085     @@Return:
3086 wakaba 1.35 @@@Type: DOMString
3087 wakaba 1.9 @@@enDesc:
3088     Perl code.
3089     @@@PerlDef:
3090 wakaba 1.35 my @child = @{$self-><AG::Node.childNodes>};
3091     if (@child == 1 and
3092     {
3093     block => true, blockContainer => true,
3094     }->{$child[0]-><AG::Node.localName>}) {
3095     $r = $child[0]->stringify;
3096     } else {
3097     for my $child (@child) {
3098     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3099     1 == @child) {
3100     $r .= '(' . $child->stringify . ')';
3101     } else {
3102     $r .= $child->stringify;
3103     }
3104     }
3105 wakaba 1.9
3106 wakaba 1.35 __DEEP{
3107 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
3108     -><AG::Document.domConfig>
3109     -><M::DOMCore:DOMConfiguration.getParameter>
3110     (<Q::pc:line>)) {
3111     my $file = $self-><AG::PerlCode.fileNode>;
3112     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3113     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3114     $r = sprintf qq<\n#line %d "%s [bc] (Chunk #%d)"\n%s>.
3115     qq<\n#line 1 "%s [/bc] (Chunk #%d)"\n>,
3116 wakaba 1.35 $self-><AG::PerlCodeStatements.sourceLine> || 1,
3117     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3118     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3119     $r,
3120     $sfile,
3121     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
3122 wakaba 1.39 }
3123 wakaba 1.35 }__;
3124     }
3125     ##PCCodeBlocks
3126    
3127     IFClsETDef:
3128 wakaba 1.44 @IFQName: PCDereference
3129     @CQName: ManakaiPCDereference
3130     @ETQName: pc|dereference
3131    
3132     @IFISA: PerlCode
3133     @IFISA: PerlCodeInlines
3134     @CISA: ManakaiPCCodeInlines
3135    
3136     @enDesc:
3137     A <IF::PCDereference> object represents a dereference.
3138    
3139     @ATTR:
3140     @@Name: variableType
3141     @@ATTRQName: pc|variableType
3142     @@enDesc:
3143     The type of the value, such as <Perl::$>.
3144     @@ReflectCDATA:
3145     @@Get:
3146     @@Set:
3147    
3148     @ToStringMethod:
3149     @@Return:
3150     @@@Type: DOMString
3151     @@@PerlDef:
3152     __DEEP{
3153     $r = $self-><AG::PCDereference.variableType> . '{';
3154     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3155     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3156     $r .= $child;
3157     }
3158     $r .= '}';
3159     }__;
3160     ##PCDereference
3161    
3162     IFClsETDef:
3163 wakaba 1.48 @IFQName: PCReference
3164     @CQName: ManakaiPCReference
3165     @ETQName: pc|reference
3166    
3167     @IFISA: PerlCode
3168     @IFISA: PerlCodeInlines
3169     @CISA: ManakaiPCCodeInlines
3170    
3171     @enDesc:
3172     A <IF::PCReference> object represents a reference (<Perl::\>) operation.
3173    
3174     @ToStringMethod:
3175     @@Return:
3176     @@@Type: DOMString
3177     @@@PerlDef:
3178     __DEEP{
3179     $r = '\(undef)';
3180     no warnings 'uninitialized';
3181     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3182     next A unless $child-><AG::Node.nodeType> ==
3183     <C::Node.ELEMENT_NODE>;
3184     $r = $child;
3185     unless ({
3186     <Q::pc:variable> => true,
3187     }->{$child-><AG::Node.namespaceURI>.
3188     $child-><AG::Node.localName>}) {
3189     $r = '('.$r.')';
3190     }
3191     last A;
3192     }
3193     }__;
3194     ##PCReference
3195    
3196     IFClsETDef:
3197 wakaba 1.44 @IFQName: PCApply
3198     @CQName: ManakaiPCApply
3199     @ETQName: pc|apply
3200    
3201     @IFISA: PerlCode
3202     @IFISA: PerlCodeInlines
3203     @CISA: ManakaiPCCodeInlines
3204    
3205     @enDesc:
3206     A <IF::PCApply> object represents a function call.
3207    
3208     The first child element must be an expression results in a function name
3209     (such as bare function or operator name represented
3210     as a <IF::PCVariable> object or an <IF::PCExpression> with
3211     operator <Perl::-<gt>> whose last operand is a method name.
3212    
3213     The second child element, if any, is an expression intended to be
3214     an argument for the function. It is possible to specify more than
3215     one arguments by <IF::PCExpression> with operator <Perl::,>.
3216    
3217     The third child element, if any, is an expression that is put
3218     into the indirect object slot.
3219    
3220     @Attr:
3221     @@Name: function
3222     @@enDesc:
3223     The function child element of the element.
3224     @@Type: PerlCode
3225     @@Get:
3226     @@@nullCase:
3227     @@@@enDesc: There is no child element.
3228     @@@PerlDef:
3229     __DEEP{
3230     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3231     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3232     $r = $child;
3233     last A;
3234     }
3235     }__;
3236    
3237     @Attr:
3238     @@Name: argument
3239     @@enDesc:
3240     The argument child element of the element.
3241     @@Type: PerlCode
3242     @@Get:
3243     @@@nullCase:
3244     @@@@enDesc: There is no argument element.
3245     @@@PerlDef:
3246     __DEEP{
3247     my $x;
3248     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3249     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3250     if ($x) {
3251     $r = $child;
3252     last A;
3253     } else {
3254     $x = true;
3255     }
3256     }
3257     }__;
3258    
3259     @Attr:
3260     @@Name: indirect
3261     @@enDesc:
3262     The indirect object slot child element of the element.
3263     @@Type: PerlCode
3264     @@Get:
3265     @@@nullCase:
3266     @@@@enDesc: There is no indirect object element.
3267     @@@PerlDef:
3268     __DEEP{
3269     my $x = 0;
3270     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3271     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3272     if ($x++ == 2) {
3273     $r = $child;
3274     last A;
3275     }
3276     }
3277     }__;
3278    
3279    
3280     @ToStringMethod:
3281     @@Return:
3282     @@@Type: DOMString
3283     @@@PerlDef:
3284     __DEEP{
3285     my $f;
3286     my $arg;
3287     my $obj;
3288     no warnings 'uninitialized';
3289     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3290     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3291     if (not defined $f) {
3292     $f = ''.$child;
3293     } elsif (not defined $arg) {
3294     $arg = ''.$child;
3295     } else {
3296     $obj = ''.$child;
3297     last A;
3298     }
3299     }
3300    
3301     $r = $f;
3302     $r .= ' ' . $obj if defined $obj;
3303    
3304     if ({
3305     'die' => true,
3306     'last' => true,
3307     'next' => true,
3308     'redo' => true,
3309     'return' => true,
3310     'warn' => true,
3311     }->{$r}) {
3312     $r .= ' ' . $arg;
3313     } else {
3314     $r .= ' (' . $arg . ')';
3315     }
3316     }__;
3317     ##PCApply
3318    
3319     IFClsETDef:
3320 wakaba 1.43 @IFQName: PCExpression
3321     @CQName: ManakaiPCExpression
3322     @ETQName: pc|expression
3323    
3324     @IFISA: PerlCode
3325     @IFISA: PerlCodeInlines
3326     @CISA: ManakaiPCCodeInlines
3327    
3328     @enDesc:
3329     A <IF::PCExpression> object represents a sequence of one or more
3330     expression fragments (operands) separated by the same operator.
3331    
3332     @ATTR:
3333     @@Name: operator
3334     @@ATTRQName: pc|operator
3335     @@enDesc:
3336     The operator.
3337     @@ReflectCDATA:
3338     @@Get:
3339     @@Set:
3340    
3341     @Attr:
3342     @@Name: operandNumber
3343     @@enDesc:
3344     The number of operands.
3345     @@Type: idl|unsignedLong||ManakaiDOM|all
3346     @@Get:
3347     @@@PerlDef:
3348     __DEEP{
3349     $r = @{$self-><AG::Node.childNodes>};
3350     }__;
3351    
3352     @ToStringMethod:
3353     @@Return:
3354     @@@Type: DOMString
3355     @@@PerlDef:
3356     __DEEP{
3357     my @r;
3358     no warnings 'uninitialized';
3359     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3360     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3361 wakaba 1.44 my $xuri = $child-><AG::Node.namespaceURI>
3362     . $child-><AG::Node.localName>;
3363     push @r, [$child.'', $child, $xuri];
3364 wakaba 1.43 }
3365     if (@r > 1) {
3366     my $op = $self-><AG::PCExpression.operator>;
3367     for (@r) {
3368 wakaba 1.44 if ($_->[2] ne <Q::pc:expression> and not {
3369 wakaba 1.45 <Q::pc:apply> => true,
3370 wakaba 1.44 <Q::pc:arrayRefLiteral> => true,
3371     <Q::pc:atom> => true,
3372     <Q::pc:dereference> => true,
3373     <Q::pc:hashRefLiteral> => true,
3374     <Q::pc:numberLiteral> => true,
3375     <Q::pc:stringLiteral> => true,
3376     <Q::pc:tokens> => true,
3377     <Q::pc:variable> => true,
3378     }->{$_->[2]}) {
3379     $_ = '(' . $_->[0] . ')';
3380     } elsif ($_->[2] eq <Q::pc:expression> and
3381     (not {
3382 wakaba 1.46 '**' => {'->' => true},
3383     '=~' => {'->' => true},
3384     '!~' => {'->' => true},
3385     '*' => {'->' => true, '*' => true},
3386     '/' => {'->' => true},
3387     '%' => {'->' => true},
3388     'x' => {'->' => true},
3389     '+' => {'->' => true, '*' => true, '+' => true, '-' => true},
3390     '-' => {'->' => true, '*' => true},
3391     '.' => {'->' => true},
3392     '<' => {'->' => true},
3393     '>' => {'->' => true},
3394     '<=' => {'->' => true},
3395     '>=' => {'->' => true},
3396     'lt' => {'->' => true},
3397     'gt' => {'->' => true},
3398     'le' => {'->' => true},
3399     'gr' => {'->' => true},
3400     '==' => {'->' => true},
3401     '!=' => {'->' => true},
3402     '<=>' => {'->' => true},
3403     'eq' => {'->' => true},
3404     'ne' => {'->' => true},
3405     'cmp' => {'->' => true},
3406     '&&' => {'->' => true, '&&' => true},
3407     '||' => {'->' => true, '||' => true},
3408     '..' => {'->' => true},
3409     '=' => {'->' => true},
3410     ',' => {'->' => true, ',' => true, '=>' => true},
3411     '=>' => {'->' => true, ',' => true, '=>' => true},
3412     'and' => {'->' => true, 'and' => true},
3413     'or' => {'->' => true, 'or' => true},
3414 wakaba 1.43 }->{$op}->{$_->[1]-><AG::PCExpression.operator>}) and
3415     $_->[1]-><AG::PCExpression.operandNumber> > 1) {
3416     $_ = '(' . $_->[0] . ')';
3417     } else {
3418     $_ = $_->[0];
3419     }
3420     }
3421 wakaba 1.44 $op = ' '.$op unless {
3422     ',' => true,
3423     '->' => true,
3424 wakaba 1.46 '..' => true,
3425     '...' => true,
3426 wakaba 1.44 }->{$op};
3427     $op = $op.' ' unless {
3428     '->' => true,
3429 wakaba 1.46 '..' => true,
3430     '...' => true,
3431 wakaba 1.44 }->{$op};
3432     $r = join $op, @r;
3433 wakaba 1.43 } elsif (@r) {
3434     $r = $r[0]->[0];
3435 wakaba 1.48 } elsif ($self-><AG::PCExpression.operator> eq ',') {
3436     $r = '()';
3437 wakaba 1.43 } else {
3438     $r = 'undef';
3439     }
3440     }__;
3441     ##PCExpression
3442    
3443     IFClsETDef:
3444 wakaba 1.25 @IFQName: PerlAssignment
3445 wakaba 1.35 @CQName: ManakaiPCAssignment
3446     @ETQName: pc|assignment
3447 wakaba 1.25
3448     @IFISA: PerlCode
3449 wakaba 1.35 @CISA: ManakaiPCCode
3450 wakaba 1.25
3451 wakaba 1.11 @enDesc:
3452 wakaba 1.36 Perl variable assignment.
3453 wakaba 1.11
3454     @ToStringMethod:
3455     @@Return:
3456 wakaba 1.35 @@@Type: DOMString
3457 wakaba 1.11 @@@enDesc:
3458     Perl code.
3459     @@@PerlDef:
3460 wakaba 1.35 __DEEP{
3461     $r = $self-><AG::PerlAssignment.leftCode>->stringify
3462     . ' = '
3463     . $self-><AG::PerlAssignment.rightCode>->stringify;
3464     }__;
3465    
3466     @Attr:
3467     @@Name: leftCode
3468     @@enDesc:
3469     Left-hand expression.
3470     @@Type: PerlCodeInlines
3471     @@Get:
3472     @@@nullCase:
3473     @@@@enDesc: Left-hand code not yet specified.
3474     @@@PerlDef:
3475     __DEEP{
3476     F: for my $child (@{$self-><AG::Node.childNodes>}) {
3477     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3478     $child-><AG::Node.localName> eq 'left') {
3479     $r = $child-><AG::Node.lastChild>;
3480     last F;
3481     }
3482     }
3483     }__;
3484     @@Set:
3485     @@@PerlDef:
3486     __DEEP{
3487     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
3488     F: {
3489     for my $child (@{$self-><AG::Node.childNodes>}) {
3490     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3491     $child-><AG::Node.localName> eq 'left') {
3492     $child-><AS::Node.textContent> ('');
3493     $child-><M::Node.appendChild> ($given);
3494     last F;
3495     }
3496     }
3497     my $node = $self-><AG::Node.ownerDocument>
3498     -><M::Document.createElementNS>
3499     (<Q::pc:>, 'left');
3500     $node-><M::Node.appendChild> ($given);
3501     $self-><M::Node.appendChild> ($node);
3502     }
3503     }__;
3504    
3505     @Attr:
3506     @@Name: rightCode
3507     @@enDesc:
3508     Right-hand expression.
3509     @@Type: PerlCodeInlines
3510     @@Get:
3511     @@@nullCase:
3512     @@@@enDesc: Right-hand code not yet specified.
3513     @@@PerlDef:
3514     __DEEP{
3515     F: for my $child (@{$self-><AG::Node.childNodes>}) {
3516     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3517     $child-><AG::Node.localName> eq 'right') {
3518     $r = $child-><AG::Node.lastChild>;
3519     last F;
3520     }
3521     }
3522     }__;
3523     @@Set:
3524     @@@PerlDef:
3525     __DEEP{
3526     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
3527     F: {
3528     for my $child (@{$self-><AG::Node.childNodes>}) {
3529     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3530     $child-><AG::Node.localName> eq 'right') {
3531     $child-><AS::Node.textContent> ('');
3532     $child-><M::Node.appendChild> ($given);
3533     last F;
3534     }
3535     }
3536     my $node = $self-><AG::Node.ownerDocument>
3537     -><M::Document.createElementNS>
3538     (<Q::pc:>, 'right');
3539     $node-><M::Node.appendChild> ($given);
3540     $self-><M::Node.appendChild> ($node);
3541     }
3542     }__;
3543 wakaba 1.11 ##PerlAssignment
3544    
3545 wakaba 1.35 IFClsETDef:
3546 wakaba 1.44 @IFQName: PCCondition
3547     @CQName: ManakaiPCCondition
3548     @ETQName: pc2|condition
3549    
3550     @IFISA: PerlCode
3551     @IFISA: PerlCodeInlines
3552     @CISA: ManakaiPCCodeInlines
3553    
3554     @enDesc:
3555     A <IF::PCCondition> object represents a condition expression
3556     part of an <Perl::if> or <Perl::while> statement.
3557    
3558     @ToStringMethod:
3559     @@Return:
3560     @@@Type: DOMString
3561     @@@PerlDef:
3562     __DEEP{
3563     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3564     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3565     $r .= $child;
3566     }
3567     }__;
3568     ##PCCondition
3569    
3570     IFClsETDef:
3571     @IFQName: PCBlock
3572     @CQName: ManakaiPCBlock
3573     @ETQName: pc2|block
3574    
3575     @IFISA: PerlCode
3576     @IFISA: PerlCodeStatements
3577     @CISA: ManakaiPCCodeStatements
3578    
3579     @enDesc:
3580     A <Q::PCBlock> object represents a Perl code block, i.e.
3581     a set of statements enclosed by <CHAR::{> and <CHAR::}> pair.
3582    
3583     @ToStringMethod:
3584     @@Return:
3585     @@@Type: DOMString
3586     @@@PerlDef:
3587     __DEEP{
3588     my @child = @{$self-><AG::Node.childNodes>};
3589     my $label = $self-><AG::PerlCodeStatements.label>;
3590    
3591     $r = "\x0A";
3592     for my $child (@child) {
3593     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3594     1 == @child) {
3595     $r .= '(' . $child->stringify . ')';
3596     } else {
3597     $r .= $child->stringify;
3598     }
3599     }
3600     $r .= "\x0A";
3601     $r .= ';' unless @child;
3602    
3603     if ($self-><AG::Node.ownerDocument>
3604     -><AG::Document.domConfig>
3605     -><M::DOMCore:DOMConfiguration.getParameter>
3606     (<Q::pc:line>)) {
3607     my $file = $self-><AG::PerlCode.fileNode>;
3608     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3609     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3610     $r = sprintf qq<\n{\n#line %d "%s [b] (Chunk #%d)"%s>.
3611     qq<#line 1 "%s [/b] (Chunk #%d)"\n}\n>,
3612     $self-><AG::PerlCodeStatements.sourceLine> || 1,
3613     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3614     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3615     $r,
3616     $sfile,
3617     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
3618     } else {
3619     $r = "\n{\n$r\n}\n";
3620     }
3621    
3622     $r = "\n" . $label . ':' . $r . '# ' . $label . "\n"
3623     if length $label;
3624    
3625     }__;
3626     ##PCBlock
3627    
3628     IFClsETDef:
3629 wakaba 1.45 @IFQName: PCWhile
3630     @CQName: ManakaiPCWhile
3631     @ETQName: pc|while
3632    
3633     @IFISA: PerlCode
3634     @CISA: ManakaiPCCode
3635    
3636     @enDesc:
3637     A <IF::PCWhile> object represents a <Perl::while> statement.
3638     It can contain two child elements: <Q::pc2|condition> and <Q::pc2|block>,
3639     each represents the condition expression and the block of the <Perl::while>
3640     statement.
3641    
3642     @ATTR:
3643     @@Name: label
3644     @@ATTRQName: pc|label
3645     @@enDesc:
3646     Label for this block.
3647     @@ReflectCDATA:
3648     @@Get:
3649     @@@nullCase:
3650     @@@@enDesc:
3651     No label.
3652     @@Set:
3653     @@@nullCase:
3654     @@@@enDesc:
3655     No label.
3656    
3657     @Attr:
3658     @@Name: condition
3659     @@enDesc:
3660     The condition object.
3661     @@Type: PCCondition
3662     @@Get:
3663     @@@nullCase:
3664     @@@@enDesc:
3665     There is no condition element.
3666     @@@PerlDef:
3667     __CODE{getChildElementByType::
3668     $namespaceURI => {<Q::pc2:>},
3669     $localName => {'condition'},
3670     $parent => $self,
3671     $result => $r,
3672     }__;
3673    
3674     @Attr:
3675     @@Name: block
3676     @@enDesc:
3677     The code block that is executed while the <A::PCWhile.condition> met.
3678     @@Type: PCBlock
3679     @@Get:
3680     @@@nullCase:
3681     @@@@enDesc:
3682     There is no <Q::pc2:block> child element.
3683     @@@PerlDef:
3684     __CODE{getChildElementByType::
3685     $namespaceURI => {<Q::pc2:>},
3686     $localName => {'block'},
3687     $parent => $self,
3688     $result => $r,
3689     }__;
3690    
3691     @ToStringMethod:
3692     @@Return:
3693     @@@Type: DOMString
3694     @@@PerlDef:
3695     __DEEP{
3696     $r = 'while (';
3697     my $cond = $self-><AG::PCWhile.condition>;
3698     if ($cond) {
3699     $r .= $cond->stringify;
3700     } else {
3701     $r .= '0';
3702     }
3703     $r .= ') ';
3704     my $block = $self-><AG::PCWhile.block>;
3705     if ($block) {
3706     $r .= $block->stringify;
3707     } else {
3708     $r .= "{ }\n";
3709     }
3710    
3711     my $label = $self-><AG::PCWhile.label>;
3712     $r = "\n" . $label . ': ' . $r . ' # ' . $label . "\n"
3713     if length $label;
3714     }__;
3715     ##PCWhile
3716    
3717     IFClsETDef:
3718 wakaba 1.43 @IFQName: PCChoose
3719     @CQName: ManakaiPCChoose
3720     @ETQName: pc|choose
3721    
3722     @IFISA: PerlCode
3723     @CISA: ManakaiPCCode
3724    
3725     @enDesc:
3726     A <IF::PCChoose> object, or a <Q::pc|choose> element, represents
3727     a set of <Perl::if>, <Perl::elsif>, and <Perl::else> statements.
3728    
3729     @Method:
3730     @@Name: getWhen
3731     @@enDesc:
3732     Returns a <IF::PCWhen> by its ordinal index.
3733     @@Param:
3734     @@@Name: index
3735     @@@Type: idl|unsignedLong||ManakaiDOM|all
3736     @@@enDesc:
3737     The ordinal index of the <Q::pc|when> element.
3738     @@Return:
3739     @@@Type: PCWhen
3740     @@@enDesc:
3741     The <P::index>th <Q::pc|when> object.
3742     @@@nullCase:
3743     @@@@enDesc:
3744     There is no <P::index>th element.
3745     @@@PerlDef:
3746     __DEEP{
3747     my $i = 0;
3748     no warnings 'uninitialized';
3749     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3750     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
3751     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
3752     $child-><AG::Node.localName> eq 'when' and
3753     ++$i == $index) {
3754     $r = $child;
3755     last A;
3756     }
3757     }
3758     }__;
3759    
3760     @Method:
3761     @@Name: appendNewPCWhen
3762     @@enDesc:
3763     Appends a new <Q::pc|when> element.
3764     @@Return:
3765     @@@Type: PCWhen
3766     @@@enDesc:
3767     The newly created <Q::pc|when> element.
3768     @@@PerlDef:
3769     __DEEP{
3770     my $od = $self-><AG::Node.ownerDocument>;
3771     $r = $od-><M::Document.createElementNS> (<Q::pc:>, 'when');
3772     my $cond = $od-><M::Document.createElementNS>
3773 wakaba 1.44 (<Q::pc2:>, 'condition');
3774 wakaba 1.43 $r-><M::Node.appendChild> ($cond);
3775     my $block = $od-><M::Document.createElementNS>
3776 wakaba 1.44 (<Q::pc2:>, 'block');
3777 wakaba 1.43 $r-><M::Node.appendChild> ($block);
3778     $self-><M::Node.insertBefore> ($r, $self-><AG::PCChoose.otherwise>);
3779     }__;
3780    
3781     @Attr:
3782     @@Name: otherwise
3783     @@enDesc:
3784     Returns the <IF::PCOtherwise> by its ordinal index.
3785     @@Type: PCOtherwise
3786     @@Get:
3787     @@@enDesc:
3788     The <Q::pc|otherwise> object.
3789     @@@nullCase:
3790     @@@@enDesc:
3791     There is no <Q::pc|otherwise> element.
3792     @@@PerlDef:
3793     __CODE{getChildElementByType::
3794     $namespaceURI => {<Q::pc:>},
3795     $localName => {'otherwise'},
3796     $parent => $self,
3797     $result => $r,
3798     }__;
3799    
3800     @Method:
3801     @@Name: appendNewPCOtherwise
3802     @@enDesc:
3803     Appends a new <Q::pc|otherwise> element. If there is already the
3804     <Q::pc|otherwise> element, then no element is created and
3805     the element is returned.
3806     @@Return:
3807     @@@Type: PCOtherwise
3808     @@@enDesc:
3809     The <Q::pc|otherwise> element.
3810     @@@PerlDef:
3811     __DEEP{
3812     $r = $self-><AG::PCChoose.otherwise>;
3813     unless ($r) {
3814     my $od = $self-><AG::Node.ownerDocument>;
3815     $r = $od-><M::Document.createElementNS> (<Q::pc:>, 'otherwise');
3816     my $block = $od-><M::Document.createElementNS>
3817 wakaba 1.44 (<Q::pc2:>, 'block');
3818 wakaba 1.43 $r-><M::Node.appendChild> ($block);
3819     $self-><M::Node.appendChild> ($r);
3820     }
3821     }__;
3822    
3823     @ToStringMethod:
3824     @@Return:
3825     @@@Type: DOMString
3826     @@@PerlDef:
3827     __DEEP{
3828     S: for my $child (@{$self-><AG::Node.childNodes>}) {
3829     next S unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3830     next S unless $child-><AG::Node.namespaceURI> eq <Q::pc:>;
3831     my $ln = $child-><AG::Node.localName>;
3832     if ($ln eq 'when') {
3833     $r .= 'els' if length $r;
3834     $r .= $child->stringify;
3835     } elsif ($ln eq 'otherwise') {
3836     $r .= $child->stringify;
3837     last S;
3838     }
3839     } # S
3840     }__;
3841     ##PCChoose
3842    
3843     IFClsETDef:
3844     @IFQName: PCWhen
3845     @CQName: ManakaiPCWhen
3846     @ETQName: pc|when
3847    
3848     @IFISA: PerlCode
3849     @CISA: ManakaiPCCode
3850    
3851     @enDesc:
3852     A <IF::PCWhen> object, or a <Q::pc|when> element, represents an
3853     <Perl::if> or <Perl::elsif> block.
3854    
3855     @Attr:
3856     @@Name: condition
3857     @@enDesc:
3858 wakaba 1.44 The condition object.
3859     @@Type: PCCondition
3860 wakaba 1.43 @@Get:
3861     @@@nullCase:
3862     @@@@enDesc:
3863 wakaba 1.44 There is no condition element.
3864 wakaba 1.43 @@@PerlDef:
3865     __CODE{getChildElementByType::
3866 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3867 wakaba 1.43 $localName => {'condition'},
3868     $parent => $self,
3869     $result => $r,
3870     }__;
3871    
3872     @Attr:
3873     @@Name: block
3874     @@enDesc:
3875     The code block that is executed when the <A::PCWhen.condition> met.
3876 wakaba 1.44 @@Type: PCBlock
3877 wakaba 1.43 @@Get:
3878     @@@nullCase:
3879     @@@@enDesc:
3880 wakaba 1.44 There is no <Q::pc2:block> child element.
3881 wakaba 1.43 @@@PerlDef:
3882     __CODE{getChildElementByType::
3883 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3884 wakaba 1.43 $localName => {'block'},
3885     $parent => $self,
3886     $result => $r,
3887     }__;
3888    
3889     @ToStringMethod:
3890     @@Return:
3891     @@@Type: DOMString
3892     @@@PerlDef:
3893     __DEEP{
3894     $r = 'if (';
3895     my $cond = $self-><AG::PCWhen.condition>;
3896     if ($cond) {
3897     $r .= $cond->stringify;
3898     } else {
3899     $r .= '0';
3900     }
3901     $r .= ') ';
3902     my $block = $self-><AG::PCWhen.block>;
3903     if ($block) {
3904     $r .= $block->stringify;
3905     } else {
3906     $r .= "{ }\n";
3907     }
3908     }__;
3909     ##PCWhen
3910    
3911     IFClsETDef:
3912     @IFQName: PCOtherwise
3913     @CQName: ManakaiPCOtherwise
3914     @ETQName: pc|otherwise
3915    
3916     @IFISA: PerlCode
3917     @CISA: ManakaiPCCode
3918    
3919     @enDesc:
3920     A <IF::PCOtherwise> object, or a <Q::pc|otherwise> element, represents an
3921     <Perl::else> clause.
3922    
3923     @Attr:
3924     @@Name: block
3925     @@enDesc:
3926     The code block that is executed.
3927 wakaba 1.44 @@Type: PCBlock
3928 wakaba 1.43 @@Get:
3929     @@@nullCase:
3930     @@@@enDesc:
3931 wakaba 1.44 There is no <Q::pc2:block> child element.
3932 wakaba 1.43 @@@PerlDef:
3933     __CODE{getChildElementByType::
3934 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3935 wakaba 1.43 $localName => {'block'},
3936     $parent => $self,
3937     $result => $r,
3938     }__;
3939    
3940     @ToStringMethod:
3941     @@Return:
3942     @@@Type: DOMString
3943     @@@PerlDef:
3944     __DEEP{
3945     my $block = $self-><AG::PCOtherwise.block>;
3946     if ($block) {
3947     $r = 'else ' . $block->stringify;
3948     }
3949     }__;
3950     ##PCOtherwise
3951    
3952     ResourceDef:
3953     @For: ManakaiDOM|ManakaiDOM
3954     @QName: getChildElementByType
3955     @rdf:type: DISPerl|BlockCode
3956     @enDesc:
3957     Returns the first element of a type.
3958     @PerlCDef:
3959     __DEEP{
3960     no warnings 'uninitialized';
3961     A: for my $__child (@{$parent-><AG::Node.childNodes>}) {
3962     if ($__child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
3963     $__child-><AG::Node.namespaceURI> eq $namespaceURI and
3964     $__child-><AG::Node.localName> eq $localName) {
3965     $result = $__child;
3966     last A;
3967     }
3968     }
3969     }__;
3970    
3971     IFClsETDef:
3972 wakaba 1.26 @IFQName: PerlIf
3973 wakaba 1.35 @CQName: ManakaiPCIf
3974     @ETQName: pc|if
3975 wakaba 1.25
3976     @IFISA: PerlCode
3977 wakaba 1.35 @CISA: ManakaiPCCode
3978 wakaba 1.25
3979 wakaba 1.12 @enDesc:
3980     Perl variable assignment.
3981    
3982     @ToStringMethod:
3983     @@Return:
3984 wakaba 1.35 @@@Type: DOMString
3985 wakaba 1.12 @@@enDesc:
3986     Perl code.
3987     @@@PerlDef:
3988 wakaba 1.35 __DEEP{
3989     my $tcode = $self-><AG::PerlIf.trueCode>;
3990     my $fcode = $self-><AG::PerlIf.falseCode>;
3991     my $ccode = $self-><AG::PerlIf.condition>;
3992     if (defined $tcode) {
3993     if (defined $fcode) {
3994     $r = q<if (> . $ccode->stringify . q<) {> . $tcode->stringify .
3995     q<} else {> . $fcode->stringify . qq<}\n>;
3996     } else {
3997 wakaba 1.36 $r = q<if (> . $ccode->stringify . q<) {> . $tcode->stringify .
3998 wakaba 1.35 qq<}\n>;
3999     }
4000     } else {
4001     $r = q<unless (> . $ccode->stringify . q<) {> . $fcode->stringify .
4002     qq<}\n>;
4003     }
4004     }__;
4005    
4006     @Attr:
4007     @@Name: condition
4008     @@enDesc:
4009     Condition expression.
4010     @@Type: PerlCodeInlines
4011     @@Get:
4012     @@@nullCase:
4013     @@@@enDesc: Condition code not yet specified.
4014     @@@PerlDef:
4015     __DEEP{
4016     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4017     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4018     $child-><AG::Node.localName> eq 'condition') {
4019     $r = $child-><AG::Node.lastChild>;
4020     last F;
4021     }
4022     }
4023     }__;
4024     @@Set:
4025     @@@PerlDef:
4026     __DEEP{
4027     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4028     F: {
4029     for my $child (@{$self-><AG::Node.childNodes>}) {
4030     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4031     $child-><AG::Node.localName> eq 'condition') {
4032     $child-><AS::Node.textContent> ('');
4033     $child-><M::Node.appendChild> ($given);
4034     last F;
4035     }
4036     }
4037     my $node = $self-><AG::Node.ownerDocument>
4038     -><M::Document.createElementNS>
4039     (<Q::pc:>, 'condition');
4040     $node-><M::Node.appendChild> ($given);
4041     $self-><M::Node.appendChild> ($node);
4042     }
4043     }__;
4044    
4045     @Attr:
4046     @@Name: trueCode
4047     @@enDesc:
4048     True-case code.
4049     @@Type: PerlCodeBlocks
4050     @@Get:
4051     @@@nullCase:
4052     @@@@enDesc: True-case code not yet specified.
4053     @@@PerlDef:
4054     __DEEP{
4055     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4056     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4057     $child-><AG::Node.localName> eq 'tr'.'ue') {
4058     $r = $child-><AG::Node.lastChild>;
4059     last F;
4060     }
4061     }
4062     }__;
4063     @@Set:
4064     @@@PerlDef:
4065     __DEEP{
4066     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4067     F: {
4068     for my $child (@{$self-><AG::Node.childNodes>}) {
4069     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4070     $child-><AG::Node.localName> eq 'tr'.'ue') {
4071     $child-><AS::Node.textContent> ('');
4072     $child-><M::Node.appendChild> ($given);
4073     last F;
4074     }
4075     }
4076     my $node = $self-><AG::Node.ownerDocument>
4077     -><M::Document.createElementNS>
4078     (<Q::pc:>, 'tr'.'ue');
4079     $node-><M::Node.appendChild> ($given);
4080     $self-><M::Node.appendChild> ($node);
4081     }
4082     }__;
4083    
4084     @Attr:
4085     @@Name: falseCode
4086     @@enDesc:
4087     False-case code.
4088     @@Type: PerlCodeBlocks
4089     @@Get:
4090     @@@nullCase:
4091     @@@@enDesc: True-case code not yet specified.
4092     @@@PerlDef:
4093     __DEEP{
4094     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4095     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4096     $child-><AG::Node.localName> eq 'fal'.'se') {
4097     $r = $child-><AG::Node.lastChild>;
4098     last F;
4099     }
4100     }
4101     }__;
4102     @@Set:
4103     @@@PerlDef:
4104     __DEEP{
4105     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4106     F: {
4107     for my $child (@{$self-><AG::Node.childNodes>}) {
4108     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4109     $child-><AG::Node.localName> eq 'fal'.'se') {
4110     $child-><AS::Node.textContent> ('');
4111     $child-><M::Node.appendChild> ($given);
4112     last F;
4113     }
4114     }
4115     my $node = $self-><AG::Node.ownerDocument>
4116     -><M::Document.createElementNS>
4117     (<Q::pc:>, 'fal'.'se');
4118     $node-><M::Node.appendChild> ($given);
4119     $self-><M::Node.appendChild> ($node);
4120     }
4121     }__;
4122 wakaba 1.12 ##PerlIf
4123    
4124     PropDef:
4125     @QName:condition
4126     @enDesc:
4127     Condition.
4128     PropDef:
4129     @QName:true
4130     @enDesc:
4131     If true.
4132     PropDef:
4133     @QName:false
4134     @enDesc:
4135     If false.
4136    
4137 wakaba 1.11 PropDef:
4138     @QName:left
4139     @FullName:
4140     @@lang:en
4141     @@@: Left hand side
4142     PropDef:
4143     @QName:right
4144     @FullName:
4145     @@lang:en
4146     @@@: Right hand side
4147    
4148 wakaba 1.8 PropDef:
4149     @QName:label
4150     @enDesc:
4151     Perl statement / block label.
4152    
4153 wakaba 1.43
4154     IFClsETDef:
4155     @IFQName: PCFunctionCall
4156     @CQName: ManakaiPCFunctionCall
4157     @ETQName: pc|call
4158    
4159     @IFISA: PerlCode
4160     @IFISA: PerlCodeInlines
4161     @CISA: ManakaiPCCodeInlines
4162    
4163     @enDesc:
4164     A <IF::PCFunctionCall> object represents a function call or
4165     function-like statement such as <Perl::next>.
4166    
4167     @ATTR:
4168     @@Name: variableType
4169     @@ATTRQName: pc|variableType
4170     @@enDesc:
4171     The value of the attribute <kwd:MAY> be <Perl::&>,
4172     which introduces a subroutine name.
4173     @@ReflectCDATA:
4174     @@Get:
4175     @@Set:
4176    
4177     @ATTR:
4178     @@Name: packageName
4179     @@ATTRQName: pc|packageName
4180     @@enDesc:
4181     The name of the package to which the subroutine belongs.
4182     @@ReflectCDATA:
4183     @@Get:
4184     @@@nullCase:
4185     @@@@enDesc:
4186     The object belongs to the current package or
4187     does not belong to any package.
4188     @@Set:
4189     @@@nullCase:
4190     @@@@enDesc:
4191     The object belongs to the current package or
4192     does not belong to any package.
4193    
4194     @ATTR:
4195     @@Name: pcLocalName
4196     @@ATTRQName: pc|localName
4197     @@enDesc:
4198     The local part of the subroutine name.
4199     @@ReflectCDATA:
4200     @@Get:
4201     @@Set:
4202    
4203     @ToStringMethod:
4204     @@Return:
4205     @@@Type: DOMString
4206     @@@PerlDef:
4207     __DEEP{
4208     $r .= $self-><AG::PCFunctionCall.variableType>;
4209     my $v = $self-><AG::PCFunctionCall.packageName>;
4210     $r .= $v . '::' if length $v;
4211     $r .= $self-><AG::PCFunctionCall.pcLocalName>;
4212    
4213     my @arg;
4214     no warnings 'uninitialized';
4215     A: for my $child (@{$self-><AG::Node.childNodes>}) {
4216     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
4217     push @arg, ''.$child;
4218     }
4219     my $arg = join ', ', @arg;
4220     if ({
4221     'die' => true,
4222     'last' => true,
4223     'next' => true,
4224     'redo' => true,
4225 wakaba 1.44 'return' => true,
4226 wakaba 1.43 'warn' => true,
4227 wakaba 1.44 }->{$r}) {
4228 wakaba 1.43 $r .= ' ' . $arg;
4229     } else {
4230     $r .= ' (' . $arg . ')';
4231     }
4232     }__;
4233     ##PCFunctionCall
4234    
4235 wakaba 1.6 ElementTypeBinding:
4236     @Name: RaiseException
4237     @ElementType:
4238 wakaba 1.39 dx:raises
4239    
4240     ## -- Configuration Parameters
4241    
4242     boolCParam:
4243     @QName: pc|line
4244     @nodeProp: pcline
4245     @IsSupportRequired:1
4246     @DOMCore:targetType: DOMCore|Document
4247     @TrueCase:
4248     @@DOMCore:isSupported:1
4249     @@enDesc:
4250     Inserts <Perl::#line> directives.
4251     @FalseCase:
4252     @@DOMCore:isSupported:1
4253     @@IsSupportRequired:1
4254     @@IsDefault:1
4255     Does not insert any <Perl::#line> directive.
4256    
4257     CParam:
4258     @QName: pc|split-resolver
4259     @nodeProp: pcsres
4260     @IsSupportRequired:1
4261     @DOMCore:targetType: DOMCore|Document
4262     @Type: DISPerl|CODE||ManakaiDOM|all
4263     @enDesc:
4264     Splits module file. The parameter value <kwd:MUST> be
4265     a Perl code reference. The serializer would invoke
4266     the code with arguments: a reserved parameter, a <IF::PerlFile>
4267     whose serialization is being split, and a string
4268     that identifies the split part. The code is expected
4269     to return a <IF::DOMLS:LSOutput> object to which the module part
4270     is written. Note that splitting serialized module file
4271     does not affect to the <IF::PerlFile> tree.
4272     @nullCase:
4273     @@enDesc:
4274     Does not split module file.
4275    
4276     ElementTypeBinding:
4277     @Name: nodeProp
4278     @ElementType:
4279     DOMCore:nodeProp
4280     @ShadowContent:
4281     @@For: =ManakaiDOM|all
4282    
4283     ElementTypeBinding:
4284     @Name: CParam
4285     @ElementType:
4286     dis:ResourceDef
4287     @ShadowContent:
4288     @@rdf:type:
4289     @@@@: DOMCore|DOMConfigurationParameter
4290     @@@For: ManakaiDOM|DOM
4291     @@rdf:type:
4292     @@@@: DISCore|Property
4293     @@@For: =ManakaiDOM|all
4294     @@For: ManakaiDOM|DOM3
4295     @@For: =ManakaiDOM|all
4296    
4297     ElementTypeBinding:
4298     @Name: boolCParam
4299     @ElementType:
4300     dis:ResourceDef
4301     @ShadowContent:
4302     @@rdf:type:
4303     @@@@: DOMCore|DOMConfigurationParameter
4304     @@@For: ManakaiDOM|DOM
4305     @@rdf:type:
4306     @@@@: DISCore|Property
4307     @@@For: =ManakaiDOM|all
4308     @@For: ManakaiDOM|DOM3
4309     @@For: =ManakaiDOM|all
4310     @@Type: idl|boolean||ManakaiDOM|all
4311    
4312 wakaba 1.41 ## -- PCDocument
4313    
4314     IFClsDef:
4315     @IFQName: PCDocument
4316     @CQName: ManakaiPCDocument
4317    
4318     @IFISA: Document
4319     @CISA: DOMCore|ManakaiDOMDocument
4320    
4321     @enDesc:
4322     A <IF::PCDocument> is a <IF::Document> that represents a Perl code.
4323    
4324     @s:rootElementType: pc|file
4325    
4326     @Method:
4327     @@Name: createPCLiteral
4328     @@enDesc:
4329     Creates a literal object.
4330 wakaba 1.47
4331     {NOTE:: If a member of <P::value> is a <IF::PerlCode> object,
4332     then it is appended to the tree as is, except when
4333     the object comes from different document than the
4334     document, in which case the object is being adopted
4335     to the document by <M::Document.adoptNode> method.
4336     If that method fails, then the result is undefined.
4337     }
4338 wakaba 1.41 @@Param:
4339     @@@Name: value
4340     @@@Type: DISPerl|Any
4341     @@@enDesc:
4342     The value.
4343     @@@InCase:
4344     @@@@Type: DISPerl|StringValue
4345     @@@@enDesc:
4346     A <IF::PerlStringLiteral> whose value is <P::value> is created.
4347     @@@InCase:
4348     @@@@Type: DISPerl|ARRAY
4349     @@@@enDesc:
4350     A <IF::PCArrayRefLiteral> is created. If <P::value>
4351     has items, then objects are recursively created.
4352     @@@InCase:
4353     @@@@Type: DISPerl|HASH
4354     @@@@enDesc:
4355     A <IF::PCHashRefLiteral> is created. If <P::value>
4356     has key-value pairs, then objects are recursively created.
4357     @@Return:
4358     @@@Type: PerlCode
4359     @@@enDesc: The newly created value object.
4360     @@@PerlDef:
4361     __DEEP{
4362     if (ref $value eq 'HASH' or ref $value eq 'ARRAY') {
4363     $r = $self-><M::Document.createElementNS>
4364     (<Q::pc:>, ref $value eq 'HASH' ? 'hashRefLiteral'
4365     : 'arrayRefLiteral');
4366     for my $v (ref $value eq 'HASH' ? %$value : @$value) {
4367     my $vo;
4368     if (UNIVERSAL::isa ($v, <IFName::PerlCode>)) {
4369 wakaba 1.47 $vo = $self-><M::Document.adoptNode> ($v);
4370 wakaba 1.41 } else {
4371     $vo = $self-><M::PCDocument.createPCLiteral> ($v);
4372     }
4373     $r-><M::Node.appendChild> ($vo);
4374     }
4375     } else {
4376     $r = $self-><M::Document.createElementNS>
4377     (<Q::pc:>, 'stringLiteral');
4378     $r-><AS::Node.textContent> ($value);
4379     }
4380 wakaba 1.43 }__;
4381    
4382     @Method:
4383 wakaba 1.44 @@Name: createPCNumberLiteral
4384     @@enDesc:
4385     Creates a number literal object.
4386     @@Param:
4387     @@@Name: value
4388     @@@Type: DISPerl|NumberValue
4389     @@@enDesc:
4390     The value.
4391     @@Return:
4392     @@@Type: PCNumberValue
4393     @@@enDesc: The newly created value object.
4394     @@@PerlDef:
4395     __DEEP{
4396     $r = $self-><M::Document.createElementNS>
4397     (<Q::pc:>, 'numberLiteral');
4398     $r-><AS::Node.textContent> ($value);
4399     }__;
4400    
4401     @Method:
4402     @@Name: createPCVariable
4403     @@enDesc:
4404     Creates a new <IF::PerlVariable> object.
4405     @@Param:
4406     @@@Name: variableType
4407     @@@Type: DOMString
4408     @@@enDesc:
4409     Variable prefix.
4410     @@@nullCase:
4411     @@@@enDesc:
4412     If the <P::packageName> is <DOM::null>, then
4413     the <P::variableType> is detected by the prefix of
4414     <P::localName>. Otherwise, it is an unprefixed variable
4415     such as file handle.
4416     @@Param:
4417     @@@Name: packageName
4418     @@@Type: DOMString
4419     @@@enDesc:
4420     Package name.
4421     @@@nullCase:
4422     @@@@enDesc:
4423     The variable belongs to the current package or a
4424     lexical-scoped variable.
4425     @@Param:
4426     @@@Name: localName
4427     @@@Type: DOMString
4428     @@@enDesc:
4429     Variable name. If both <P::variableType> and <P::packageName>
4430     is <DOM::null>, the <P::localName> value may be prefixed
4431     by any possible <P::variableType> value.
4432     @@Return:
4433     @@@Type: PerlVariable
4434     @@@enDesc:
4435     Newly created Perl variable object.
4436     @@@PerlDef:
4437     __DEEP{
4438     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'variable');
4439     if (not $variableType and not $packageName and
4440     $localName =~ s/^(\\?[\$\@%&*])//) {
4441     $variableType = $1;
4442     }
4443     $r-><AS::PerlVariable.variableType> ($variableType)
4444     if defined $variableType;
4445     $r-><AS::PerlVariable.packageName> ($packageName)
4446     if defined $packageName;
4447     $r-><AS::PerlVariable.pcLocalName> ($localName);
4448     }__;
4449    
4450     @Method:
4451     @@Name: createPCDereference
4452     @@enDesc:
4453     Creates a <IF::PCDereference> object.
4454     @@Param:
4455     @@@Name: variableType
4456     @@@Type: DOMString
4457     @@@enDesc:
4458     The type of the referenced value, such as <Perl::$>.
4459     @@Return:
4460     @@@Type: PCDereference
4461     @@@enDesc:
4462     The newly created element node.
4463     @@@PerlDef:
4464     __DEEP{
4465 wakaba 1.48 $r = $self-><M::Document.createElementNS>
4466     (<Q::pc:>, 'dereference');
4467 wakaba 1.44 $r-><AS::PCDereference.variableType> ($variableType);
4468 wakaba 1.48 }__;
4469    
4470     @Method:
4471     @@Name: createPCReference
4472     @@enDesc:
4473     Creates a <IF::PCReference> object.
4474     @@Return:
4475     @@@Type: PCReference
4476     @@@enDesc:
4477     The newly created element node.
4478     @@@PerlDef:
4479     __DEEP{
4480     $r = $self-><M::Document.createElementNS>
4481     (<Q::pc:>, 'reference');
4482 wakaba 1.44 }__;
4483    
4484     @Method:
4485 wakaba 1.43 @@Name: createPCExpression
4486     @@enDesc:
4487     Creates a <Q::pc:expression> element node.
4488     @@Param:
4489     @@@Name: operator
4490     @@@Type: DOMString
4491     @@@enDesc:
4492     The operator of the expression.
4493     @@Return:
4494     @@@Type: PCExpression
4495     @@@enDesc:
4496     The newly created expression object.
4497     @@@PerlDef:
4498     __DEEP{
4499 wakaba 1.44 $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'expression');
4500 wakaba 1.43 $r-><AS::PCExpression.operator> ($operator);
4501     }__;
4502    
4503     @Method:
4504 wakaba 1.44 @@Name: createPCApply
4505     @@enDesc:
4506     Creates a <Q::pc:apply> element node.
4507     @@Return:
4508     @@@Type: PCApply
4509     @@@enDesc: The newly created element node.
4510     @@@PerlDef:
4511     __DEEP{
4512     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'apply');
4513     }__;
4514    
4515     @Method:
4516 wakaba 1.43 @@Name: createPCFunctionCall
4517     @@enDesc:
4518 wakaba 1.44 Creates a function call element node.
4519 wakaba 1.43 @@Param:
4520     @@@Name: package
4521     @@@Type: DOMString
4522     @@@enDesc:
4523     The package to which the function belongs.
4524     @@@nullCase:
4525     @@@@enDesc: No package name.
4526     @@Param:
4527     @@@Name: localName
4528     @@@Type: DOMString
4529     @@@enDesc:
4530     The local part of the function name.
4531     @@Return:
4532 wakaba 1.44 @@@Type: PCApply
4533 wakaba 1.43 @@@enDesc:
4534     The newly created function object.
4535     @@@PerlDef:
4536     __DEEP{
4537 wakaba 1.44 $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'apply');
4538     my $func = $self-><M::PCDocument.createPCVariable>
4539     ('', $package, $localName);
4540     $r-><M::Node.appendChild> ($func);
4541     }__;
4542    
4543     @Method:
4544 wakaba 1.46 @@Name: createPCStatement
4545     @@enDesc:
4546     Creates a statement object.
4547     @@Return:
4548     @@@Type: PerlStatement
4549     @@@enDesc:
4550     The newly created statement element node.
4551     @@@PerlDef:
4552     __DEEP{
4553     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'statement');
4554     }__;
4555    
4556     @Method:
4557 wakaba 1.44 @@Name: createPCBlock
4558     @@enDesc:
4559     Creates a <Q::pc2:block> element node.
4560     @@Return:
4561     @@@Type: PCBlock
4562     @@@enDesc:
4563     The newly created <Q::pc2:block> element.
4564     @@@PerlDef:
4565     __DEEP{
4566     $r = $self-><M::Document.createElementNS> (<Q::pc2:>, 'block');
4567 wakaba 1.43 }__;
4568    
4569     @Method:
4570     @@Name: createPCChoose
4571     @@enDesc:
4572     Creates a <Q::pc:choose> element node.
4573     @@Return:
4574     @@@Type: PCChoose
4575     @@@enDesc:
4576     The newly created <Q::pc:choose> element.
4577     @@@PerlDef:
4578     __DEEP{
4579     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'choose');
4580 wakaba 1.45 }__;
4581    
4582     @Method:
4583     @@Name: createPCWhile
4584     @@enDesc:
4585     Creates a <Q::pc:while> element node.
4586     @@Return:
4587     @@@Type: PCWhile
4588     @@@enDesc:
4589     The newly created <Q::pc:while> element.
4590     @@@PerlDef:
4591     __DEEP{
4592     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'while');
4593     $r-><M::Node.appendChild>
4594     ($self-><M::Document.createElementNS> (<Q::pc2:>, 'condition'));
4595     $r-><M::Node.appendChild>
4596     ($self-><M::Document.createElementNS> (<Q::pc2:>, 'block'));
4597 wakaba 1.41 }__;
4598 wakaba 1.46
4599     @Method:
4600     @@Name: createPerlSub
4601     @@enDesc:
4602     Creates a new <IF::PerlSub> object.
4603     @@Param:
4604     @@@Name: subName
4605     @@@Type: DOMString
4606     @@@enDesc:
4607     The name of the subroutine to create.
4608     @@@nullCase:
4609     @@@@enDesc:
4610     The subroutine created has no name.
4611     @@Return:
4612     @@@Type: PerlSub
4613     @@@enDesc:
4614     Newly created Perl subroutine object.
4615     @@@PerlDef:
4616     __DEEP{
4617     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'sub');
4618     $r-><M::PerlSub.addPerlName> ($subName) if defined $subName;
4619     }__;
4620 wakaba 1.41 ##PCDocument
4621    
4622 wakaba 1.39 ## -- Implementation
4623 wakaba 1.6
4624 wakaba 1.25 IFClsDef:
4625     @IFQName: PCImplementation
4626 wakaba 1.35 @CQName: ManakaiPCImplementation
4627 wakaba 1.25
4628 wakaba 1.1 @enDesc:
4629     The class that provides factory methods.
4630 wakaba 1.20
4631 wakaba 1.35 @CISA: DOMCore|ManakaiDOMImplementation||ManakaiDOM|ManakaiDOMLatest
4632     @CISA: dx|ManakaiDefaultExceptionHandler||ManakaiDOM|Perl
4633 wakaba 1.17
4634 wakaba 1.35 @f:provides: pc|CoreFeature10
4635 wakaba 1.1
4636     @Method:
4637     @@Name: createPerlFile
4638     @@enDesc:
4639     Creates a Perl code file.
4640     @@Return:
4641 wakaba 1.25 @@@Type: PerlFile
4642 wakaba 1.1 @@@enDesc: A newly created Perl source file object.
4643     @@@PerlDef:
4644 wakaba 1.35 __DEEP{
4645     $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4646     -><AG::Document.documentElement>;
4647     }__;
4648 wakaba 1.1
4649 wakaba 1.13 @Method:
4650     @@Name: createPerlPackage
4651     @@enDesc:
4652     Creates a new package scope block.
4653     @@Param:
4654     @@@Name: packageName
4655 wakaba 1.35 @@@Type: DOMString
4656 wakaba 1.13 @@@enDesc:
4657     The fully-qualified name of the package to create.
4658     @@Return:
4659 wakaba 1.25 @@@Type: PerlPackage
4660 wakaba 1.13 @@@enDesc:
4661     The newly created package scope object.
4662     @@@PerlDef:
4663 wakaba 1.35 __DEEP{
4664 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4665 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'package');
4666     $r-><AS::PerlPackage.packageName> ($packageName);
4667     }__;
4668 wakaba 1.13
4669 wakaba 1.1 @IntMethod:
4670 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4671 wakaba 1.1 @@Name: perlComment
4672     @@ManakaiDOM:isStatic:1
4673     @@enDesc:
4674     Generates a Perl comment string.
4675     @@Param:
4676     @@@Name: str
4677 wakaba 1.35 @@@Type: DOMString
4678 wakaba 1.1 @@@enDesc:
4679     A comment text.
4680     @@Return:
4681 wakaba 1.35 @@@Type: DOMString
4682 wakaba 1.1 @@@enDesc:
4683     A Perl comment string.
4684     @@@PerlDef:
4685     $r = $str;
4686     $r =~ s/\n/\n## /g;
4687     $r =~ s/\n## $/\n/s;
4688     $r .= "\n" unless $r =~ /\n$/;
4689     $r = q<## > . $r;
4690    
4691     @IntMethod:
4692 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4693 wakaba 1.1 @@Name: rfc3339DateTime
4694     @@ManakaiDOM:isStatic:1
4695     @@enDesc:
4696     Returns RFC 3339 <CODE::date-time> representation of a date.
4697     @@Param:
4698     @@@Name: perlDate
4699 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
4700 wakaba 1.1 @@@enDesc:
4701     A Perl representation of date.
4702     @@Return:
4703 wakaba 1.35 @@@Type: DOMString
4704 wakaba 1.1 @@@enDesc:
4705     RFC 3339 date string.
4706     @@@PerlDef:
4707     my @time = gmtime $perlDate;
4708     $r = sprintf q<%04d-%02d-%02dT%02d:%02d:%02d+00:00>,
4709     $time[5] + 1900, $time[4] + 1, @time[3,2,1,0];
4710    
4711     @IntMethod:
4712 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4713 wakaba 1.1 @@Name: versionDateTime
4714     @@ManakaiDOM:isStatic:1
4715     @@enDesc:
4716     Returns date for version.
4717     @@Param:
4718     @@@Name: perlDate
4719 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
4720 wakaba 1.1 @@@enDesc:
4721     A Perl representation of date.
4722     @@Return:
4723 wakaba 1.35 @@@Type: DOMString
4724 wakaba 1.1 @@@enDesc:
4725     A Perl number literal.
4726     @@@PerlDef:
4727     my @time = gmtime $perlDate;
4728     $r = sprintf q<%04d%02d%02d.%02d%02d>,
4729     $time[5] + 1900, $time[4] + 1, @time[3,2,1];
4730    
4731     @Method:
4732     @@Name: perlLiteral
4733     @@enDesc:
4734     Perl code representation.
4735     @@Param:
4736     @@@Name: val
4737 wakaba 1.35 @@@Type: DISPerl|Any||ManakaiDOM|all
4738 wakaba 1.1 @@@enDesc:
4739     A Perl value.
4740     @@Return:
4741 wakaba 1.35 @@@Type: DOMString
4742 wakaba 1.1 @@@enDesc:
4743     A Perl lexical representation of <P::val>.
4744     @@@PerlDef:
4745     unless (defined $val) {
4746     $r = q<undef>;
4747     } elsif (ref $val eq 'ARRAY') {
4748     __DEEP{
4749 wakaba 1.36 $r = q<[> . <ClassM::ManakaiPCImplementation
4750 wakaba 1.14 .perlList> ($val) . q<]>;
4751 wakaba 1.1 }__;
4752     } elsif (ref $val eq 'HASH') {
4753     __DEEP{
4754 wakaba 1.31 $r = q<{>
4755 wakaba 1.36 . <ClassM::ManakaiPCImplementation.perlList>
4756 wakaba 1.31 ([map {$_ => $val->{$_}} sort {$a cmp $b} keys %$val])
4757     . q<}>;
4758 wakaba 1.1 }__;
4759 wakaba 1.38 } elsif (ref $val eq 'manakai::code') {
4760     $r = $$val;
4761 wakaba 1.1 } else {
4762     $val =~ s/(['\\])/\\$1/g;
4763     $r = q<'> . $val . q<'>;
4764     }
4765    
4766     @Method:
4767     @@Name: perlList
4768     @@enDesc:
4769     Perl code representation of a list.
4770     @@Param:
4771     @@@Name: val
4772 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
4773 wakaba 1.1 @@@enDesc:
4774     A Perl array reference.
4775     @@Return:
4776 wakaba 1.35 @@@Type: DOMString
4777 wakaba 1.1 @@@enDesc:
4778     A Perl lexical representation of <CODE::@$val>.
4779     @@@PerlDef:
4780     __DEEP{
4781 wakaba 1.36 $r = join (q<, >, map {<ClassM::ManakaiPCImplementation
4782 wakaba 1.1 .perlLiteral> ($_)} @{$val});
4783     }__;
4784 wakaba 1.5
4785     @Method:
4786     @@Name: createPerlSub
4787     @@enDesc:
4788 wakaba 1.35 Creates a new <IF::PerlSub> object.
4789 wakaba 1.5 @@Param:
4790     @@@Name: subName
4791 wakaba 1.35 @@@Type: DOMString
4792 wakaba 1.5 @@@enDesc:
4793     The name of the subroutine to create.
4794     @@@nullCase:
4795     @@@@enDesc:
4796     The subroutine created has no name.
4797     @@Return:
4798 wakaba 1.25 @@@Type: PerlSub
4799 wakaba 1.5 @@@enDesc:
4800     Newly created Perl subroutine object.
4801     @@@PerlDef:
4802 wakaba 1.35 __DEEP{
4803 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4804 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'sub');
4805     $r-><M::PerlSub.addPerlName> ($subName) if defined $subName;
4806     }__;
4807 wakaba 1.5
4808     @Method:
4809     @@Name: createPerlUnparsedCode
4810     @@enDesc:
4811     Creates a new <Class::ManakaiPerlUnparsedCode> object.
4812     @@Param:
4813     @@@Name: codeArg
4814 wakaba 1.35 @@@Type: DOMString
4815 wakaba 1.5 @@@enDesc:
4816     The code fragment.
4817     @@@nullCase:
4818     @@@@enDesc:
4819     The fragment initially has no code.
4820     @@Return:
4821 wakaba 1.25 @@@Type: PerlUnparsedCode
4822 wakaba 1.5 @@@enDesc:
4823     Newly created Perl code object.
4824     @@@PerlDef:
4825 wakaba 1.35 __DEEP{
4826 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4827 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'unparsed');
4828     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4829     }__;
4830 wakaba 1.6
4831     @Method:
4832     @@Name: createPerlInlineContainer
4833     @@enDesc:
4834 wakaba 1.35 Creates a new <IF::PerlInlineContainer> object.
4835 wakaba 1.6 @@Return:
4836 wakaba 1.25 @@@Type: PerlCodeInlines
4837 wakaba 1.6 @@@enDesc:
4838     Newly created Perl code object.
4839     @@@PerlDef:
4840 wakaba 1.35 __DEEP{
4841 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4842 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'inlineContainer');
4843     }__;
4844 wakaba 1.6
4845     @Method:
4846     @@Name: createPerlInlineUnparsedCode
4847     @@enDesc:
4848 wakaba 1.35 Creates a new <IF::PerlInlineUnparsedCode> object.
4849 wakaba 1.6 @@Param:
4850     @@@Name: codeArg
4851 wakaba 1.35 @@@Type: DOMString
4852 wakaba 1.6 @@@enDesc:
4853     The code fragment.
4854     @@@nullCase:
4855     @@@@enDesc:
4856     The fragment initially has no code.
4857     @@Return:
4858 wakaba 1.25 @@@Type: PerlInlineUnparsedCode
4859 wakaba 1.6 @@@enDesc:
4860     Newly created Perl code object.
4861     @@@PerlDef:
4862 wakaba 1.35 __DEEP{
4863 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4864 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'inlineUnparsed');
4865     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4866     }__;
4867 wakaba 1.6
4868     @Method:
4869     @@Name: createPerlBare
4870     @@enDesc:
4871 wakaba 1.35 Creates a new <IF::PerlTokens> object.
4872 wakaba 1.6 @@Param:
4873     @@@Name: codeArg
4874 wakaba 1.35 @@@Type: DOMString
4875 wakaba 1.6 @@@enDesc:
4876     The code fragment.
4877     @@Return:
4878 wakaba 1.25 @@@Type: PerlTokens
4879 wakaba 1.6 @@@enDesc:
4880     Newly created Perl code object.
4881     @@@PerlDef:
4882 wakaba 1.35 __DEEP{
4883 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4884 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'tokens');
4885     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4886     }__;
4887 wakaba 1.6
4888     @Method:
4889     @@Name: createPerlAtom
4890     @@enDesc:
4891 wakaba 1.35 Creates a new <IF::PerlAtom> object.
4892 wakaba 1.6 @@Param:
4893     @@@Name: codeArg
4894 wakaba 1.35 @@@Type: DOMString
4895 wakaba 1.6 @@@enDesc:
4896     The code fragment.
4897     @@Return:
4898 wakaba 1.25 @@@Type: PerlAtom
4899 wakaba 1.6 @@@enDesc:
4900     Newly created Perl code object.
4901     @@@PerlDef:
4902 wakaba 1.35 __DEEP{
4903 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4904 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'atom');
4905     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4906     }__;
4907 wakaba 1.6
4908     @Method:
4909     @@Name: createPerlStringLiteral
4910     @@enDesc:
4911 wakaba 1.35 Creates a new <IF::PerlStringLiteral> object.
4912 wakaba 1.6 @@Param:
4913     @@@Name: stringArg
4914 wakaba 1.35 @@@Type: DOMString
4915 wakaba 1.6 @@@enDesc: A string.
4916     @@Return:
4917 wakaba 1.25 @@@Type: PerlStringLiteral
4918 wakaba 1.6 @@@enDesc:
4919     Newly created Perl code object.
4920     @@@PerlDef:
4921 wakaba 1.35 __DEEP{
4922 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4923 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'stringLiteral');
4924     $r-><AS::Node.textContent> ($stringArg);
4925     }__;
4926 wakaba 1.6
4927     @Method:
4928     @@Name: createPerlVariable
4929     @@enDesc:
4930 wakaba 1.35 Creates a new <IF::PerlVariable> object.
4931 wakaba 1.6 @@Param:
4932     @@@Name: variableType
4933 wakaba 1.35 @@@Type: DOMString
4934 wakaba 1.6 @@@enDesc:
4935     Variable prefix.
4936 wakaba 1.16 @@@nullCase:
4937     @@@@enDesc:
4938     If the <P::packageName> is <DOM::null>, then
4939     the <P::variableType> is detected by the prefix of
4940     <P::localName>. Otherwise, it is an unprefixed variable
4941     such as file handle.
4942 wakaba 1.6 @@Param:
4943     @@@Name: packageName
4944 wakaba 1.35 @@@Type: DOMString
4945 wakaba 1.6 @@@enDesc:
4946     Package name.
4947     @@@nullCase:
4948     @@@@enDesc:
4949     The variable belongs to the current package or a
4950     lexical-scoped variable.
4951     @@Param:
4952     @@@Name: localName
4953 wakaba 1.35 @@@Type: DOMString
4954 wakaba 1.6 @@@enDesc:
4955 wakaba 1.16 Variable name. If both <P::variableType> and <P::packageName>
4956     is <DOM::null>, the <P::localName> value may be prefixed
4957     by any possible <P::variableType> value.
4958 wakaba 1.6 @@Return:
4959 wakaba 1.25 @@@Type: PerlVariable
4960 wakaba 1.6 @@@enDesc:
4961     Newly created Perl variable object.
4962     @@@PerlDef:
4963 wakaba 1.35 __DEEP{
4964 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4965 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'variable');
4966     if (not $variableType and not $packageName and
4967     $localName =~ s/^(\\?[\$\@%&*])//) {
4968     $variableType = $1;
4969     }
4970     $r-><AS::PerlVariable.variableType> ($variableType)
4971     if defined $variableType;
4972     $r-><AS::PerlVariable.packageName> ($packageName)
4973     if defined $packageName;
4974     $r-><AS::PerlVariable.pcLocalName> ($localName);
4975     }__;
4976 wakaba 1.8
4977     @Method:
4978     @@Name: createPerlBlock
4979     @@enDesc:
4980 wakaba 1.35 Creates a new <IF::PerlBlock> object.
4981 wakaba 1.8 @@Return:
4982 wakaba 1.25 @@@Type: PerlBlock
4983 wakaba 1.8 @@@enDesc:
4984     Newly created Perl code object.
4985     @@@PerlDef:
4986 wakaba 1.35 __DEEP{
4987 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4988 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'block');
4989     }__;
4990 wakaba 1.9
4991     @Method:
4992     @@Name: createPerlBlockContainer
4993     @@enDesc:
4994     Creates a new <Class::ManakaiPerlBlockContainer> object.
4995     @@Return:
4996 wakaba 1.25 @@@Type: PerlCodeBlocks
4997 wakaba 1.9 @@@enDesc:
4998     Newly created Perl code object.
4999     @@@PerlDef:
5000 wakaba 1.35 __DEEP{
5001 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5002 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'blockContainer');
5003     }__;
5004 wakaba 1.11
5005     @Method:
5006     @@Name: createPerlStatement
5007     @@enDesc:
5008     Creates a new Perl statement.
5009     @@Param:
5010     @@@Name: codeArg
5011 wakaba 1.35 @@@Type: DOMString
5012 wakaba 1.11 @@@enDesc:
5013     A Perl statement without terminating <Perl::;>.
5014     @@@nullCase:
5015     @@@@enDesc:
5016     No initial content.
5017     @@Return:
5018 wakaba 1.25 @@@Type: PerlStatement
5019 wakaba 1.11 @@@enDesc:
5020     The newly created Perl code object.
5021     @@@PerlDef:
5022 wakaba 1.35 __DEEP{
5023 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5024 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'statement');
5025     if (defined $codeArg) {
5026     $r-><M::PerlCodeUnits.appendBare> ($codeArg);
5027     }
5028     }__;
5029 wakaba 1.12
5030     @Method:
5031     @@Name: createPerlIf
5032     @@enDesc:
5033 wakaba 1.35 Creates a <IF::PerlIf> object.
5034 wakaba 1.12 @@Param:
5035     @@@Name: conditionArg
5036 wakaba 1.35 @@@Type: PerlCodeInlines
5037 wakaba 1.12 @@@enDesc:
5038     Conditoon code fragment object.
5039     @@Param:
5040     @@@Name: trueArg
5041 wakaba 1.35 @@@Type: PerlCodeBlocks
5042 wakaba 1.12 @@@enDesc:
5043     A true code fragment object.
5044     @@@nullCase:
5045     @@@@enDesc: No true code.
5046     @@Param:
5047     @@@Name: falseArg
5048 wakaba 1.35 @@@Type: PerlCodeBlocks
5049 wakaba 1.12 @@@enDesc:
5050     A false code fragment object.
5051     @@@nullCase:
5052     @@@@enDesc: No false code.
5053     @@Return:
5054 wakaba 1.25 @@@Type: PerlIf
5055 wakaba 1.12 @@@RaiseException:
5056     @@@@@:BAD_CHILD_ERR
5057     @@@@enDesc:
5058     An attempt is made to append a child
5059     that is not valid type.
5060     @@@RaiseException:
5061     @@@@@:IN_USE_NODE_ERR
5062     @@@@enDesc:
5063     An attempt is made to append a node that is
5064     already used elsewhere.
5065     @@@PerlDef:
5066 wakaba 1.35 for my $arg ([conditionArg => $conditionArg]) {
5067     if ({
5068     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
5069     inlineUnparsed => 1, variable => 1, stringLiteral => true,
5070 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
5071 wakaba 1.35 }->{$arg->[1]-><AG::Node.localName>}) {
5072     if ($arg->[1]-><AG::Node.parentNode>) {
5073     __EXCEPTION{IN_USE_NODE_ERR::
5074     pc:childNode => {$arg->[1]},
5075     MDOMX:param-name => {$arg->[0]},
5076     }__;
5077     }
5078     } else {
5079     __EXCEPTION{BAD_CHILD_ERR::
5080     pc:parentNode => {$self},
5081     pc:childNode => {$arg->[1]},
5082     MDOMX:param-name => {$arg->[0]},
5083     }__;
5084     }
5085     } # c
5086    
5087     for my $arg ([trueArg => $trueArg],
5088     [falseArg => $falseArg]) {
5089     next unless $arg->[1];
5090     if ({
5091     blockContainer => true,
5092     }->{$arg->[1]-><AG::Node.localName>}) {
5093     if ($arg->[1]-><AG::Node.parentNode>) {
5094     __EXCEPTION{IN_USE_NODE_ERR::
5095     pc:childNode => {$arg->[1]},
5096     MDOMX:param-name => {$arg->[0]},
5097     }__;
5098     }
5099     } else {
5100     __EXCEPTION{BAD_CHILD_ERR::
5101     pc:parentNode => {$self},
5102     pc:childNode => {$arg->[1]},
5103     MDOMX:param-name => {$arg->[0]},
5104     }__;
5105     }
5106     } # t/f
5107    
5108     __DEEP{
5109 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5110 wakaba 1.35 -><M::Document.createElementNS>
5111     (<Q::pc:>, 'if');
5112     $r-><AS::PerlIf.condition> ($conditionArg) if $conditionArg;
5113     $r-><AS::PerlIf.trueCode> ($trueArg) if $trueArg;
5114     $r-><AS::PerlIf.falseCode> ($falseArg) if $falseArg;
5115     }__;
5116 wakaba 1.25 ##PCImplementation
5117 wakaba 1.1
5118 wakaba 1.5 ResourceDef:
5119 wakaba 1.35 @QName: DOMImpl
5120     @AliasFor: DOMCore|DOMImplementation
5121 wakaba 1.41 @For: ManakaiDOM|DOM
5122    
5123     ResourceDef:
5124     @QName: NodeList
5125     @AliasFor: DOMCore|NodeList
5126 wakaba 1.35 @For: ManakaiDOM|DOM
5127    
5128     ResourceDef:
5129     @QName: Node
5130     @AliasFor: DOMCore|Node
5131     @For: ManakaiDOM|DOM
5132    
5133     ResourceDef:
5134     @QName: Element
5135     @AliasFor: DOMCore|Element
5136     @For: ManakaiDOM|DOM
5137    
5138     ResourceDef:
5139     @QName: Document
5140     @AliasFor: DOMCore|Document
5141     @For: ManakaiDOM|DOM
5142    
5143 wakaba 1.4 ## -- Exceptions
5144    
5145 wakaba 1.25 ResourceDef:
5146     @rdf:type:
5147     @@@: dis|MultipleResource
5148     @@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
5149     @resourceFor: ManakaiDOM|ForIF
5150     @resourceFor: ManakaiDOM|ForClass
5151    
5152     @For: ManakaiDOM|Perl
5153    
5154     @rdf:type:
5155 wakaba 1.33 @@@: dx|Interface
5156 wakaba 1.25 @@ForCheck: ManakaiDOM|ForIF
5157    
5158     @rdf:type:
5159 wakaba 1.33 @@@: dx|Class
5160 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
5161    
5162     @Implement:
5163 wakaba 1.35 @@@: ||ManakaiDOM|ManakaiDOM|ManakaiDOM||ManakaiDOM|ForIF
5164     @@ContentType: DISCore|TFPQNames
5165     @@ForCheck: ManakaiDOM|ForClass
5166     @Implement:
5167     @@@: ||ManakaiDOM|ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
5168 wakaba 1.25 @@ContentType: DISCore|TFPQNames
5169     @@ForCheck: ManakaiDOM|ForClass
5170 wakaba 1.35 @dx:implementedBy: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForClass
5171 wakaba 1.25
5172 wakaba 1.35 @f:implements: pc|CoreFeature10
5173 wakaba 1.25
5174     @ISA:
5175 wakaba 1.33 @@@: dx|Exception||ManakaiDOM|Perl
5176 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
5177    
5178     @IFQName: PCException
5179 wakaba 1.35 @QName:
5180     @@@: ManakaiPCException
5181     @@ForCheck: ManakaiDOM|ForClass
5182 wakaba 1.25
5183 wakaba 1.4 @enDesc:
5184 wakaba 1.25 Exceptions for the <Module::Util:PerlCode> module.
5185    
5186     @ResourceDef:
5187 wakaba 1.33 @@ForCheck: ManakaiDOM|ForIF
5188     @@rdf:type: DISLang|ConstGroup
5189 wakaba 1.25
5190     @@IFQName: PCExceptionCode
5191    
5192 wakaba 1.4 @@enDesc:
5193 wakaba 1.25 Exception codes for <IF::PCException>.
5194    
5195 wakaba 1.33 @@Type: idl|unsignedShort||ManakaiDOM|all
5196     @@rdfs:subClassOf: idl|unsignedShort||ManakaiDOM|all
5197 wakaba 1.25
5198 wakaba 1.5 @@XConstDef:
5199     @@@Name: HIERARCHY_REQUEST_ERR
5200 wakaba 1.27 @@@Value:
5201     @@@@@:3
5202     @@@@ContentType: DISCore|Integer
5203 wakaba 1.5 @@@enDesc:
5204     An attempt is made to break the hierarchy.
5205     @@@XSubTypeDef:
5206     @@@@QName: BAD_CHILD_ERR
5207     @@@@enDesc:
5208     An attempt is made to append a node as a child whose type
5209     is not allowed.
5210     @@@@XParam:
5211     @@@@@QName: childNode
5212     @@@@@enDesc:
5213     The node attempted to append.
5214     @@@@XParam:
5215     @@@@@QName: parentNode
5216     @@@@@enDesc:
5217     The node to whose child list an attempt to append is made.
5218     @@@XSubTypeDef:
5219     @@@@QName: IN_USE_NODE_ERR
5220     @@@@enDesc:
5221     An attempt is made to append a node that has already been used
5222     elsewhere.
5223     @@@@XParam:
5224     @@@@@QName: childNode
5225     @@@@@enDesc:
5226     The node attempted to append.
5227     @@@@XParam:
5228     @@@@@QName: parentNode
5229     @@@@@enDesc:
5230     The parent node of the <XP::childNode>.
5231 wakaba 1.4 @@XConstDef:
5232     @@@Name: NOT_SUPPORTED_ERR
5233 wakaba 1.27 @@@Value:
5234     @@@@@:9
5235     @@@@ContentType: DISCore|Integer
5236 wakaba 1.4 @@@enDesc:
5237     An attempt is made to do something the implementation does not support.
5238     @@@XSubTypeDef:
5239     @@@@QName: UNSUPPORTED_OPERATOR_ERR
5240     @@@@enDesc:
5241     The implementation does not support the specified operator.
5242     @@@@XParam:
5243     @@@@@QName: operator
5244     @@@@@enDesc:
5245     The operator that is not supported.
5246     @@@@enMufDef:
5247     Operator "%p (name => {<Q::pc:operator>});" is not supported
5248 wakaba 1.25 ##PCException
5249 wakaba 1.4
5250     ElementTypeBinding:
5251     @Name: XConstDef
5252     @ElementType:
5253     dis:ResourceDef
5254     @ShadowContent:
5255 wakaba 1.33 @@rdf:type: dx|ErrorCode
5256 wakaba 1.4
5257     ElementTypeBinding:
5258     @Name: XSubTypeDef
5259     @ElementType:
5260     dis:ResourceDef
5261     @ShadowContent:
5262 wakaba 1.33 @@rdf:type: dx|ErrorSubCode
5263 wakaba 1.4
5264     ElementTypeBinding:
5265     @Name: XParam
5266     @ElementType:
5267 wakaba 1.33 ecore:hasParameter
5268 wakaba 1.4
5269     ElementTypeBinding:
5270     @Name: XParamDef
5271     @ElementType:
5272     dis:ResourceDef
5273     @ShadowContent:
5274 wakaba 1.33 @@rdf:type: ecore|Parameter
5275 wakaba 1.27 @@For: =ManakaiDOM|all
5276 wakaba 1.4
5277     ElementTypeBinding:
5278     @Name: enMufDef
5279     @ElementType:
5280 wakaba 1.40 ecore:defaultMessage
5281 wakaba 1.4 @ShadowContent:
5282     @@ContentType:
5283     lang:muf
5284     @@lang:en
5285    
5286 wakaba 1.1 ElementTypeBinding:
5287     @Name: Method
5288     @ElementType:
5289     dis:ResourceDef
5290     @ShadowContent:
5291     @@rdf:type:
5292     DISLang:Method
5293    
5294     ElementTypeBinding:
5295     @Name: ToStringMethod
5296     @ElementType:
5297     dis:ResourceDef
5298     @ShadowContent:
5299     @@rdf:type:
5300     DISLang:Method
5301     @@Operator:
5302     @@@@:
5303     DISPerl:AsStringMethod
5304 wakaba 1.35 @@@ContentType: DISCore|QName
5305 wakaba 1.1 @@Description:
5306     @@@lang:en
5307     @@@@:
5308     Returns the textual Perl source code representation of this object.
5309 wakaba 1.9
5310 wakaba 1.14 ElementTypeBinding:
5311     @Name: NumValMethod
5312     @ElementType:
5313     dis:ResourceDef
5314     @ShadowContent:
5315     @@rdf:type:
5316     DISLang:Method
5317     @@Operator:
5318     @@@@: 0+
5319     @@@ContentType:
5320     lang:Perl
5321     @@Description:
5322     @@@lang:en
5323     @@@@:
5324     Returns the numeric value of this object.
5325 wakaba 1.9
5326     ElementTypeBinding:
5327 wakaba 1.1 @Name: IntMethod
5328     @ElementType:
5329     dis:ResourceDef
5330     @ShadowContent:
5331     @@rdf:type:
5332     DISLang:Method
5333     @@ManakaiDOM:isForInternal:1
5334    
5335     ElementTypeBinding:
5336     @Name: Attr
5337     @ElementType:
5338     dis:ResourceDef
5339     @ShadowContent:
5340     @@rdf:type:
5341     DISLang:Attribute
5342    
5343     ElementTypeBinding:
5344     @Name: Return
5345     @ElementType:
5346     dis:ResourceDef
5347     @ShadowContent:
5348     @@rdf:type:
5349     DISLang:MethodReturn
5350    
5351     ElementTypeBinding:
5352     @Name: Get
5353     @ElementType:
5354     dis:ResourceDef
5355     @ShadowContent:
5356     @@rdf:type:
5357     DISLang:AttributeGet
5358    
5359     ElementTypeBinding:
5360     @Name: Set
5361     @ElementType:
5362     dis:ResourceDef
5363     @ShadowContent:
5364     @@rdf:type:
5365     DISLang:AttributeSet
5366    
5367     ElementTypeBinding:
5368     @Name: Param
5369     @ElementType:
5370     dis:ResourceDef
5371     @ShadowContent:
5372     @@rdf:type:
5373     DISLang:MethodParameter
5374    
5375     ElementTypeBinding:
5376     @Name: PerlDef
5377     @ElementType:
5378     dis:Def
5379     @ShadowContent:
5380     @@ContentType:
5381     lang:Perl
5382 wakaba 1.27 @@ForCheck: ManakaiDOM|ForClass
5383 wakaba 1.28
5384     ElementTypeBinding:
5385     @Name: PerlCDef
5386     @ElementType:
5387     dis:Def
5388     @ShadowContent:
5389     @@ContentType:
5390     lang:Perl
5391 wakaba 1.1
5392     ElementTypeBinding:
5393     @Name: disDef
5394     @ElementType:
5395     dis:Def
5396     @ShadowContent:
5397     @@ContentType:
5398     lang:dis
5399 wakaba 1.27 @@ForCheck: ManakaiDOM|ForClass
5400 wakaba 1.1
5401     ElementTypeBinding:
5402     @Name: InCase
5403     @ElementType:
5404     dis:ResourceDef
5405     @ShadowContent:
5406     @@rdf:type:
5407     ManakaiDOM:InCase
5408    
5409     ElementTypeBinding:
5410     @Name: nullCase
5411     @ElementType:
5412     dis:ResourceDef
5413     @ShadowContent:
5414     @@rdf:type:
5415     ManakaiDOM:InCase
5416     @@Value:
5417     @@@is-null:1
5418    
5419     ElementTypeBinding:
5420     @Name: TrueCase
5421     @ElementType:
5422     dis:ResourceDef
5423     @ShadowContent:
5424     @@rdf:type:
5425     ManakaiDOM:InCase
5426 wakaba 1.27 @@Value:
5427     @@@@:1
5428     @@@ContentType: DISCore|Boolean
5429 wakaba 1.1 @@Type:
5430 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
5431 wakaba 1.1
5432    
5433     ElementTypeBinding:
5434     @Name: FalseCase
5435     @ElementType:
5436     dis:ResourceDef
5437     @ShadowContent:
5438     @@rdf:type:
5439     ManakaiDOM:InCase
5440 wakaba 1.27 @@Value:
5441     @@@@:0
5442     @@@ContentType: DISCore|Boolean
5443 wakaba 1.1 @@Type:
5444 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
5445 wakaba 1.1
5446     ElementTypeBinding:
5447     @Name: enDesc
5448     @ElementType:
5449     dis:Description
5450     @ShadowContent:
5451     @@lang:en
5452    
5453     ElementTypeBinding:
5454     @Name: PropDef
5455     @ElementType:
5456     dis:ResourceDef
5457     @ShadowContent:
5458     @@rdf:type:
5459     rdf:Property
5460 wakaba 1.27 @@For: =ManakaiDOM|all
5461 wakaba 1.1
5462     ElementTypeBinding:
5463     @Name: NamedParam
5464     @ElementType:
5465     dis:ResourceDef
5466     @ShadowContent:
5467     @@rdf:type:
5468     DISLang:MethodParameter
5469     @@DISPerl:isNamedParameter:1
5470    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24