/[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.51 - (hide annotations) (download)
Sun Jan 29 07:09:25 2006 UTC (19 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.50: +41 -5 lines
++ manakai/t/ChangeLog	29 Jan 2006 07:08:33 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* Makefile (dom-xml.t): New test.

++ manakai/lib/Message/Util/ChangeLog	29 Jan 2006 07:07:32 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (skipLines): Its code was incorrect.
	(createPCLiteral): Creates a |undef| keyword node
	for an |undef| value.  Tests added.

++ manakai/lib/Message/Util/DIS/ChangeLog	29 Jan 2006 07:08:09 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* Test.dis (assertDOMTreeEquals): |attributes| and |generalEntities|
	are implemented.

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

	* XMLParser.dis: Tests on default attributes and their |specified|
	attribute are added.

	* XDoctype.dis (createGeneralEntity): New method.
	(generalEntities): New attribute.
	(getGeneralEntityNode, setGeneralEntityNode): New methods.

	* Tree.dis (ManakaiDOMEntities): Removed.
	(ManakaiDOMEntityMap): New class.
	(ManakaiDOM:entity-reference-read-only): New configuration parameter.
	(createEntityReference): If there is a corresponding |Entity|
	node in the document type definition, then copies its
	subtree.

	* DOMXML.dis (Entity): Documentation updated.
	(publicId, systemId, notationName, xmlEncoding,
	xmlVersion): These attributes are now settable
	if |ManakaiDOM:ManakaiDOMLatest| mode.
	(hasReplacementTree): New attribute for |ManakaiDOM:ManakaiDOMLatest|
	mode.
	(ownerDocumentTypeDefinition): New attribute
	for |ManakaiDOM:ManakaiDOMLatest| mode.
	(isExpanded): New attribute for |ManakaiDOM:ManakaiDOMLatest| mode.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24