/[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.46 - (hide annotations) (download)
Sun Dec 18 13:21:47 2005 UTC (19 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.45: +72 -10 lines
++ manakai/lib/Message/Util/ChangeLog	18 Dec 2005 13:21:17 -0000
2005-12-18  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCDocument.createPerlSub): New method.

	* Makefile: Rules to make |DIS/DPG.pm| added.

2005-12-18  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCExpression.stringify): More operators supported.
	(PCDocument.createPCStatement): New method.

++ manakai/lib/Message/Util/DIS/ChangeLog	18 Dec 2005 13:11:01 -0000
2005-12-18  Wakaba  <wakaba@suika.fam.cx>

	* DPG.dis: New module.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24