/[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.62 - (hide annotations) (download)
Tue Apr 4 12:35:15 2006 UTC (19 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.61: +19 -672 lines
++ manakai/lib/Message/Util/ChangeLog	4 Apr 2006 12:34:51 -0000
	* PerlCode.dis (PropDef): Removed (they were not used).
	(appendPackage, appendCodeFragment): Removed.
	(PCImplementation.createPerl* factoty methods): Removed.
	(setSubNode, setOverloadSub): Removed.
	(Node setter attributes): They no longer call |adoptNode|
	method.
	(PCImplementation): Don't inherit |dx:ManakaiDefaultExceptionHandler|.
	(PCException): Removed.

	* Grove.dis (destroy): Threshold value experimentally changed.

2006-04-04  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	4 Apr 2006 12:30:15 -0000
	* Document.dis (adoptNode test): Documents were
	made by different documents.

2006-04-04  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24