/[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.48 - (hide annotations) (download)
Wed Dec 28 03:50:17 2005 UTC (19 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.47: +71 -3 lines
++ manakai/lib/Message/Util/ChangeLog	28 Dec 2005 03:36:58 -0000
2005-12-27  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCReference): New interface.

++ manakai/lib/Message/Util/DIS/ChangeLog	28 Dec 2005 03:49:57 -0000
2005-12-28  Wakaba  <wakaba@suika.fam.cx>

	* DPG.dis (plCodeFragment): Pushes |pop @ch| rather
	than |$ch| if an acception clause follows to a code block
	generated from a child match statement so that tokenizer
	does do the correct thing.  Support for |builtin:nestedBlockAsText|
	special rule is removed.  |pg:ifTrueStatement| is
	supported.  |pg:returnStatement| is supported.

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

	* DPG.dis (VALIDITY_ERR): New error code.
	($merge_adjacent_range): New subfunction.  Adjacent character
	ranges are now merged so that |if| conditions in
	scanner methods are simplified.
	($array_uniq): New subfunction.  Filters states so that
	state number don't explode.
	(plCodeFragment): Now a DPG parser can have more than
	one tokenizer.  The |pg:qMatch| rvalue is supported.
	(DPGMatchStatementElement): The match statement
	now accepts attributes.
	(DPGRuleRefStatementElement): The ruleref statement
	now accepts attributes.
	(AttributeSpecificationList): The attribute specification
	now accepts a |NAME| as an attribute value as well
	as |STRING|s.
	(CodeBlock): The |pg:qLexmodeStatement| is supported.
	(lexmode.default): |QKEYWORD| token type is added.
	(ErrDef): Errors |unique-lexmode-name-error|, |rule-not-defined-error|,
	|lexmode-not-defined-error| and properties added.

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

	* DPG.dis (dpgGetAttributeList): New method.
	(plCodeFragment): |:terminator?| option for a match
	block is supported.  |pg:matchElseBlock| is implemented.

++ manakai/lib/Message/DOM/ChangeLog	28 Dec 2005 03:36:24 -0000
2005-12-28  Wakaba  <wakaba@suika.fam.cx>

	* XMLParser.dis: Some modifications made.

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

	* DOMLS.dis (PARSE_ERR, SERIALIZE_ERR): They are now a
	global named resource.

	* Makefile: Rules to make |XMLParser.pm| is added.

	* XMLParser.dis: New file.

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

	* DOMCore.dis (ManakaiDOMError._FORMATTER_PACKAGE_): Error
	message formatter can now vary by error types.
	(DOMLocator.utf32Offset): New (manakai extended) attribute.

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.48 $Date: 2005/12/24 07:27:13 $
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 wakaba 1.47 @@Name: clearPerlName
1880     @@enDesc:
1881     Removes all Perl name associated to the <IF::PerlSub>.
1882     @@Return:
1883     @@@PerlDef:
1884     __DEEP{
1885     $self-><M::Element.removeAttributeNS> (<Q::pc:>, 'localName');
1886     }__;
1887    
1888     @Method:
1889 wakaba 1.35 @@Name: addPerlOperator
1890     @@enDesc:
1891     Adds an operator overloaded by the method.
1892     @@Param:
1893     @@@Name: op
1894     @@@Type: DOMString
1895     @@@enDesc: The operator to add.
1896     @@Return:
1897     @@@PerlDef:
1898     __DEEP{
1899     __CODE{addNameListAttr::
1900     $node => {$self},
1901     $attrName => 'operator',
1902     $newName => {$op},
1903     }__;
1904     }__;
1905    
1906     @Method:
1907     @@Name: getPerlOperatorList
1908     @@enDesc:
1909     Returns a list of operators of the subroutine.
1910     @@Return:
1911     @@@Type: DISPerl|ARRAY||ManakaiDOM|all
1912     @@@enDesc:
1913     An unordered snapshot list of operators.
1914     @@@PerlDef:
1915     __DEEP{
1916     __CODE{getNameListAttr::
1917     $node => {$self},
1918     $attrName => 'operator',
1919     $result => {$r},
1920     }__;
1921     }__;
1922    
1923     @Method:
1924     @@Name: hasPerlOperator
1925     @@enDesc:
1926     Returns whether the subroutine has an operator or not.
1927     @@Param:
1928     @@@Name: op
1929     @@@Type: DOMString
1930     @@@enDesc: The operator.
1931     @@Return:
1932     @@@Type: idl|boolean||ManakaiDOM|all
1933     @@@PerlDef:
1934     __DEEP{
1935     my $l;
1936     __CODE{getNameListAttr::
1937     $node => {$self},
1938     $attrName => 'operator',
1939     $result => {$l},
1940     }__;
1941     F: for (@$l) {
1942     if ($_ eq $op) {
1943     $r = true;
1944     last F;
1945     }
1946     }
1947     }__;
1948    
1949     @ATTR:
1950 wakaba 1.6 @@Name: prototype
1951 wakaba 1.35 @@ATTRQName: pc|prototype
1952 wakaba 1.6 @@enDesc:
1953     The prototype of this subroutine.
1954 wakaba 1.35 @@ReflectCDATA:
1955 wakaba 1.6 @@Get:
1956     @@@nullCase:
1957     @@@@enDesc:
1958     No prototype is set.
1959     @@Set:
1960     @@@nullCase:
1961     @@@@enDesc:
1962     No prototype declaration.
1963 wakaba 1.42
1964     @@Test:
1965     @@@ForCheck: ManakaiDOM|ForClass
1966     @@@enDesc:
1967     Getting value after setting empty value must return an empty string.
1968     @@@PerlDef:
1969     my $impl = <Class::ManakaiPCImplementation>->_new;
1970     my $sub = $impl-><M::PCImplementation.createPerlSub> ("sub_name");
1971     $test->assert_not_null ($sub);
1972    
1973     $sub-><AS::PerlSub.prototype> ('');
1974     $test->assert_string (actual_value => $sub-><AG::PerlSub.prototype>,
1975     expected_value => '');
1976     $test->assert_true ($sub->stringify =~ /^sub sub_name \(\)/);
1977 wakaba 1.6
1978 wakaba 1.4 @ToStringMethod:
1979     @@Return:
1980 wakaba 1.35 @@@Type: DOMString
1981 wakaba 1.4 @@@enDesc:
1982     Perl code.
1983     @@@PerlDef:
1984 wakaba 1.35 __DEEP{
1985     $r = q<sub>;
1986     my $nm = $self-><M::PerlSub.getPerlNameList>;
1987     $r .= q< > . $nm->[0] if @$nm;
1988 wakaba 1.42 if ($self-><M::Element.hasAttributeNS> (<Q::pc:>, 'prototype')) {
1989     $r .= q< (> . $self-><AG::PerlSub.prototype> . q<)>;
1990     }
1991 wakaba 1.35 $r .= qq< {\n>;
1992     for my $child (@{$self-><AG::Node.childNodes>}) {
1993     $r .= $child->stringify;
1994     }
1995     $r .= qq<}\n>;
1996     }__;
1997 wakaba 1.14
1998     @NumValMethod:
1999     @@Return:
2000 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2001 wakaba 1.14 @@@PerlDef:
2002 wakaba 1.35 __DEEP{
2003     $r = 0 + $self-><AG::Node.lastChild>;
2004     }__;
2005 wakaba 1.47 ##PerlSub
2006 wakaba 1.1
2007 wakaba 1.42 ElementTypeBinding:
2008     @Name: Test
2009     @ElementType:
2010     dis:ResourceDef
2011     @ShadowContent:
2012     @@rdf:type: test|StandaloneTest
2013    
2014 wakaba 1.5 XParamDef:
2015     @QName: parentNode
2016     @enDesc:
2017     Parent node.
2018    
2019     XParamDef:
2020     @QName: childNode
2021     @enDesc:
2022     Child node.
2023    
2024 wakaba 1.35 IFClsETDef:
2025 wakaba 1.25 @IFQName: PerlUnparsedCode
2026 wakaba 1.35 @CQName: ManakaiPCUnparsedCode
2027     @ETQName: pc|unparsed
2028 wakaba 1.25
2029     @IFISA: PerlCode
2030 wakaba 1.35 @CISA: ManakaiPCCode
2031 wakaba 1.25
2032 wakaba 1.1 @enDesc:
2033     Unparsed Perl code fragments.
2034 wakaba 1.5
2035 wakaba 1.35 @ATTR:
2036 wakaba 1.5 @@Name: sourceFile
2037 wakaba 1.35 @@ATTRQName: pc|sourceFile
2038 wakaba 1.5 @@enDesc:
2039     The source file name of this fragment.
2040 wakaba 1.35 @@ReflectCDATA:
2041 wakaba 1.5 @@Get:
2042     @@@enDesc:
2043     Any string identifying the source.
2044     @@@nullCase:
2045     @@@@enDesc: No source file name is set.
2046     @@Set:
2047     @@@nullCase:
2048     @@@@enDesc: No (or unknown) source file.
2049    
2050 wakaba 1.35 @ATTR:
2051 wakaba 1.5 @@Name: sourceLine
2052 wakaba 1.35 @@ATTRQName: pc|sourceLine
2053 wakaba 1.5 @@enDesc:
2054     Source file line number of the first line of this fragment.
2055 wakaba 1.35 @@ReflectCDATA:
2056 wakaba 1.5 @@Get:
2057     @@Set:
2058 wakaba 1.6
2059     @ToStringMethod:
2060     @@Return:
2061 wakaba 1.35 @@@Type: DOMString
2062 wakaba 1.6 @@@enDesc:
2063     Perl code.
2064     @@@PerlDef:
2065 wakaba 1.35 __DEEP{
2066 wakaba 1.39 $r = "\x0A" . $self-><AG::Node.textContent> . "\x0A";
2067 wakaba 1.35 my $file = $self-><AG::PerlCode.fileNode>;
2068 wakaba 1.38 my $src_file = $file ? $file-><AG::PerlFile.sourceFile>
2069     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
2070 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
2071     -><AG::Document.domConfig>
2072     -><M::DOMCore:DOMConfiguration.getParameter>
2073     (<Q::pc:line>)) {
2074     my $nxt_cnum = $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
2075     $r = sprintf qq<\n#line %d "%s [u] (Chunk #%d)"%s>.
2076     qq<#line 1 "%s [/u] (Chunk #%d)"\n>,
2077 wakaba 1.35 $self-><AG::PerlUnparsedCode.sourceLine> || 1,
2078     $self-><AG::PerlUnparsedCode.sourceFile> || $src_file,
2079     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
2080 wakaba 1.39 $r,
2081 wakaba 1.35 $src_file,
2082     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
2083 wakaba 1.39 }
2084 wakaba 1.35 }__;
2085 wakaba 1.1 ##PerlUnparsedCode
2086    
2087 wakaba 1.35 IFClsETDef:
2088 wakaba 1.25 @IFQName: PerlInlineUnparsedCode
2089 wakaba 1.35 @CQName: ManakaiPCInlineUnparsedCode
2090     @ETQName: pc|inlineUnparsed
2091 wakaba 1.25
2092     @IFISA: PerlCode
2093 wakaba 1.35 @CISA: ManakaiPCCode
2094 wakaba 1.25
2095 wakaba 1.6 @enDesc:
2096 wakaba 1.36 Unparsed Perl inline code fragments.
2097 wakaba 1.6
2098 wakaba 1.36 @ToStringMethod:
2099 wakaba 1.9 @@Return:
2100 wakaba 1.36 @@@Type: DOMString
2101     @@@enDesc:
2102     Perl code.
2103 wakaba 1.35 @@@disDef:
2104     @@@@DISPerl:cloneCode: DOMCore|ManakaiDOMNode.textContent.get
2105 wakaba 1.36 ##PCInlineUnparsedCode
2106 wakaba 1.6
2107 wakaba 1.35 IFClsETDef:
2108 wakaba 1.44 @IFQName: PCNumberLiteral
2109     @CQName: ManakaiPCNumberLiteral
2110     @ETQName: pc|numberLiteral
2111    
2112     @IFISA: PerlCode
2113     @CISA: ManakaiPCCode
2114    
2115     @enDesc:
2116     A <IF::PCNumberLiteral> object represents a Perl number literal.
2117     The <A::Node.textContent> of a <IF::PCNumberLiteral> object
2118     is a Perl source code representation of the number for the object.
2119    
2120     @ToStringMethod:
2121     @@Return:
2122     @@@Type: DOMString
2123     @@@PerlDef:
2124     __DEEP{
2125     $r = $self-><AG::Node.textContent>;
2126     }__;
2127     ##PCNumberLiteral
2128    
2129     IFClsETDef:
2130 wakaba 1.25 @IFQName: PerlStringLiteral
2131 wakaba 1.35 @CQName: ManakaiPCPerlStringLiteral
2132     @ETQName: pc|stringLiteral
2133 wakaba 1.25
2134     @IFISA: PerlCode
2135 wakaba 1.35 @CISA: ManakaiPCCode
2136 wakaba 1.25
2137 wakaba 1.6 @enDesc:
2138 wakaba 1.36 Perl string literal.
2139 wakaba 1.6
2140 wakaba 1.14 @NumValMethod:
2141     @@Return:
2142 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2143 wakaba 1.14 @@@enDesc:
2144     Numeric value of the Perl code.
2145     @@@PerlDef:
2146 wakaba 1.35 __DEEP{
2147     $r = 0 + $self-><AG::Node.textContent>;
2148     }__;
2149 wakaba 1.14
2150 wakaba 1.6 @ToStringMethod:
2151     @@Return:
2152 wakaba 1.35 @@@Type: DOMString
2153 wakaba 1.6 @@@enDesc:
2154     Perl code.
2155     @@@PerlDef:
2156 wakaba 1.35 __DEEP{
2157     $r = $self-><AG::Node.textContent>;
2158     $r =~ s/(['\\])/\\$1/g;
2159     $r = q<'> . $r . q<'>;
2160     }__;
2161 wakaba 1.6 ##PerlStringLiteral
2162    
2163 wakaba 1.35 IFClsETDef:
2164 wakaba 1.41 @IFQName: PCList
2165     @CQName: ManakaiPCList
2166     @ETQName: pc|list
2167    
2168     @IFISA: PerlCode
2169 wakaba 1.42 @CISA: ManakaiPCCode
2170 wakaba 1.41
2171     @enDesc:
2172     A <IF::PCList> is a Perl list, i.e. <CHAR::COMMA> separated
2173     list of values.
2174    
2175     @Method:
2176     @@Name: item
2177     @@enDesc:
2178     Returns the <P::index>th item in the list.
2179     @@Param:
2180     @@@Name: index
2181     @@@Type: unsignedLong
2182     @@@enDesc:
2183     The ordinal index of the item.
2184     @@Return:
2185     @@@Type: PerlCodeInlines
2186     @@@enDesc:
2187     The <P::index>th item in the list.
2188     @@@nullCase:
2189     @@@@enDesc:
2190     Either <P::index> is negative or the <P::index> is
2191     greater than the number of the items in the list.
2192     @@@PerlDef:
2193     __DEEP{
2194     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index);
2195     }__;
2196    
2197     @Attr:
2198     @@Name: length
2199     @@enDesc:
2200     The number of items in the list.
2201     @@Type: unsignedLong
2202     @@Get:
2203     @@@PerlDef:
2204     __DEEP{
2205     $r = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2206     }__;
2207    
2208     @ToStringMethod:
2209     @@Return:
2210     @@@Type: DOMString
2211     @@@enDesc:
2212     Perl code.
2213     @@@PerlDef:
2214     __DEEP{
2215     my @r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2216     $r = '(' . join (', ', @r) . ')';
2217     }__;
2218     ##PCList
2219    
2220     IFClsETDef:
2221     @IFQName: PCArrayRefLiteral
2222     @CQName: ManakaiPCArrayRefLiteral
2223 wakaba 1.44 @ETQName: pc|arrayRefLiteral
2224 wakaba 1.41
2225     @IFISA: PerlCode
2226 wakaba 1.42 @CISA: ManakaiPCCode
2227 wakaba 1.41
2228     @enDesc:
2229     A <IF::PCArrayRefLiteral> is a Perl array reference literal.
2230    
2231     @Method:
2232     @@Name: item
2233     @@enDesc:
2234     Returns the <P::index>th item in the list.
2235     @@Param:
2236     @@@Name: index
2237     @@@Type: unsignedLong
2238     @@@enDesc:
2239     The ordinal index of the item.
2240     @@Return:
2241     @@@Type: PerlCodeInlines
2242     @@@enDesc:
2243     The <P::index>th item in the list.
2244     @@@nullCase:
2245     @@@@enDesc:
2246     Either <P::index> is negative or the <P::index> is
2247     greater than the number of the items in the list.
2248     @@@PerlDef:
2249     __DEEP{
2250     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index);
2251     }__;
2252    
2253     @Attr:
2254     @@Name: length
2255     @@enDesc:
2256     The number of items in the list.
2257     @@Type: unsignedLong
2258     @@Get:
2259     @@@PerlDef:
2260     __DEEP{
2261     $r = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2262     }__;
2263    
2264     @ToStringMethod:
2265     @@Return:
2266     @@@Type: DOMString
2267     @@@enDesc:
2268     Perl code.
2269     @@@PerlDef:
2270     __DEEP{
2271     my @r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2272     $r = '[' . join (', ', @r) . ']';
2273     }__;
2274     ##PCArrayRefLiteral
2275    
2276     IFClsETDef:
2277     @IFQName: PCHashRefLiteral
2278     @CQName: ManakaiPCHashRefLiteral
2279 wakaba 1.44 @ETQName: pc|hashRefLiteral
2280 wakaba 1.41
2281     @IFISA: PerlCode
2282 wakaba 1.42 @CISA: ManakaiPCCode
2283 wakaba 1.41
2284     @enDesc:
2285     A <IF::PCHashRefLiteral> is a Perl hash reference literal.
2286    
2287     @Method:
2288     @@Name: key
2289     @@enDesc:
2290     Returns the <P::index>th key in the list.
2291    
2292     {NOTE:: Although the order of key-value pairs is
2293     preserved in the object, it is not preserved
2294     in Perl source codes and in Perl language.
2295     }
2296     @@Param:
2297     @@@Name: index
2298     @@@Type: unsignedLong
2299     @@@enDesc:
2300     The ordinal index of the key.
2301     @@Return:
2302     @@@Type: PerlCodeInlines
2303     @@@enDesc:
2304     The <P::index>th key in the list.
2305     @@@nullCase:
2306     @@@@enDesc:
2307     Either <P::index> is negative or the <P::index> is
2308     greater than the number of the keys in the list.
2309     @@@PerlDef:
2310     __DEEP{
2311     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index * 2);
2312     }__;
2313    
2314     @Method:
2315     @@Name: value
2316     @@enDesc:
2317     Returns the <P::index>th value in the list.
2318    
2319     {NOTE:: Although the order of key-value pairs is
2320     preserved in the object, it is not preserved
2321     in Perl source codes and in Perl language.
2322     }
2323     @@Param:
2324     @@@Name: index
2325     @@@Type: unsignedLong
2326     @@@enDesc:
2327     The ordinal index of the value.
2328     @@Return:
2329     @@@Type: PerlCodeInlines
2330     @@@enDesc:
2331     The <P::index>th value in the list.
2332     @@@nullCase:
2333     @@@@enDesc:
2334     Either <P::index> is negative or the <P::index> is
2335     greater than the number of the values in the list.
2336    
2337     {NOTE:: <MATH::<A::PCHashRefLiteral.length> - 1>th
2338     value might not be found.
2339     }
2340     @@@PerlDef:
2341     __DEEP{
2342     $r = $self-><AG::Node.childNodes>-><M::NodeList.item> ($index * 2 + 1);
2343     }__;
2344    
2345     @Attr:
2346     @@Name: length
2347     @@enDesc:
2348     The number of key-value pairs in the list.
2349     @@Type: unsignedLong
2350     @@Get:
2351     @@@PerlDef:
2352     __DEEP{
2353     my $length = $self-><AG::Node.childNodes>-><AG::NodeList.length>;
2354     $r = int ($length / 2) + ($length % 2);
2355     }__;
2356    
2357     @Method:
2358     @@Name: setNamedItem
2359     @@enDesc:
2360     Set a named item.
2361     @@Param:
2362     @@@Name: key
2363     @@@Type: DOMString
2364     @@@enDesc:
2365     The key.
2366     @@Param:
2367     @@@Name: value
2368     @@@Type: PerlCodeInlines
2369     @@@enDesc:
2370     The value.
2371     @@Return:
2372     @@@PerlDef:
2373     __DEEP{
2374     my @children = @{$self-><AG::Node.childNodes>};
2375     R: {
2376     while (@children) {
2377     my $ckey = shift @children;
2378     my $cval = shift @children;
2379     if ($ckey-><AG::Node.textContent> eq $key) {
2380     $self-><M::Node.replaceChild> ($value, $cval);
2381     last R;
2382     }
2383     }
2384    
2385     $self-><M::Node.appendChild>
2386     ($self-><AG::Node.ownerDocument>
2387     -><M::Document.createElementNS>
2388     (<Q::pc:>, 'stringLiteral'))
2389     -><AS::Node.textContent> ($key);
2390     $self-><M::Node.appendChild> ($value);
2391     } # R
2392     }__;
2393    
2394     @ToStringMethod:
2395     @@Return:
2396     @@@Type: DOMString
2397     @@@enDesc:
2398     Perl code.
2399     @@@PerlDef:
2400     __DEEP{
2401     my %r = map {$_->stringify} @{$self-><AG::Node.childNodes>};
2402     ## Different values with same key are not preserved.
2403     $r = '{' . join (', ', map {$_ => $r{$_}}
2404     sort {$a cmp $b} keys %r) . '}';
2405     }__;
2406     ##PCHashRefLiteral
2407    
2408     ResourceDef:
2409     @QName: unsignedLong
2410     @AliasFor: idl|unsignedLong||ManakaiDOM|all
2411     @For: ManakaiDOM|DOM
2412    
2413     IFClsETDef:
2414 wakaba 1.25 @IFQName: PerlTokens
2415 wakaba 1.35 @CQName: ManakaiPCTokens
2416     @ETQName: pc|tokens
2417 wakaba 1.12
2418 wakaba 1.25 @IFISA: PerlCode
2419 wakaba 1.35 @CISA: ManakaiPCCode
2420 wakaba 1.25
2421 wakaba 1.6 @enDesc:
2422 wakaba 1.36 Unparsed Perl inline code fragments.
2423 wakaba 1.6
2424     @ToStringMethod:
2425     @@Return:
2426 wakaba 1.43 @@@Type: DOMString
2427 wakaba 1.6 @@@PerlDef:
2428 wakaba 1.35 __DEEP{
2429     $r = $self-><AG::Node.textContent>;
2430     }__;
2431     ##PCTokens
2432 wakaba 1.6
2433 wakaba 1.35 IFClsETDef:
2434 wakaba 1.25 @IFQName: PerlAtom
2435 wakaba 1.35 @CQName: ManakaiPCAtom
2436     @ETQName: pc|atom
2437 wakaba 1.25
2438     @IFISA: PerlCode
2439 wakaba 1.35 @CISA: ManakaiPCTokens
2440 wakaba 1.25
2441 wakaba 1.6 @enDesc:
2442     Unparsed Perl atomic code fragments (such as numeric literal).
2443    
2444 wakaba 1.14 @NumValMethod:
2445     @@Return:
2446 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
2447 wakaba 1.14 @@@enDesc:
2448     Numeric value of the Perl code.
2449     @@@PerlDef:
2450 wakaba 1.35 __DEEP{
2451     $r = 0 + $self-><AG::Node.textContent>;
2452     }__;
2453 wakaba 1.9
2454 wakaba 1.6 @ToStringMethod:
2455     @@Return:
2456 wakaba 1.35 @@@Type: DOMString
2457 wakaba 1.6 @@@enDesc:
2458     Perl code.
2459     @@@PerlDef:
2460 wakaba 1.35 __DEEP{
2461     $r = $self-><AG::Node.textContent>;
2462     }__;
2463 wakaba 1.6 ##PerlAtom
2464    
2465 wakaba 1.35 IFClsETDef:
2466 wakaba 1.25 @IFQName: PerlVariable
2467 wakaba 1.35 @CQName: ManakaiPCVariable
2468     @ETQName: pc|variable
2469 wakaba 1.25
2470     @IFISA: PerlCode
2471 wakaba 1.35 @CISA: ManakaiPCCode
2472 wakaba 1.25
2473 wakaba 1.6 @enDesc:
2474     Unparsed Perl variable.
2475     \
2476     {NOTE:: Future version of the implementation may
2477     support to specify array index or hash key.
2478     \
2479 wakaba 1.36 }
2480 wakaba 1.6
2481 wakaba 1.35 @ATTR:
2482 wakaba 1.6 @@Name: variableType
2483 wakaba 1.35 @@ATTRQName: pc|variableType
2484 wakaba 1.6 @@enDesc:
2485     Perl variable type (<CODE::$>, <CODE::@>, <CODE::%>,
2486     <CODE::&> or empty string).
2487 wakaba 1.35 @@ReflectCDATA:
2488 wakaba 1.6 @@Get:
2489     @@Set:
2490    
2491 wakaba 1.35 @ATTR:
2492 wakaba 1.6 @@Name: packageName
2493 wakaba 1.35 @@ATTRQName: pc|packageName
2494 wakaba 1.6 @@enDesc:
2495     The name of the package to which this variable belongs.
2496 wakaba 1.35 @@ReflectCDATA:
2497 wakaba 1.6 @@Get:
2498     @@@nullCase:
2499     @@@@enDesc:
2500     This package belongs to the current package or
2501     does not belong to any package.
2502     @@Set:
2503     @@@nullCase:
2504     @@@@enDesc:
2505     This package belongs to the current package or
2506     does not belong to any package.
2507    
2508 wakaba 1.35 @ATTR:
2509 wakaba 1.36 @@Name: pcLocalName
2510 wakaba 1.35 @@ATTRQName: pc|localName
2511 wakaba 1.6 @@enDesc:
2512     The local variable name.
2513 wakaba 1.35 @@ReflectCDATA:
2514 wakaba 1.6 @@Get:
2515     @@Set:
2516    
2517 wakaba 1.35 @ATTR:
2518 wakaba 1.6 @@Name: variableScope
2519 wakaba 1.35 @@ATTRQName: pc|variableScope
2520 wakaba 1.6 @@enDesc:
2521     Scope modifier (<CODE::my> or <CODE::our> or <CODE::local>).
2522 wakaba 1.35 @@ReflectCDATA:
2523 wakaba 1.6 @@Get:
2524     @@@nullCase:
2525     @@@@enDesc:
2526     This variable does not have scope modifier.
2527     @@Set:
2528     @@@nullCase:
2529     @@@@enDesc:
2530     This variable does not have scope modifier.
2531    
2532     @ToStringMethod:
2533     @@Return:
2534 wakaba 1.35 @@@Type: DOMString
2535 wakaba 1.6 @@@enDesc:
2536     Perl code.
2537     @@@PerlDef:
2538 wakaba 1.35 __DEEP{
2539     my $t = $self-><AG::PerlVariable.variableScope>;
2540     $r .= $t . ' ' if length $t;
2541     $r .= $self-><AG::PerlVariable.variableType>;
2542     my $v = $self-><AG::PerlVariable.packageName>;
2543     $r .= $v . '::' if length $v;
2544     $r .= $self-><AG::PerlVariable.pcLocalName>;
2545     $v = $self-><AG::PerlVariable.hashKey>;
2546     if ($t eq '$' and length $v) {
2547     $v =~ s/(['\\])/\\$1/g;
2548     $r .= q<{'> . $v . q<'}>;
2549     }
2550     }__;
2551 wakaba 1.6
2552 wakaba 1.35 @ATTR:
2553 wakaba 1.6 @@Name: hashKey
2554 wakaba 1.35 @@ATTRQName: pc|hashKey
2555 wakaba 1.6 @@enDesc:
2556     The key for hash.
2557     \
2558     {NOTE:: Using Perl code for key is not supported in the current
2559     version of the implementation.
2560     \
2561     }
2562 wakaba 1.35 @@ReflectCDATA:
2563 wakaba 1.6 @@Get:
2564     @@@nullCase:
2565     @@@@enDesc:
2566     This variable is not for hash value access.
2567     @@Set:
2568     @@@nullCase:
2569     @@@@enDesc:
2570     This variable is not for hash value access.
2571 wakaba 1.15 ##PerlVariable
2572 wakaba 1.6
2573 wakaba 1.25 IFClsDef:
2574     @IFQName: PerlCodeUnits
2575 wakaba 1.35 @CQName: ManakaiPCCodeUnits
2576 wakaba 1.25
2577 wakaba 1.35 @CISA: ManakaiPCCode
2578 wakaba 1.25
2579 wakaba 1.6 @enDesc:
2580     A base class implemented by both inline container and
2581     block-level container.
2582    
2583     @Attr:
2584     @@Name: length
2585     @@enDesc:
2586     The number of child code fragments.
2587 wakaba 1.35 @@Type: idl|unsignedLong||ManakaiDOM|all
2588 wakaba 1.6 @@Get:
2589     @@@PerlDef:
2590 wakaba 1.35 __DEEP{
2591     $r = @{$self-><AG::Node.childNodes>};
2592     }__;
2593 wakaba 1.6
2594     @Method:
2595     @@Name: appendStringLiteral
2596     @@enDesc:
2597     Appends a Perl string literal (<CODE::q>).
2598     @@Param:
2599     @@@Name: stringArg
2600 wakaba 1.35 @@@Type: DOMString
2601 wakaba 1.6 @@@enDesc:
2602     A string.
2603     @@Return:
2604 wakaba 1.35 @@@Type: PerlStringLiteral
2605 wakaba 1.6 @@@enDesc:
2606     The newly created Perl string literal object.
2607     @@@PerlDef:
2608 wakaba 1.35 __DEEP{
2609     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2610     (<Q::pc:>, 'stringLiteral');
2611     $r-><AS::Node.textContent> ($stringArg);
2612     $self-><M::Node.appendChild> ($r);
2613     }__;
2614 wakaba 1.6
2615     @Method:
2616 wakaba 1.41 @@Name: appendNewPCLiteral
2617     @@enDesc:
2618     Creates a <IF::PCLiteral> object and appends it to the node.
2619     @@Param:
2620     @@@Name: value
2621     @@@Type: DISPerl|Any
2622     @@@enDesc: The value.
2623     @@Return:
2624     @@@Type: PerlCode
2625     @@@enDesc:
2626     The newly created object.
2627     @@@PerlDef:
2628     __DEEP{
2629     $r = $self-><AG::Node.ownerDocument>
2630     -><M::PCDocument.createPCLiteral> ($value);
2631     $self-><M::Node.appendChild> ($r);
2632     }__;
2633    
2634     @Method:
2635 wakaba 1.44 @@Name: appendNewPCNumberLiteral
2636     @@enDesc:
2637     Creates a <IF::PCNumberLiteral> object and appends it to the node.
2638     @@Param:
2639     @@@Name: value
2640     @@@Type: DISPerl|NumberValue
2641     @@@enDesc:
2642     The value.
2643     @@Return:
2644     @@@Type: PCNumberLiteral
2645     @@@enDesc:
2646     The newly created node.
2647     @@@PerlDef:
2648     __DEEP{
2649     $r = $self-><AG::Node.ownerDocument>
2650     -><M::PCDocument.createPCNumberLiteral> ($value);
2651     $self-><M::Node.appendChild> ($r);
2652     }__;
2653    
2654     @Method:
2655 wakaba 1.6 @@Name: appendAtom
2656     @@enDesc:
2657     Appends a Perl atomic code fragment.
2658     @@Param:
2659     @@@Name: codeArg
2660 wakaba 1.35 @@@Type: DOMString
2661 wakaba 1.6 @@@enDesc:
2662     An atom.
2663     @@Return:
2664 wakaba 1.35 @@@Type: PerlAtom
2665 wakaba 1.6 @@@enDesc:
2666     The newly created Perl code object.
2667     @@@PerlDef:
2668 wakaba 1.35 __DEEP{
2669     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2670     (<Q::pc:>, 'atom');
2671     $r-><AS::Node.textContent> ($codeArg);
2672     $self-><M::Node.appendChild> ($r);
2673     }__;
2674 wakaba 1.6
2675     @Method:
2676     @@Name: appendBare
2677     @@enDesc:
2678     Appends a Perl bare code fragment.
2679     @@Param:
2680     @@@Name: codeArg
2681 wakaba 1.35 @@@Type: DOMString
2682 wakaba 1.6 @@@enDesc:
2683 wakaba 1.7 An bare code.
2684 wakaba 1.6 @@Return:
2685 wakaba 1.35 @@@Type: PerlBare
2686 wakaba 1.6 @@@enDesc:
2687     The newly created Perl code object.
2688     @@@PerlDef:
2689 wakaba 1.35 __DEEP{
2690     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2691     (<Q::pc:>, 'tokens');
2692     $r-><AS::Node.textContent> ($codeArg);
2693     $self-><M::Node.appendChild> ($r);
2694     }__;
2695 wakaba 1.11
2696     @Method:
2697 wakaba 1.44 @@Name: appendNewPCVariable
2698     @@enDesc:
2699     Creates a variable object and appends it to the children list of
2700     the node.
2701     @@Param:
2702     @@@Name: variableTypeArg
2703     @@@Type: DOMString
2704     @@@enDesc:
2705     The variable type prefix such as <Perl::$>, if any, or an empty string.
2706     @@Param:
2707     @@@Name: packageNameArg
2708     @@@Type: DOMString
2709     @@@enDesc:
2710     The name of the package to which the variable belongs.
2711     @@@nullCase:
2712     @@@@enDesc:
2713     The variable does not belong to any package or belongs
2714     to the current package.
2715     @@Param:
2716     @@@Name: localNameArg
2717     @@@Type: DOMString
2718     @@@enDesc:
2719     The local part of the variable name.
2720     @@Return:
2721     @@@Type: PerlVariable
2722     @@@enDesc:
2723     The newly created variable object.
2724     @@@PerlDef:
2725     __DEEP{
2726     $r = $self-><AG::Node.ownerDocument>
2727     -><M::PCDocument.createPCVariable>
2728     ($variableTypeArg, $packageNameArg, $localNameArg);
2729     $self-><M::Node.appendChild> ($r);
2730     }__;
2731    
2732     @Method:
2733     @@Name: appendNewPCDereference
2734     @@enDesc:
2735     Creates a <IF::PCDereference> object and appends it to the child
2736     node list of the node.
2737     @@Param:
2738     @@@Name: variableTypeArg
2739     @@@Type: DOMString
2740     @@@enDesc:
2741     The type of the referenced value, such as <Perl::$>.
2742     @@Return:
2743     @@@Type: PCDereference
2744     @@@enDesc:
2745     The newly created element node.
2746     @@@PerlDef:
2747     __DEEP{
2748     $r = $self-><AG::Node.ownerDocument>
2749 wakaba 1.48 -><M::PCDocument.createPCDereference>
2750     ($variableTypeArg);
2751     $self-><M::Node.appendChild> ($r);
2752     }__;
2753    
2754     @Method:
2755     @@Name: appendNewPCReference
2756     @@enDesc:
2757     Creates a <IF::PCReference> object and appends it to the child
2758     node list of the node.
2759     @@Return:
2760     @@@Type: PCReference
2761     @@@enDesc:
2762     The newly created element node.
2763     @@@PerlDef:
2764     __DEEP{
2765     $r = $self-><AG::Node.ownerDocument>
2766     -><M::PCDocument.createPCReference>;
2767 wakaba 1.44 $self-><M::Node.appendChild> ($r);
2768     }__;
2769    
2770     @Method:
2771 wakaba 1.43 @@Name: appendNewPCExpression
2772     @@enDesc:
2773     Appends a newly created <IF::PCExpression> node.
2774     @@Param:
2775     @@@Name: operatorArg
2776     @@@Type: DOMString
2777     @@@enDesc:
2778     The operator of the expression.
2779     @@Return:
2780     @@@Type: PCExpression
2781     @@@enDesc:
2782     The newly created expression object.
2783     @@@PerlDef:
2784     __DEEP{
2785     $r = $self-><AG::Node.ownerDocument>
2786     -><M::PCDocument.createPCExpression> ($operatorArg);
2787     $self-><M::Node.appendChild> ($r);
2788     }__;
2789    
2790     @Method:
2791 wakaba 1.11 @@Name: appendNewAssignment
2792     @@enDesc:
2793     Appends a newly created <Class::ManakaiPerlAssign> object.
2794     @@Param:
2795     @@@Name: leftArg
2796 wakaba 1.35 @@@Type: PerlCode
2797 wakaba 1.11 @@@enDesc:
2798     A left hand side code fragment object.
2799     @@Param:
2800     @@@Name: rightArg
2801 wakaba 1.35 @@@Type: PerlCode
2802 wakaba 1.11 @@@enDesc:
2803     A right hand side code fragment object.
2804     @@Return:
2805 wakaba 1.36 @@@Type: PerlAssignment
2806 wakaba 1.11 @@@RaiseException:
2807     @@@@@:BAD_CHILD_ERR
2808     @@@@enDesc:
2809     An attempt is made to append a child
2810     that is not valid type.
2811     @@@RaiseException:
2812     @@@@@:IN_USE_NODE_ERR
2813     @@@@enDesc:
2814     An attempt is made to append a node that is
2815     already used elsewhere.
2816     @@@PerlDef:
2817 wakaba 1.35 for my $arg ([leftArg => $leftArg], [rightArg => $rightArg]) {
2818     if ({
2819     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
2820     inlineUnparsed => 1, variable => 1, stringLiteral => true,
2821 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
2822 wakaba 1.35 }->{$arg->[1]-><AG::Node.localName>}) {
2823     if ($arg->[1]-><AG::Node.parentNode>) {
2824     __EXCEPTION{IN_USE_NODE_ERR::
2825     pc:childNode => {$arg->[1]},
2826     MDOMX:param-name => {$arg->[0]},
2827     }__;
2828     }
2829     } else {
2830     __EXCEPTION{BAD_CHILD_ERR::
2831     pc:parentNode => {$self},
2832     pc:childNode => {$arg->[1]},
2833     MDOMX:param-name => {$arg->[0]},
2834     }__;
2835     }
2836     } # left/right
2837    
2838     __DEEP{
2839     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2840     (<Q::pc:>, 'assignment');
2841     $r-><AS::PerlAssignment.leftCode> ($leftArg);
2842     $r-><AS::PerlAssignment.rightCode> ($rightArg);
2843     $self-><M::Node.appendChild> ($r);
2844     }__;
2845 wakaba 1.43
2846     @Method:
2847 wakaba 1.44 @@Name: appendNewPCApply
2848     @@enDesc:
2849     Creates a <IF::PCApply> object and appends it to the children list
2850     of the node.
2851     @@Return:
2852     @@@Type: PCApply
2853     @@@enDesc: The newly created node.
2854     @@@PerlDef:
2855     __DEEP{
2856     $r = $self-><AG::Node.ownerDocument>-><M::PCDocument.createPCApply>;
2857     $self-><M::Node.appendChild> ($r);
2858     }__;
2859    
2860     @Method:
2861 wakaba 1.43 @@Name: appendNewPCFunctionCall
2862     @@enDesc:
2863     Appends a newly created <IF::PCFunctionCall> node.
2864     @@Param:
2865     @@@Name: packageArg
2866     @@@Type: DOMString
2867     @@@enDesc:
2868     The package name of the function.
2869     @@@nullCase:
2870     @@@@enDesc: No package name.
2871     @@Param:
2872     @@@Name: localNameArg
2873     @@@Type: DOMString
2874     @@@enDesc:
2875     The local part of the function name.
2876     @@Return:
2877     @@@Type: PCFunctionCall
2878     @@@enDesc:
2879     The newly created functin call object.
2880     @@@PerlDef:
2881     __DEEP{
2882     $r = $self-><AG::Node.ownerDocument>
2883     -><M::PCDocument.createPCFunctionCall>
2884     ($packageArg, $localNameArg);
2885     $self-><M::Node.appendChild> ($r);
2886     }__;
2887     ##PCCodeUnits
2888 wakaba 1.6
2889 wakaba 1.35 IFClsETDef:
2890 wakaba 1.25 @IFQName: PerlStatement
2891 wakaba 1.35 @CQName: ManakaiPCStatement
2892     @ETQName: pc|statement
2893 wakaba 1.25
2894     @IFISA: PerlCode
2895     @IFISA: PerlCodeInlines
2896 wakaba 1.35 @CISA: ManakaiPCCodeInlines
2897 wakaba 1.25
2898 wakaba 1.8 @enDesc:
2899 wakaba 1.36 Perl statements.
2900 wakaba 1.8
2901     @ToStringMethod:
2902     @@Return:
2903 wakaba 1.35 @@@Type: DOMString
2904 wakaba 1.8 @@@enDesc:
2905     Perl code.
2906     @@@PerlDef:
2907     $r = $self->SUPER::stringify;
2908 wakaba 1.16 $r .= ";\n" if length $r;
2909 wakaba 1.8 ##PerlStatement
2910 wakaba 1.6
2911 wakaba 1.35 IFClsETDef:
2912 wakaba 1.25 @IFQName: PerlCodeInlines
2913 wakaba 1.35 @CQName: ManakaiPCCodeInlines
2914     @ETQName: pc|inlineContainer
2915 wakaba 1.25
2916 wakaba 1.35 @CISA: ManakaiPCCodeUnits
2917 wakaba 1.25
2918 wakaba 1.6 @enDesc:
2919 wakaba 1.41 Perl inline code block.
2920 wakaba 1.6
2921     @Method:
2922     @@Name: appendCodeFragment
2923     @@enDesc:
2924 wakaba 1.35 Appends a <IF::PerlCode> object.
2925 wakaba 1.6 @@Param:
2926     @@@Name: codeArg
2927 wakaba 1.25 @@@Type: PerlCode
2928 wakaba 1.6 @@@enDesc:
2929     A code fragment object.
2930     @@Return:
2931     @@@RaiseException:
2932     @@@@@:BAD_CHILD_ERR
2933     @@@@enDesc:
2934     An attempt is made to append a child
2935     that is not a <Class::ManakaiPerlUnparsedCode>.
2936     @@@RaiseException:
2937     @@@@@:IN_USE_NODE_ERR
2938     @@@@enDesc:
2939     An attempt is made to append a node that is
2940     already used elsewhere.
2941     @@@PerlDef:
2942 wakaba 1.35 if ({
2943     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
2944     inlineUnparsed => 1, variable => 1, stringLiteral => true,
2945 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
2946 wakaba 1.35 }->{$codeArg-><AG::Node.localName>}) {
2947     if ($codeArg-><AG::Node.parentNode>) {
2948     __EXCEPTION{IN_USE_NODE_ERR::
2949     pc:childNode => {$codeArg},
2950     }__;
2951     }
2952     __DEEP{
2953     $self-><AG::Node.ownerDocument>
2954     -><M::Document.adoptNode> ($codeArg);
2955     $self-><M::Node.appendChild> ($codeArg);
2956     }__;
2957     } else {
2958     __EXCEPTION{BAD_CHILD_ERR::
2959     pc:parentNode => {$self},
2960     pc:childNode => {$codeArg},
2961     }__;
2962     }
2963 wakaba 1.6
2964     @Method:
2965     @@Name: appendCode
2966     @@enDesc:
2967     Appends an unparsed Perl code fragment.
2968     @@Param:
2969     @@@Name: codeArg
2970 wakaba 1.35 @@@Type: DOMString
2971 wakaba 1.6 @@@enDesc:
2972     An unparsed Perl code fragment.
2973     @@Return:
2974 wakaba 1.25 @@@Type: PerlInlineUnparsedCode
2975 wakaba 1.6 @@@enDesc:
2976     The newly created Perl code object.
2977     @@@PerlDef:
2978 wakaba 1.35 __DEEP{
2979     $r = $self-><AG::Node.ownerDocument>-><M::Document.createElementNS>
2980     (<Q::pc:>, 'inlineUnparsed');
2981     $r-><AS::Node.textContent> ($codeArg);
2982     $self-><M::Node.appendChild> ($r);
2983     }__;
2984 wakaba 1.6
2985     @ToStringMethod:
2986     @@Return:
2987 wakaba 1.35 @@@Type: DOMString
2988 wakaba 1.6 @@@enDesc:
2989     Perl code.
2990     @@@PerlDef:
2991 wakaba 1.35 __DEEP{
2992     my @child = @{$self-><AG::Node.childNodes>};
2993     for my $child (@child) {
2994     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
2995     $child-><AG::Node.localName> eq 'inlineContainer' and
2996     1 == @child) {
2997     $r .= '(' . $child->stringify . ')';
2998     } else {
2999     $r .= $child->stringify;
3000     }
3001     }
3002     }__;
3003     ##PCCodeInlines
3004 wakaba 1.6
3005 wakaba 1.35 IFClsETDef:
3006 wakaba 1.25 @IFQName: PerlBlock
3007 wakaba 1.44 @CQName: ManakaiPerlBlock
3008 wakaba 1.35 @ETQName: pc|block
3009 wakaba 1.25
3010     @IFISA: PerlCode
3011     @IFISA: PerlCodeStatements
3012 wakaba 1.35 @CISA: ManakaiPCCodeStatements
3013 wakaba 1.25
3014 wakaba 1.8 @enDesc:
3015 wakaba 1.36 Perl block-level code block.
3016 wakaba 1.8
3017     @ToStringMethod:
3018     @@Return:
3019 wakaba 1.35 @@@Type: DOMString
3020 wakaba 1.8 @@@enDesc:
3021     Perl code.
3022     @@@PerlDef:
3023 wakaba 1.43 __DEEP{
3024 wakaba 1.35 my @child = @{$self-><AG::Node.childNodes>};
3025 wakaba 1.43 my $label = $self-><AG::PerlCodeStatements.label>;
3026     if (not $label and @child == 1 and
3027 wakaba 1.35 $child[0]-><AG::Node.localName> eq 'block') {
3028 wakaba 1.39 $r = "\x0A" . $child[0]->stringify . "\x0A";
3029 wakaba 1.43 } elsif (not $label and @child == 1 and
3030 wakaba 1.35 $child[0]-><AG::Node.localName> eq 'unparsed' and
3031     $child[0]-><AG::Node.textContent> =~ /^\s*$/) {
3032     #
3033     } else {
3034 wakaba 1.39 $r = "\x0A";
3035 wakaba 1.35 for my $child (@child) {
3036     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3037     1 == @child) {
3038     $r .= '(' . $child->stringify . ')';
3039     } else {
3040     $r .= $child->stringify;
3041     }
3042     }
3043 wakaba 1.39 $r .= "\x0A";
3044 wakaba 1.35
3045 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
3046     -><AG::Document.domConfig>
3047     -><M::DOMCore:DOMConfiguration.getParameter>
3048     (<Q::pc:line>)) {
3049     my $file = $self-><AG::PerlCode.fileNode>;
3050     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3051     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3052     $r = sprintf qq<\n{\n#line %d "%s [b] (Chunk #%d)"%s>.
3053     qq<#line 1 "%s [/b] (Chunk #%d)"\n;}\n>,
3054 wakaba 1.35 $self-><AG::PerlCodeStatements.sourceLine> || 1,
3055     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3056     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3057     $r,
3058     $sfile,
3059     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0
3060 wakaba 1.39 if 2 < length $r;
3061 wakaba 1.41 } else {
3062     $r = "\n{\n$r\n;}\n" if 2 < length $r;
3063 wakaba 1.39 }
3064 wakaba 1.43
3065     $r = "\n" . $label . ':' . $r if $label;
3066     }
3067     }__;
3068 wakaba 1.44 ##PerlBlock
3069 wakaba 1.8
3070 wakaba 1.35 IFClsETDef:
3071 wakaba 1.25 @IFQName: PerlCodeBlocks
3072 wakaba 1.35 @CQName: ManakaiPCCodeBlocks
3073     @ETQName: pc|blockContainer
3074 wakaba 1.25
3075     @IFISA: PerlCodeStatements
3076 wakaba 1.35 @CISA: ManakaiPCCodeStatements
3077 wakaba 1.25
3078 wakaba 1.9 @enDesc:
3079     Perl block-level code container whose content may or may
3080     not semantically be self-contained.
3081    
3082     @ToStringMethod:
3083     @@Return:
3084 wakaba 1.35 @@@Type: DOMString
3085 wakaba 1.9 @@@enDesc:
3086     Perl code.
3087     @@@PerlDef:
3088 wakaba 1.35 my @child = @{$self-><AG::Node.childNodes>};
3089     if (@child == 1 and
3090     {
3091     block => true, blockContainer => true,
3092     }->{$child[0]-><AG::Node.localName>}) {
3093     $r = $child[0]->stringify;
3094     } else {
3095     for my $child (@child) {
3096     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3097     1 == @child) {
3098     $r .= '(' . $child->stringify . ')';
3099     } else {
3100     $r .= $child->stringify;
3101     }
3102     }
3103 wakaba 1.9
3104 wakaba 1.35 __DEEP{
3105 wakaba 1.39 if ($self-><AG::Node.ownerDocument>
3106     -><AG::Document.domConfig>
3107     -><M::DOMCore:DOMConfiguration.getParameter>
3108     (<Q::pc:line>)) {
3109     my $file = $self-><AG::PerlCode.fileNode>;
3110     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3111     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3112     $r = sprintf qq<\n#line %d "%s [bc] (Chunk #%d)"\n%s>.
3113     qq<\n#line 1 "%s [/bc] (Chunk #%d)"\n>,
3114 wakaba 1.35 $self-><AG::PerlCodeStatements.sourceLine> || 1,
3115     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3116     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3117     $r,
3118     $sfile,
3119     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
3120 wakaba 1.39 }
3121 wakaba 1.35 }__;
3122     }
3123     ##PCCodeBlocks
3124    
3125     IFClsETDef:
3126 wakaba 1.44 @IFQName: PCDereference
3127     @CQName: ManakaiPCDereference
3128     @ETQName: pc|dereference
3129    
3130     @IFISA: PerlCode
3131     @IFISA: PerlCodeInlines
3132     @CISA: ManakaiPCCodeInlines
3133    
3134     @enDesc:
3135     A <IF::PCDereference> object represents a dereference.
3136    
3137     @ATTR:
3138     @@Name: variableType
3139     @@ATTRQName: pc|variableType
3140     @@enDesc:
3141     The type of the value, such as <Perl::$>.
3142     @@ReflectCDATA:
3143     @@Get:
3144     @@Set:
3145    
3146     @ToStringMethod:
3147     @@Return:
3148     @@@Type: DOMString
3149     @@@PerlDef:
3150     __DEEP{
3151     $r = $self-><AG::PCDereference.variableType> . '{';
3152     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3153     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3154     $r .= $child;
3155     }
3156     $r .= '}';
3157     }__;
3158     ##PCDereference
3159    
3160     IFClsETDef:
3161 wakaba 1.48 @IFQName: PCReference
3162     @CQName: ManakaiPCReference
3163     @ETQName: pc|reference
3164    
3165     @IFISA: PerlCode
3166     @IFISA: PerlCodeInlines
3167     @CISA: ManakaiPCCodeInlines
3168    
3169     @enDesc:
3170     A <IF::PCReference> object represents a reference (<Perl::\>) operation.
3171    
3172     @ToStringMethod:
3173     @@Return:
3174     @@@Type: DOMString
3175     @@@PerlDef:
3176     __DEEP{
3177     $r = '\(undef)';
3178     no warnings 'uninitialized';
3179     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3180     next A unless $child-><AG::Node.nodeType> ==
3181     <C::Node.ELEMENT_NODE>;
3182     $r = $child;
3183     unless ({
3184     <Q::pc:variable> => true,
3185     }->{$child-><AG::Node.namespaceURI>.
3186     $child-><AG::Node.localName>}) {
3187     $r = '('.$r.')';
3188     }
3189     last A;
3190     }
3191     }__;
3192     ##PCReference
3193    
3194     IFClsETDef:
3195 wakaba 1.44 @IFQName: PCApply
3196     @CQName: ManakaiPCApply
3197     @ETQName: pc|apply
3198    
3199     @IFISA: PerlCode
3200     @IFISA: PerlCodeInlines
3201     @CISA: ManakaiPCCodeInlines
3202    
3203     @enDesc:
3204     A <IF::PCApply> object represents a function call.
3205    
3206     The first child element must be an expression results in a function name
3207     (such as bare function or operator name represented
3208     as a <IF::PCVariable> object or an <IF::PCExpression> with
3209     operator <Perl::-<gt>> whose last operand is a method name.
3210    
3211     The second child element, if any, is an expression intended to be
3212     an argument for the function. It is possible to specify more than
3213     one arguments by <IF::PCExpression> with operator <Perl::,>.
3214    
3215     The third child element, if any, is an expression that is put
3216     into the indirect object slot.
3217    
3218     @Attr:
3219     @@Name: function
3220     @@enDesc:
3221     The function child element of the element.
3222     @@Type: PerlCode
3223     @@Get:
3224     @@@nullCase:
3225     @@@@enDesc: There is no child element.
3226     @@@PerlDef:
3227     __DEEP{
3228     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3229     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3230     $r = $child;
3231     last A;
3232     }
3233     }__;
3234    
3235     @Attr:
3236     @@Name: argument
3237     @@enDesc:
3238     The argument child element of the element.
3239     @@Type: PerlCode
3240     @@Get:
3241     @@@nullCase:
3242     @@@@enDesc: There is no argument element.
3243     @@@PerlDef:
3244     __DEEP{
3245     my $x;
3246     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3247     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3248     if ($x) {
3249     $r = $child;
3250     last A;
3251     } else {
3252     $x = true;
3253     }
3254     }
3255     }__;
3256    
3257     @Attr:
3258     @@Name: indirect
3259     @@enDesc:
3260     The indirect object slot child element of the element.
3261     @@Type: PerlCode
3262     @@Get:
3263     @@@nullCase:
3264     @@@@enDesc: There is no indirect object element.
3265     @@@PerlDef:
3266     __DEEP{
3267     my $x = 0;
3268     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3269     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3270     if ($x++ == 2) {
3271     $r = $child;
3272     last A;
3273     }
3274     }
3275     }__;
3276    
3277    
3278     @ToStringMethod:
3279     @@Return:
3280     @@@Type: DOMString
3281     @@@PerlDef:
3282     __DEEP{
3283     my $f;
3284     my $arg;
3285     my $obj;
3286     no warnings 'uninitialized';
3287     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3288     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3289     if (not defined $f) {
3290     $f = ''.$child;
3291     } elsif (not defined $arg) {
3292     $arg = ''.$child;
3293     } else {
3294     $obj = ''.$child;
3295     last A;
3296     }
3297     }
3298    
3299     $r = $f;
3300     $r .= ' ' . $obj if defined $obj;
3301    
3302     if ({
3303     'die' => true,
3304     'last' => true,
3305     'next' => true,
3306     'redo' => true,
3307     'return' => true,
3308     'warn' => true,
3309     }->{$r}) {
3310     $r .= ' ' . $arg;
3311     } else {
3312     $r .= ' (' . $arg . ')';
3313     }
3314     }__;
3315     ##PCApply
3316    
3317     IFClsETDef:
3318 wakaba 1.43 @IFQName: PCExpression
3319     @CQName: ManakaiPCExpression
3320     @ETQName: pc|expression
3321    
3322     @IFISA: PerlCode
3323     @IFISA: PerlCodeInlines
3324     @CISA: ManakaiPCCodeInlines
3325    
3326     @enDesc:
3327     A <IF::PCExpression> object represents a sequence of one or more
3328     expression fragments (operands) separated by the same operator.
3329    
3330     @ATTR:
3331     @@Name: operator
3332     @@ATTRQName: pc|operator
3333     @@enDesc:
3334     The operator.
3335     @@ReflectCDATA:
3336     @@Get:
3337     @@Set:
3338    
3339     @Attr:
3340     @@Name: operandNumber
3341     @@enDesc:
3342     The number of operands.
3343     @@Type: idl|unsignedLong||ManakaiDOM|all
3344     @@Get:
3345     @@@PerlDef:
3346     __DEEP{
3347     $r = @{$self-><AG::Node.childNodes>};
3348     }__;
3349    
3350     @ToStringMethod:
3351     @@Return:
3352     @@@Type: DOMString
3353     @@@PerlDef:
3354     __DEEP{
3355     my @r;
3356     no warnings 'uninitialized';
3357     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3358     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3359 wakaba 1.44 my $xuri = $child-><AG::Node.namespaceURI>
3360     . $child-><AG::Node.localName>;
3361     push @r, [$child.'', $child, $xuri];
3362 wakaba 1.43 }
3363     if (@r > 1) {
3364     my $op = $self-><AG::PCExpression.operator>;
3365     for (@r) {
3366 wakaba 1.44 if ($_->[2] ne <Q::pc:expression> and not {
3367 wakaba 1.45 <Q::pc:apply> => true,
3368 wakaba 1.44 <Q::pc:arrayRefLiteral> => true,
3369     <Q::pc:atom> => true,
3370     <Q::pc:dereference> => true,
3371     <Q::pc:hashRefLiteral> => true,
3372     <Q::pc:numberLiteral> => true,
3373     <Q::pc:stringLiteral> => true,
3374     <Q::pc:tokens> => true,
3375     <Q::pc:variable> => true,
3376     }->{$_->[2]}) {
3377     $_ = '(' . $_->[0] . ')';
3378     } elsif ($_->[2] eq <Q::pc:expression> and
3379     (not {
3380 wakaba 1.46 '**' => {'->' => true},
3381     '=~' => {'->' => true},
3382     '!~' => {'->' => true},
3383     '*' => {'->' => true, '*' => true},
3384     '/' => {'->' => true},
3385     '%' => {'->' => true},
3386     'x' => {'->' => true},
3387     '+' => {'->' => true, '*' => true, '+' => true, '-' => true},
3388     '-' => {'->' => true, '*' => true},
3389     '.' => {'->' => true},
3390     '<' => {'->' => true},
3391     '>' => {'->' => true},
3392     '<=' => {'->' => true},
3393     '>=' => {'->' => true},
3394     'lt' => {'->' => true},
3395     'gt' => {'->' => true},
3396     'le' => {'->' => true},
3397     'gr' => {'->' => true},
3398     '==' => {'->' => true},
3399     '!=' => {'->' => true},
3400     '<=>' => {'->' => true},
3401     'eq' => {'->' => true},
3402     'ne' => {'->' => true},
3403     'cmp' => {'->' => true},
3404     '&&' => {'->' => true, '&&' => true},
3405     '||' => {'->' => true, '||' => true},
3406     '..' => {'->' => true},
3407     '=' => {'->' => true},
3408     ',' => {'->' => true, ',' => true, '=>' => true},
3409     '=>' => {'->' => true, ',' => true, '=>' => true},
3410     'and' => {'->' => true, 'and' => true},
3411     'or' => {'->' => true, 'or' => true},
3412 wakaba 1.43 }->{$op}->{$_->[1]-><AG::PCExpression.operator>}) and
3413     $_->[1]-><AG::PCExpression.operandNumber> > 1) {
3414     $_ = '(' . $_->[0] . ')';
3415     } else {
3416     $_ = $_->[0];
3417     }
3418     }
3419 wakaba 1.44 $op = ' '.$op unless {
3420     ',' => true,
3421     '->' => true,
3422 wakaba 1.46 '..' => true,
3423     '...' => true,
3424 wakaba 1.44 }->{$op};
3425     $op = $op.' ' unless {
3426     '->' => true,
3427 wakaba 1.46 '..' => true,
3428     '...' => true,
3429 wakaba 1.44 }->{$op};
3430     $r = join $op, @r;
3431 wakaba 1.43 } elsif (@r) {
3432     $r = $r[0]->[0];
3433 wakaba 1.48 } elsif ($self-><AG::PCExpression.operator> eq ',') {
3434     $r = '()';
3435 wakaba 1.43 } else {
3436     $r = 'undef';
3437     }
3438     }__;
3439     ##PCExpression
3440    
3441     IFClsETDef:
3442 wakaba 1.25 @IFQName: PerlAssignment
3443 wakaba 1.35 @CQName: ManakaiPCAssignment
3444     @ETQName: pc|assignment
3445 wakaba 1.25
3446     @IFISA: PerlCode
3447 wakaba 1.35 @CISA: ManakaiPCCode
3448 wakaba 1.25
3449 wakaba 1.11 @enDesc:
3450 wakaba 1.36 Perl variable assignment.
3451 wakaba 1.11
3452     @ToStringMethod:
3453     @@Return:
3454 wakaba 1.35 @@@Type: DOMString
3455 wakaba 1.11 @@@enDesc:
3456     Perl code.
3457     @@@PerlDef:
3458 wakaba 1.35 __DEEP{
3459     $r = $self-><AG::PerlAssignment.leftCode>->stringify
3460     . ' = '
3461     . $self-><AG::PerlAssignment.rightCode>->stringify;
3462     }__;
3463    
3464     @Attr:
3465     @@Name: leftCode
3466     @@enDesc:
3467     Left-hand expression.
3468     @@Type: PerlCodeInlines
3469     @@Get:
3470     @@@nullCase:
3471     @@@@enDesc: Left-hand code not yet specified.
3472     @@@PerlDef:
3473     __DEEP{
3474     F: for my $child (@{$self-><AG::Node.childNodes>}) {
3475     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3476     $child-><AG::Node.localName> eq 'left') {
3477     $r = $child-><AG::Node.lastChild>;
3478     last F;
3479     }
3480     }
3481     }__;
3482     @@Set:
3483     @@@PerlDef:
3484     __DEEP{
3485     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
3486     F: {
3487     for my $child (@{$self-><AG::Node.childNodes>}) {
3488     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3489     $child-><AG::Node.localName> eq 'left') {
3490     $child-><AS::Node.textContent> ('');
3491     $child-><M::Node.appendChild> ($given);
3492     last F;
3493     }
3494     }
3495     my $node = $self-><AG::Node.ownerDocument>
3496     -><M::Document.createElementNS>
3497     (<Q::pc:>, 'left');
3498     $node-><M::Node.appendChild> ($given);
3499     $self-><M::Node.appendChild> ($node);
3500     }
3501     }__;
3502    
3503     @Attr:
3504     @@Name: rightCode
3505     @@enDesc:
3506     Right-hand expression.
3507     @@Type: PerlCodeInlines
3508     @@Get:
3509     @@@nullCase:
3510     @@@@enDesc: Right-hand code not yet specified.
3511     @@@PerlDef:
3512     __DEEP{
3513     F: for my $child (@{$self-><AG::Node.childNodes>}) {
3514     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3515     $child-><AG::Node.localName> eq 'right') {
3516     $r = $child-><AG::Node.lastChild>;
3517     last F;
3518     }
3519     }
3520     }__;
3521     @@Set:
3522     @@@PerlDef:
3523     __DEEP{
3524     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
3525     F: {
3526     for my $child (@{$self-><AG::Node.childNodes>}) {
3527     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
3528     $child-><AG::Node.localName> eq 'right') {
3529     $child-><AS::Node.textContent> ('');
3530     $child-><M::Node.appendChild> ($given);
3531     last F;
3532     }
3533     }
3534     my $node = $self-><AG::Node.ownerDocument>
3535     -><M::Document.createElementNS>
3536     (<Q::pc:>, 'right');
3537     $node-><M::Node.appendChild> ($given);
3538     $self-><M::Node.appendChild> ($node);
3539     }
3540     }__;
3541 wakaba 1.11 ##PerlAssignment
3542    
3543 wakaba 1.35 IFClsETDef:
3544 wakaba 1.44 @IFQName: PCCondition
3545     @CQName: ManakaiPCCondition
3546     @ETQName: pc2|condition
3547    
3548     @IFISA: PerlCode
3549     @IFISA: PerlCodeInlines
3550     @CISA: ManakaiPCCodeInlines
3551    
3552     @enDesc:
3553     A <IF::PCCondition> object represents a condition expression
3554     part of an <Perl::if> or <Perl::while> statement.
3555    
3556     @ToStringMethod:
3557     @@Return:
3558     @@@Type: DOMString
3559     @@@PerlDef:
3560     __DEEP{
3561     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3562     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3563     $r .= $child;
3564     }
3565     }__;
3566     ##PCCondition
3567    
3568     IFClsETDef:
3569     @IFQName: PCBlock
3570     @CQName: ManakaiPCBlock
3571     @ETQName: pc2|block
3572    
3573     @IFISA: PerlCode
3574     @IFISA: PerlCodeStatements
3575     @CISA: ManakaiPCCodeStatements
3576    
3577     @enDesc:
3578     A <Q::PCBlock> object represents a Perl code block, i.e.
3579     a set of statements enclosed by <CHAR::{> and <CHAR::}> pair.
3580    
3581     @ToStringMethod:
3582     @@Return:
3583     @@@Type: DOMString
3584     @@@PerlDef:
3585     __DEEP{
3586     my @child = @{$self-><AG::Node.childNodes>};
3587     my $label = $self-><AG::PerlCodeStatements.label>;
3588    
3589     $r = "\x0A";
3590     for my $child (@child) {
3591     if ($child-><AG::Node.localName> eq 'inlineContainer' and
3592     1 == @child) {
3593     $r .= '(' . $child->stringify . ')';
3594     } else {
3595     $r .= $child->stringify;
3596     }
3597     }
3598     $r .= "\x0A";
3599     $r .= ';' unless @child;
3600    
3601     if ($self-><AG::Node.ownerDocument>
3602     -><AG::Document.domConfig>
3603     -><M::DOMCore:DOMConfiguration.getParameter>
3604     (<Q::pc:line>)) {
3605     my $file = $self-><AG::PerlCode.fileNode>;
3606     my $sfile = $file ? $file-><AG::PerlFile.sourceFile>
3607     : $self->{<H::mn:node>}->{<H::mn:nodeID>};
3608     $r = sprintf qq<\n{\n#line %d "%s [b] (Chunk #%d)"%s>.
3609     qq<#line 1 "%s [/b] (Chunk #%d)"\n}\n>,
3610     $self-><AG::PerlCodeStatements.sourceLine> || 1,
3611     $self-><AG::PerlCodeStatements.sourceFile> || $sfile,
3612     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0,
3613     $r,
3614     $sfile,
3615     $file ? $file-><M::PerlFile.getNextChunkNumber> : 0;
3616     } else {
3617     $r = "\n{\n$r\n}\n";
3618     }
3619    
3620     $r = "\n" . $label . ':' . $r . '# ' . $label . "\n"
3621     if length $label;
3622    
3623     }__;
3624     ##PCBlock
3625    
3626     IFClsETDef:
3627 wakaba 1.45 @IFQName: PCWhile
3628     @CQName: ManakaiPCWhile
3629     @ETQName: pc|while
3630    
3631     @IFISA: PerlCode
3632     @CISA: ManakaiPCCode
3633    
3634     @enDesc:
3635     A <IF::PCWhile> object represents a <Perl::while> statement.
3636     It can contain two child elements: <Q::pc2|condition> and <Q::pc2|block>,
3637     each represents the condition expression and the block of the <Perl::while>
3638     statement.
3639    
3640     @ATTR:
3641     @@Name: label
3642     @@ATTRQName: pc|label
3643     @@enDesc:
3644     Label for this block.
3645     @@ReflectCDATA:
3646     @@Get:
3647     @@@nullCase:
3648     @@@@enDesc:
3649     No label.
3650     @@Set:
3651     @@@nullCase:
3652     @@@@enDesc:
3653     No label.
3654    
3655     @Attr:
3656     @@Name: condition
3657     @@enDesc:
3658     The condition object.
3659     @@Type: PCCondition
3660     @@Get:
3661     @@@nullCase:
3662     @@@@enDesc:
3663     There is no condition element.
3664     @@@PerlDef:
3665     __CODE{getChildElementByType::
3666     $namespaceURI => {<Q::pc2:>},
3667     $localName => {'condition'},
3668     $parent => $self,
3669     $result => $r,
3670     }__;
3671    
3672     @Attr:
3673     @@Name: block
3674     @@enDesc:
3675     The code block that is executed while the <A::PCWhile.condition> met.
3676     @@Type: PCBlock
3677     @@Get:
3678     @@@nullCase:
3679     @@@@enDesc:
3680     There is no <Q::pc2:block> child element.
3681     @@@PerlDef:
3682     __CODE{getChildElementByType::
3683     $namespaceURI => {<Q::pc2:>},
3684     $localName => {'block'},
3685     $parent => $self,
3686     $result => $r,
3687     }__;
3688    
3689     @ToStringMethod:
3690     @@Return:
3691     @@@Type: DOMString
3692     @@@PerlDef:
3693     __DEEP{
3694     $r = 'while (';
3695     my $cond = $self-><AG::PCWhile.condition>;
3696     if ($cond) {
3697     $r .= $cond->stringify;
3698     } else {
3699     $r .= '0';
3700     }
3701     $r .= ') ';
3702     my $block = $self-><AG::PCWhile.block>;
3703     if ($block) {
3704     $r .= $block->stringify;
3705     } else {
3706     $r .= "{ }\n";
3707     }
3708    
3709     my $label = $self-><AG::PCWhile.label>;
3710     $r = "\n" . $label . ': ' . $r . ' # ' . $label . "\n"
3711     if length $label;
3712     }__;
3713     ##PCWhile
3714    
3715     IFClsETDef:
3716 wakaba 1.43 @IFQName: PCChoose
3717     @CQName: ManakaiPCChoose
3718     @ETQName: pc|choose
3719    
3720     @IFISA: PerlCode
3721     @CISA: ManakaiPCCode
3722    
3723     @enDesc:
3724     A <IF::PCChoose> object, or a <Q::pc|choose> element, represents
3725     a set of <Perl::if>, <Perl::elsif>, and <Perl::else> statements.
3726    
3727     @Method:
3728     @@Name: getWhen
3729     @@enDesc:
3730     Returns a <IF::PCWhen> by its ordinal index.
3731     @@Param:
3732     @@@Name: index
3733     @@@Type: idl|unsignedLong||ManakaiDOM|all
3734     @@@enDesc:
3735     The ordinal index of the <Q::pc|when> element.
3736     @@Return:
3737     @@@Type: PCWhen
3738     @@@enDesc:
3739     The <P::index>th <Q::pc|when> object.
3740     @@@nullCase:
3741     @@@@enDesc:
3742     There is no <P::index>th element.
3743     @@@PerlDef:
3744     __DEEP{
3745     my $i = 0;
3746     no warnings 'uninitialized';
3747     A: for my $child (@{$self-><AG::Node.childNodes>}) {
3748     if ($child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
3749     $child-><AG::Node.namespaceURI> eq <Q::pc:> and
3750     $child-><AG::Node.localName> eq 'when' and
3751     ++$i == $index) {
3752     $r = $child;
3753     last A;
3754     }
3755     }
3756     }__;
3757    
3758     @Method:
3759     @@Name: appendNewPCWhen
3760     @@enDesc:
3761     Appends a new <Q::pc|when> element.
3762     @@Return:
3763     @@@Type: PCWhen
3764     @@@enDesc:
3765     The newly created <Q::pc|when> element.
3766     @@@PerlDef:
3767     __DEEP{
3768     my $od = $self-><AG::Node.ownerDocument>;
3769     $r = $od-><M::Document.createElementNS> (<Q::pc:>, 'when');
3770     my $cond = $od-><M::Document.createElementNS>
3771 wakaba 1.44 (<Q::pc2:>, 'condition');
3772 wakaba 1.43 $r-><M::Node.appendChild> ($cond);
3773     my $block = $od-><M::Document.createElementNS>
3774 wakaba 1.44 (<Q::pc2:>, 'block');
3775 wakaba 1.43 $r-><M::Node.appendChild> ($block);
3776     $self-><M::Node.insertBefore> ($r, $self-><AG::PCChoose.otherwise>);
3777     }__;
3778    
3779     @Attr:
3780     @@Name: otherwise
3781     @@enDesc:
3782     Returns the <IF::PCOtherwise> by its ordinal index.
3783     @@Type: PCOtherwise
3784     @@Get:
3785     @@@enDesc:
3786     The <Q::pc|otherwise> object.
3787     @@@nullCase:
3788     @@@@enDesc:
3789     There is no <Q::pc|otherwise> element.
3790     @@@PerlDef:
3791     __CODE{getChildElementByType::
3792     $namespaceURI => {<Q::pc:>},
3793     $localName => {'otherwise'},
3794     $parent => $self,
3795     $result => $r,
3796     }__;
3797    
3798     @Method:
3799     @@Name: appendNewPCOtherwise
3800     @@enDesc:
3801     Appends a new <Q::pc|otherwise> element. If there is already the
3802     <Q::pc|otherwise> element, then no element is created and
3803     the element is returned.
3804     @@Return:
3805     @@@Type: PCOtherwise
3806     @@@enDesc:
3807     The <Q::pc|otherwise> element.
3808     @@@PerlDef:
3809     __DEEP{
3810     $r = $self-><AG::PCChoose.otherwise>;
3811     unless ($r) {
3812     my $od = $self-><AG::Node.ownerDocument>;
3813     $r = $od-><M::Document.createElementNS> (<Q::pc:>, 'otherwise');
3814     my $block = $od-><M::Document.createElementNS>
3815 wakaba 1.44 (<Q::pc2:>, 'block');
3816 wakaba 1.43 $r-><M::Node.appendChild> ($block);
3817     $self-><M::Node.appendChild> ($r);
3818     }
3819     }__;
3820    
3821     @ToStringMethod:
3822     @@Return:
3823     @@@Type: DOMString
3824     @@@PerlDef:
3825     __DEEP{
3826     S: for my $child (@{$self-><AG::Node.childNodes>}) {
3827     next S unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
3828     next S unless $child-><AG::Node.namespaceURI> eq <Q::pc:>;
3829     my $ln = $child-><AG::Node.localName>;
3830     if ($ln eq 'when') {
3831     $r .= 'els' if length $r;
3832     $r .= $child->stringify;
3833     } elsif ($ln eq 'otherwise') {
3834     $r .= $child->stringify;
3835     last S;
3836     }
3837     } # S
3838     }__;
3839     ##PCChoose
3840    
3841     IFClsETDef:
3842     @IFQName: PCWhen
3843     @CQName: ManakaiPCWhen
3844     @ETQName: pc|when
3845    
3846     @IFISA: PerlCode
3847     @CISA: ManakaiPCCode
3848    
3849     @enDesc:
3850     A <IF::PCWhen> object, or a <Q::pc|when> element, represents an
3851     <Perl::if> or <Perl::elsif> block.
3852    
3853     @Attr:
3854     @@Name: condition
3855     @@enDesc:
3856 wakaba 1.44 The condition object.
3857     @@Type: PCCondition
3858 wakaba 1.43 @@Get:
3859     @@@nullCase:
3860     @@@@enDesc:
3861 wakaba 1.44 There is no condition element.
3862 wakaba 1.43 @@@PerlDef:
3863     __CODE{getChildElementByType::
3864 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3865 wakaba 1.43 $localName => {'condition'},
3866     $parent => $self,
3867     $result => $r,
3868     }__;
3869    
3870     @Attr:
3871     @@Name: block
3872     @@enDesc:
3873     The code block that is executed when the <A::PCWhen.condition> met.
3874 wakaba 1.44 @@Type: PCBlock
3875 wakaba 1.43 @@Get:
3876     @@@nullCase:
3877     @@@@enDesc:
3878 wakaba 1.44 There is no <Q::pc2:block> child element.
3879 wakaba 1.43 @@@PerlDef:
3880     __CODE{getChildElementByType::
3881 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3882 wakaba 1.43 $localName => {'block'},
3883     $parent => $self,
3884     $result => $r,
3885     }__;
3886    
3887     @ToStringMethod:
3888     @@Return:
3889     @@@Type: DOMString
3890     @@@PerlDef:
3891     __DEEP{
3892     $r = 'if (';
3893     my $cond = $self-><AG::PCWhen.condition>;
3894     if ($cond) {
3895     $r .= $cond->stringify;
3896     } else {
3897     $r .= '0';
3898     }
3899     $r .= ') ';
3900     my $block = $self-><AG::PCWhen.block>;
3901     if ($block) {
3902     $r .= $block->stringify;
3903     } else {
3904     $r .= "{ }\n";
3905     }
3906     }__;
3907     ##PCWhen
3908    
3909     IFClsETDef:
3910     @IFQName: PCOtherwise
3911     @CQName: ManakaiPCOtherwise
3912     @ETQName: pc|otherwise
3913    
3914     @IFISA: PerlCode
3915     @CISA: ManakaiPCCode
3916    
3917     @enDesc:
3918     A <IF::PCOtherwise> object, or a <Q::pc|otherwise> element, represents an
3919     <Perl::else> clause.
3920    
3921     @Attr:
3922     @@Name: block
3923     @@enDesc:
3924     The code block that is executed.
3925 wakaba 1.44 @@Type: PCBlock
3926 wakaba 1.43 @@Get:
3927     @@@nullCase:
3928     @@@@enDesc:
3929 wakaba 1.44 There is no <Q::pc2:block> child element.
3930 wakaba 1.43 @@@PerlDef:
3931     __CODE{getChildElementByType::
3932 wakaba 1.44 $namespaceURI => {<Q::pc2:>},
3933 wakaba 1.43 $localName => {'block'},
3934     $parent => $self,
3935     $result => $r,
3936     }__;
3937    
3938     @ToStringMethod:
3939     @@Return:
3940     @@@Type: DOMString
3941     @@@PerlDef:
3942     __DEEP{
3943     my $block = $self-><AG::PCOtherwise.block>;
3944     if ($block) {
3945     $r = 'else ' . $block->stringify;
3946     }
3947     }__;
3948     ##PCOtherwise
3949    
3950     ResourceDef:
3951     @For: ManakaiDOM|ManakaiDOM
3952     @QName: getChildElementByType
3953     @rdf:type: DISPerl|BlockCode
3954     @enDesc:
3955     Returns the first element of a type.
3956     @PerlCDef:
3957     __DEEP{
3958     no warnings 'uninitialized';
3959     A: for my $__child (@{$parent-><AG::Node.childNodes>}) {
3960     if ($__child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE> and
3961     $__child-><AG::Node.namespaceURI> eq $namespaceURI and
3962     $__child-><AG::Node.localName> eq $localName) {
3963     $result = $__child;
3964     last A;
3965     }
3966     }
3967     }__;
3968    
3969     IFClsETDef:
3970 wakaba 1.26 @IFQName: PerlIf
3971 wakaba 1.35 @CQName: ManakaiPCIf
3972     @ETQName: pc|if
3973 wakaba 1.25
3974     @IFISA: PerlCode
3975 wakaba 1.35 @CISA: ManakaiPCCode
3976 wakaba 1.25
3977 wakaba 1.12 @enDesc:
3978     Perl variable assignment.
3979    
3980     @ToStringMethod:
3981     @@Return:
3982 wakaba 1.35 @@@Type: DOMString
3983 wakaba 1.12 @@@enDesc:
3984     Perl code.
3985     @@@PerlDef:
3986 wakaba 1.35 __DEEP{
3987     my $tcode = $self-><AG::PerlIf.trueCode>;
3988     my $fcode = $self-><AG::PerlIf.falseCode>;
3989     my $ccode = $self-><AG::PerlIf.condition>;
3990     if (defined $tcode) {
3991     if (defined $fcode) {
3992     $r = q<if (> . $ccode->stringify . q<) {> . $tcode->stringify .
3993     q<} else {> . $fcode->stringify . qq<}\n>;
3994     } else {
3995 wakaba 1.36 $r = q<if (> . $ccode->stringify . q<) {> . $tcode->stringify .
3996 wakaba 1.35 qq<}\n>;
3997     }
3998     } else {
3999     $r = q<unless (> . $ccode->stringify . q<) {> . $fcode->stringify .
4000     qq<}\n>;
4001     }
4002     }__;
4003    
4004     @Attr:
4005     @@Name: condition
4006     @@enDesc:
4007     Condition expression.
4008     @@Type: PerlCodeInlines
4009     @@Get:
4010     @@@nullCase:
4011     @@@@enDesc: Condition code not yet specified.
4012     @@@PerlDef:
4013     __DEEP{
4014     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4015     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4016     $child-><AG::Node.localName> eq 'condition') {
4017     $r = $child-><AG::Node.lastChild>;
4018     last F;
4019     }
4020     }
4021     }__;
4022     @@Set:
4023     @@@PerlDef:
4024     __DEEP{
4025     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4026     F: {
4027     for my $child (@{$self-><AG::Node.childNodes>}) {
4028     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4029     $child-><AG::Node.localName> eq 'condition') {
4030     $child-><AS::Node.textContent> ('');
4031     $child-><M::Node.appendChild> ($given);
4032     last F;
4033     }
4034     }
4035     my $node = $self-><AG::Node.ownerDocument>
4036     -><M::Document.createElementNS>
4037     (<Q::pc:>, 'condition');
4038     $node-><M::Node.appendChild> ($given);
4039     $self-><M::Node.appendChild> ($node);
4040     }
4041     }__;
4042    
4043     @Attr:
4044     @@Name: trueCode
4045     @@enDesc:
4046     True-case code.
4047     @@Type: PerlCodeBlocks
4048     @@Get:
4049     @@@nullCase:
4050     @@@@enDesc: True-case code not yet specified.
4051     @@@PerlDef:
4052     __DEEP{
4053     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4054     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4055     $child-><AG::Node.localName> eq 'tr'.'ue') {
4056     $r = $child-><AG::Node.lastChild>;
4057     last F;
4058     }
4059     }
4060     }__;
4061     @@Set:
4062     @@@PerlDef:
4063     __DEEP{
4064     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4065     F: {
4066     for my $child (@{$self-><AG::Node.childNodes>}) {
4067     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4068     $child-><AG::Node.localName> eq 'tr'.'ue') {
4069     $child-><AS::Node.textContent> ('');
4070     $child-><M::Node.appendChild> ($given);
4071     last F;
4072     }
4073     }
4074     my $node = $self-><AG::Node.ownerDocument>
4075     -><M::Document.createElementNS>
4076     (<Q::pc:>, 'tr'.'ue');
4077     $node-><M::Node.appendChild> ($given);
4078     $self-><M::Node.appendChild> ($node);
4079     }
4080     }__;
4081    
4082     @Attr:
4083     @@Name: falseCode
4084     @@enDesc:
4085     False-case code.
4086     @@Type: PerlCodeBlocks
4087     @@Get:
4088     @@@nullCase:
4089     @@@@enDesc: True-case code not yet specified.
4090     @@@PerlDef:
4091     __DEEP{
4092     F: for my $child (@{$self-><AG::Node.childNodes>}) {
4093     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4094     $child-><AG::Node.localName> eq 'fal'.'se') {
4095     $r = $child-><AG::Node.lastChild>;
4096     last F;
4097     }
4098     }
4099     }__;
4100     @@Set:
4101     @@@PerlDef:
4102     __DEEP{
4103     $self-><AG::Node.ownerDocument>-><M::Document.adoptNode> ($given);
4104     F: {
4105     for my $child (@{$self-><AG::Node.childNodes>}) {
4106     if ($child-><AG::Node.namespaceURI> eq <Q::pc:> and
4107     $child-><AG::Node.localName> eq 'fal'.'se') {
4108     $child-><AS::Node.textContent> ('');
4109     $child-><M::Node.appendChild> ($given);
4110     last F;
4111     }
4112     }
4113     my $node = $self-><AG::Node.ownerDocument>
4114     -><M::Document.createElementNS>
4115     (<Q::pc:>, 'fal'.'se');
4116     $node-><M::Node.appendChild> ($given);
4117     $self-><M::Node.appendChild> ($node);
4118     }
4119     }__;
4120 wakaba 1.12 ##PerlIf
4121    
4122     PropDef:
4123     @QName:condition
4124     @enDesc:
4125     Condition.
4126     PropDef:
4127     @QName:true
4128     @enDesc:
4129     If true.
4130     PropDef:
4131     @QName:false
4132     @enDesc:
4133     If false.
4134    
4135 wakaba 1.11 PropDef:
4136     @QName:left
4137     @FullName:
4138     @@lang:en
4139     @@@: Left hand side
4140     PropDef:
4141     @QName:right
4142     @FullName:
4143     @@lang:en
4144     @@@: Right hand side
4145    
4146 wakaba 1.8 PropDef:
4147     @QName:label
4148     @enDesc:
4149     Perl statement / block label.
4150    
4151 wakaba 1.43
4152     IFClsETDef:
4153     @IFQName: PCFunctionCall
4154     @CQName: ManakaiPCFunctionCall
4155     @ETQName: pc|call
4156    
4157     @IFISA: PerlCode
4158     @IFISA: PerlCodeInlines
4159     @CISA: ManakaiPCCodeInlines
4160    
4161     @enDesc:
4162     A <IF::PCFunctionCall> object represents a function call or
4163     function-like statement such as <Perl::next>.
4164    
4165     @ATTR:
4166     @@Name: variableType
4167     @@ATTRQName: pc|variableType
4168     @@enDesc:
4169     The value of the attribute <kwd:MAY> be <Perl::&>,
4170     which introduces a subroutine name.
4171     @@ReflectCDATA:
4172     @@Get:
4173     @@Set:
4174    
4175     @ATTR:
4176     @@Name: packageName
4177     @@ATTRQName: pc|packageName
4178     @@enDesc:
4179     The name of the package to which the subroutine belongs.
4180     @@ReflectCDATA:
4181     @@Get:
4182     @@@nullCase:
4183     @@@@enDesc:
4184     The object belongs to the current package or
4185     does not belong to any package.
4186     @@Set:
4187     @@@nullCase:
4188     @@@@enDesc:
4189     The object belongs to the current package or
4190     does not belong to any package.
4191    
4192     @ATTR:
4193     @@Name: pcLocalName
4194     @@ATTRQName: pc|localName
4195     @@enDesc:
4196     The local part of the subroutine name.
4197     @@ReflectCDATA:
4198     @@Get:
4199     @@Set:
4200    
4201     @ToStringMethod:
4202     @@Return:
4203     @@@Type: DOMString
4204     @@@PerlDef:
4205     __DEEP{
4206     $r .= $self-><AG::PCFunctionCall.variableType>;
4207     my $v = $self-><AG::PCFunctionCall.packageName>;
4208     $r .= $v . '::' if length $v;
4209     $r .= $self-><AG::PCFunctionCall.pcLocalName>;
4210    
4211     my @arg;
4212     no warnings 'uninitialized';
4213     A: for my $child (@{$self-><AG::Node.childNodes>}) {
4214     next A unless $child-><AG::Node.nodeType> == <C::Node.ELEMENT_NODE>;
4215     push @arg, ''.$child;
4216     }
4217     my $arg = join ', ', @arg;
4218     if ({
4219     'die' => true,
4220     'last' => true,
4221     'next' => true,
4222     'redo' => true,
4223 wakaba 1.44 'return' => true,
4224 wakaba 1.43 'warn' => true,
4225 wakaba 1.44 }->{$r}) {
4226 wakaba 1.43 $r .= ' ' . $arg;
4227     } else {
4228     $r .= ' (' . $arg . ')';
4229     }
4230     }__;
4231     ##PCFunctionCall
4232    
4233 wakaba 1.6 ElementTypeBinding:
4234     @Name: RaiseException
4235     @ElementType:
4236 wakaba 1.39 dx:raises
4237    
4238     ## -- Configuration Parameters
4239    
4240     boolCParam:
4241     @QName: pc|line
4242     @nodeProp: pcline
4243     @IsSupportRequired:1
4244     @DOMCore:targetType: DOMCore|Document
4245     @TrueCase:
4246     @@DOMCore:isSupported:1
4247     @@enDesc:
4248     Inserts <Perl::#line> directives.
4249     @FalseCase:
4250     @@DOMCore:isSupported:1
4251     @@IsSupportRequired:1
4252     @@IsDefault:1
4253     Does not insert any <Perl::#line> directive.
4254    
4255     CParam:
4256     @QName: pc|split-resolver
4257     @nodeProp: pcsres
4258     @IsSupportRequired:1
4259     @DOMCore:targetType: DOMCore|Document
4260     @Type: DISPerl|CODE||ManakaiDOM|all
4261     @enDesc:
4262     Splits module file. The parameter value <kwd:MUST> be
4263     a Perl code reference. The serializer would invoke
4264     the code with arguments: a reserved parameter, a <IF::PerlFile>
4265     whose serialization is being split, and a string
4266     that identifies the split part. The code is expected
4267     to return a <IF::DOMLS:LSOutput> object to which the module part
4268     is written. Note that splitting serialized module file
4269     does not affect to the <IF::PerlFile> tree.
4270     @nullCase:
4271     @@enDesc:
4272     Does not split module file.
4273    
4274     ElementTypeBinding:
4275     @Name: nodeProp
4276     @ElementType:
4277     DOMCore:nodeProp
4278     @ShadowContent:
4279     @@For: =ManakaiDOM|all
4280    
4281     ElementTypeBinding:
4282     @Name: CParam
4283     @ElementType:
4284     dis:ResourceDef
4285     @ShadowContent:
4286     @@rdf:type:
4287     @@@@: DOMCore|DOMConfigurationParameter
4288     @@@For: ManakaiDOM|DOM
4289     @@rdf:type:
4290     @@@@: DISCore|Property
4291     @@@For: =ManakaiDOM|all
4292     @@For: ManakaiDOM|DOM3
4293     @@For: =ManakaiDOM|all
4294    
4295     ElementTypeBinding:
4296     @Name: boolCParam
4297     @ElementType:
4298     dis:ResourceDef
4299     @ShadowContent:
4300     @@rdf:type:
4301     @@@@: DOMCore|DOMConfigurationParameter
4302     @@@For: ManakaiDOM|DOM
4303     @@rdf:type:
4304     @@@@: DISCore|Property
4305     @@@For: =ManakaiDOM|all
4306     @@For: ManakaiDOM|DOM3
4307     @@For: =ManakaiDOM|all
4308     @@Type: idl|boolean||ManakaiDOM|all
4309    
4310 wakaba 1.41 ## -- PCDocument
4311    
4312     IFClsDef:
4313     @IFQName: PCDocument
4314     @CQName: ManakaiPCDocument
4315    
4316     @IFISA: Document
4317     @CISA: DOMCore|ManakaiDOMDocument
4318    
4319     @enDesc:
4320     A <IF::PCDocument> is a <IF::Document> that represents a Perl code.
4321    
4322     @s:rootElementType: pc|file
4323    
4324     @Method:
4325     @@Name: createPCLiteral
4326     @@enDesc:
4327     Creates a literal object.
4328 wakaba 1.47
4329     {NOTE:: If a member of <P::value> is a <IF::PerlCode> object,
4330     then it is appended to the tree as is, except when
4331     the object comes from different document than the
4332     document, in which case the object is being adopted
4333     to the document by <M::Document.adoptNode> method.
4334     If that method fails, then the result is undefined.
4335     }
4336 wakaba 1.41 @@Param:
4337     @@@Name: value
4338     @@@Type: DISPerl|Any
4339     @@@enDesc:
4340     The value.
4341     @@@InCase:
4342     @@@@Type: DISPerl|StringValue
4343     @@@@enDesc:
4344     A <IF::PerlStringLiteral> whose value is <P::value> is created.
4345     @@@InCase:
4346     @@@@Type: DISPerl|ARRAY
4347     @@@@enDesc:
4348     A <IF::PCArrayRefLiteral> is created. If <P::value>
4349     has items, then objects are recursively created.
4350     @@@InCase:
4351     @@@@Type: DISPerl|HASH
4352     @@@@enDesc:
4353     A <IF::PCHashRefLiteral> is created. If <P::value>
4354     has key-value pairs, then objects are recursively created.
4355     @@Return:
4356     @@@Type: PerlCode
4357     @@@enDesc: The newly created value object.
4358     @@@PerlDef:
4359     __DEEP{
4360     if (ref $value eq 'HASH' or ref $value eq 'ARRAY') {
4361     $r = $self-><M::Document.createElementNS>
4362     (<Q::pc:>, ref $value eq 'HASH' ? 'hashRefLiteral'
4363     : 'arrayRefLiteral');
4364     for my $v (ref $value eq 'HASH' ? %$value : @$value) {
4365     my $vo;
4366     if (UNIVERSAL::isa ($v, <IFName::PerlCode>)) {
4367 wakaba 1.47 $vo = $self-><M::Document.adoptNode> ($v);
4368 wakaba 1.41 } else {
4369     $vo = $self-><M::PCDocument.createPCLiteral> ($v);
4370     }
4371     $r-><M::Node.appendChild> ($vo);
4372     }
4373     } else {
4374     $r = $self-><M::Document.createElementNS>
4375     (<Q::pc:>, 'stringLiteral');
4376     $r-><AS::Node.textContent> ($value);
4377     }
4378 wakaba 1.43 }__;
4379    
4380     @Method:
4381 wakaba 1.44 @@Name: createPCNumberLiteral
4382     @@enDesc:
4383     Creates a number literal object.
4384     @@Param:
4385     @@@Name: value
4386     @@@Type: DISPerl|NumberValue
4387     @@@enDesc:
4388     The value.
4389     @@Return:
4390     @@@Type: PCNumberValue
4391     @@@enDesc: The newly created value object.
4392     @@@PerlDef:
4393     __DEEP{
4394     $r = $self-><M::Document.createElementNS>
4395     (<Q::pc:>, 'numberLiteral');
4396     $r-><AS::Node.textContent> ($value);
4397     }__;
4398    
4399     @Method:
4400     @@Name: createPCVariable
4401     @@enDesc:
4402     Creates a new <IF::PerlVariable> object.
4403     @@Param:
4404     @@@Name: variableType
4405     @@@Type: DOMString
4406     @@@enDesc:
4407     Variable prefix.
4408     @@@nullCase:
4409     @@@@enDesc:
4410     If the <P::packageName> is <DOM::null>, then
4411     the <P::variableType> is detected by the prefix of
4412     <P::localName>. Otherwise, it is an unprefixed variable
4413     such as file handle.
4414     @@Param:
4415     @@@Name: packageName
4416     @@@Type: DOMString
4417     @@@enDesc:
4418     Package name.
4419     @@@nullCase:
4420     @@@@enDesc:
4421     The variable belongs to the current package or a
4422     lexical-scoped variable.
4423     @@Param:
4424     @@@Name: localName
4425     @@@Type: DOMString
4426     @@@enDesc:
4427     Variable name. If both <P::variableType> and <P::packageName>
4428     is <DOM::null>, the <P::localName> value may be prefixed
4429     by any possible <P::variableType> value.
4430     @@Return:
4431     @@@Type: PerlVariable
4432     @@@enDesc:
4433     Newly created Perl variable object.
4434     @@@PerlDef:
4435     __DEEP{
4436     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'variable');
4437     if (not $variableType and not $packageName and
4438     $localName =~ s/^(\\?[\$\@%&*])//) {
4439     $variableType = $1;
4440     }
4441     $r-><AS::PerlVariable.variableType> ($variableType)
4442     if defined $variableType;
4443     $r-><AS::PerlVariable.packageName> ($packageName)
4444     if defined $packageName;
4445     $r-><AS::PerlVariable.pcLocalName> ($localName);
4446     }__;
4447    
4448     @Method:
4449     @@Name: createPCDereference
4450     @@enDesc:
4451     Creates a <IF::PCDereference> object.
4452     @@Param:
4453     @@@Name: variableType
4454     @@@Type: DOMString
4455     @@@enDesc:
4456     The type of the referenced value, such as <Perl::$>.
4457     @@Return:
4458     @@@Type: PCDereference
4459     @@@enDesc:
4460     The newly created element node.
4461     @@@PerlDef:
4462     __DEEP{
4463 wakaba 1.48 $r = $self-><M::Document.createElementNS>
4464     (<Q::pc:>, 'dereference');
4465 wakaba 1.44 $r-><AS::PCDereference.variableType> ($variableType);
4466 wakaba 1.48 }__;
4467    
4468     @Method:
4469     @@Name: createPCReference
4470     @@enDesc:
4471     Creates a <IF::PCReference> object.
4472     @@Return:
4473     @@@Type: PCReference
4474     @@@enDesc:
4475     The newly created element node.
4476     @@@PerlDef:
4477     __DEEP{
4478     $r = $self-><M::Document.createElementNS>
4479     (<Q::pc:>, 'reference');
4480 wakaba 1.44 }__;
4481    
4482     @Method:
4483 wakaba 1.43 @@Name: createPCExpression
4484     @@enDesc:
4485     Creates a <Q::pc:expression> element node.
4486     @@Param:
4487     @@@Name: operator
4488     @@@Type: DOMString
4489     @@@enDesc:
4490     The operator of the expression.
4491     @@Return:
4492     @@@Type: PCExpression
4493     @@@enDesc:
4494     The newly created expression object.
4495     @@@PerlDef:
4496     __DEEP{
4497 wakaba 1.44 $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'expression');
4498 wakaba 1.43 $r-><AS::PCExpression.operator> ($operator);
4499     }__;
4500    
4501     @Method:
4502 wakaba 1.44 @@Name: createPCApply
4503     @@enDesc:
4504     Creates a <Q::pc:apply> element node.
4505     @@Return:
4506     @@@Type: PCApply
4507     @@@enDesc: The newly created element node.
4508     @@@PerlDef:
4509     __DEEP{
4510     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'apply');
4511     }__;
4512    
4513     @Method:
4514 wakaba 1.43 @@Name: createPCFunctionCall
4515     @@enDesc:
4516 wakaba 1.44 Creates a function call element node.
4517 wakaba 1.43 @@Param:
4518     @@@Name: package
4519     @@@Type: DOMString
4520     @@@enDesc:
4521     The package to which the function belongs.
4522     @@@nullCase:
4523     @@@@enDesc: No package name.
4524     @@Param:
4525     @@@Name: localName
4526     @@@Type: DOMString
4527     @@@enDesc:
4528     The local part of the function name.
4529     @@Return:
4530 wakaba 1.44 @@@Type: PCApply
4531 wakaba 1.43 @@@enDesc:
4532     The newly created function object.
4533     @@@PerlDef:
4534     __DEEP{
4535 wakaba 1.44 $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'apply');
4536     my $func = $self-><M::PCDocument.createPCVariable>
4537     ('', $package, $localName);
4538     $r-><M::Node.appendChild> ($func);
4539     }__;
4540    
4541     @Method:
4542 wakaba 1.46 @@Name: createPCStatement
4543     @@enDesc:
4544     Creates a statement object.
4545     @@Return:
4546     @@@Type: PerlStatement
4547     @@@enDesc:
4548     The newly created statement element node.
4549     @@@PerlDef:
4550     __DEEP{
4551     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'statement');
4552     }__;
4553    
4554     @Method:
4555 wakaba 1.44 @@Name: createPCBlock
4556     @@enDesc:
4557     Creates a <Q::pc2:block> element node.
4558     @@Return:
4559     @@@Type: PCBlock
4560     @@@enDesc:
4561     The newly created <Q::pc2:block> element.
4562     @@@PerlDef:
4563     __DEEP{
4564     $r = $self-><M::Document.createElementNS> (<Q::pc2:>, 'block');
4565 wakaba 1.43 }__;
4566    
4567     @Method:
4568     @@Name: createPCChoose
4569     @@enDesc:
4570     Creates a <Q::pc:choose> element node.
4571     @@Return:
4572     @@@Type: PCChoose
4573     @@@enDesc:
4574     The newly created <Q::pc:choose> element.
4575     @@@PerlDef:
4576     __DEEP{
4577     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'choose');
4578 wakaba 1.45 }__;
4579    
4580     @Method:
4581     @@Name: createPCWhile
4582     @@enDesc:
4583     Creates a <Q::pc:while> element node.
4584     @@Return:
4585     @@@Type: PCWhile
4586     @@@enDesc:
4587     The newly created <Q::pc:while> element.
4588     @@@PerlDef:
4589     __DEEP{
4590     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'while');
4591     $r-><M::Node.appendChild>
4592     ($self-><M::Document.createElementNS> (<Q::pc2:>, 'condition'));
4593     $r-><M::Node.appendChild>
4594     ($self-><M::Document.createElementNS> (<Q::pc2:>, 'block'));
4595 wakaba 1.41 }__;
4596 wakaba 1.46
4597     @Method:
4598     @@Name: createPerlSub
4599     @@enDesc:
4600     Creates a new <IF::PerlSub> object.
4601     @@Param:
4602     @@@Name: subName
4603     @@@Type: DOMString
4604     @@@enDesc:
4605     The name of the subroutine to create.
4606     @@@nullCase:
4607     @@@@enDesc:
4608     The subroutine created has no name.
4609     @@Return:
4610     @@@Type: PerlSub
4611     @@@enDesc:
4612     Newly created Perl subroutine object.
4613     @@@PerlDef:
4614     __DEEP{
4615     $r = $self-><M::Document.createElementNS> (<Q::pc:>, 'sub');
4616     $r-><M::PerlSub.addPerlName> ($subName) if defined $subName;
4617     }__;
4618 wakaba 1.41 ##PCDocument
4619    
4620 wakaba 1.39 ## -- Implementation
4621 wakaba 1.6
4622 wakaba 1.25 IFClsDef:
4623     @IFQName: PCImplementation
4624 wakaba 1.35 @CQName: ManakaiPCImplementation
4625 wakaba 1.25
4626 wakaba 1.1 @enDesc:
4627     The class that provides factory methods.
4628 wakaba 1.20
4629 wakaba 1.35 @CISA: DOMCore|ManakaiDOMImplementation||ManakaiDOM|ManakaiDOMLatest
4630     @CISA: dx|ManakaiDefaultExceptionHandler||ManakaiDOM|Perl
4631 wakaba 1.17
4632 wakaba 1.35 @f:provides: pc|CoreFeature10
4633 wakaba 1.1
4634     @Method:
4635     @@Name: createPerlFile
4636     @@enDesc:
4637     Creates a Perl code file.
4638     @@Return:
4639 wakaba 1.25 @@@Type: PerlFile
4640 wakaba 1.1 @@@enDesc: A newly created Perl source file object.
4641     @@@PerlDef:
4642 wakaba 1.35 __DEEP{
4643     $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4644     -><AG::Document.documentElement>;
4645     }__;
4646 wakaba 1.1
4647 wakaba 1.13 @Method:
4648     @@Name: createPerlPackage
4649     @@enDesc:
4650     Creates a new package scope block.
4651     @@Param:
4652     @@@Name: packageName
4653 wakaba 1.35 @@@Type: DOMString
4654 wakaba 1.13 @@@enDesc:
4655     The fully-qualified name of the package to create.
4656     @@Return:
4657 wakaba 1.25 @@@Type: PerlPackage
4658 wakaba 1.13 @@@enDesc:
4659     The newly created package scope object.
4660     @@@PerlDef:
4661 wakaba 1.35 __DEEP{
4662 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4663 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'package');
4664     $r-><AS::PerlPackage.packageName> ($packageName);
4665     }__;
4666 wakaba 1.13
4667 wakaba 1.1 @IntMethod:
4668 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4669 wakaba 1.1 @@Name: perlComment
4670     @@ManakaiDOM:isStatic:1
4671     @@enDesc:
4672     Generates a Perl comment string.
4673     @@Param:
4674     @@@Name: str
4675 wakaba 1.35 @@@Type: DOMString
4676 wakaba 1.1 @@@enDesc:
4677     A comment text.
4678     @@Return:
4679 wakaba 1.35 @@@Type: DOMString
4680 wakaba 1.1 @@@enDesc:
4681     A Perl comment string.
4682     @@@PerlDef:
4683     $r = $str;
4684     $r =~ s/\n/\n## /g;
4685     $r =~ s/\n## $/\n/s;
4686     $r .= "\n" unless $r =~ /\n$/;
4687     $r = q<## > . $r;
4688    
4689     @IntMethod:
4690 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4691 wakaba 1.1 @@Name: rfc3339DateTime
4692     @@ManakaiDOM:isStatic:1
4693     @@enDesc:
4694     Returns RFC 3339 <CODE::date-time> representation of a date.
4695     @@Param:
4696     @@@Name: perlDate
4697 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
4698 wakaba 1.1 @@@enDesc:
4699     A Perl representation of date.
4700     @@Return:
4701 wakaba 1.35 @@@Type: DOMString
4702 wakaba 1.1 @@@enDesc:
4703     RFC 3339 date string.
4704     @@@PerlDef:
4705     my @time = gmtime $perlDate;
4706     $r = sprintf q<%04d-%02d-%02dT%02d:%02d:%02d+00:00>,
4707     $time[5] + 1900, $time[4] + 1, @time[3,2,1,0];
4708    
4709     @IntMethod:
4710 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
4711 wakaba 1.1 @@Name: versionDateTime
4712     @@ManakaiDOM:isStatic:1
4713     @@enDesc:
4714     Returns date for version.
4715     @@Param:
4716     @@@Name: perlDate
4717 wakaba 1.35 @@@Type: idl|unsignedLong||ManakaiDOM|all
4718 wakaba 1.1 @@@enDesc:
4719     A Perl representation of date.
4720     @@Return:
4721 wakaba 1.35 @@@Type: DOMString
4722 wakaba 1.1 @@@enDesc:
4723     A Perl number literal.
4724     @@@PerlDef:
4725     my @time = gmtime $perlDate;
4726     $r = sprintf q<%04d%02d%02d.%02d%02d>,
4727     $time[5] + 1900, $time[4] + 1, @time[3,2,1];
4728    
4729     @Method:
4730     @@Name: perlLiteral
4731     @@enDesc:
4732     Perl code representation.
4733     @@Param:
4734     @@@Name: val
4735 wakaba 1.35 @@@Type: DISPerl|Any||ManakaiDOM|all
4736 wakaba 1.1 @@@enDesc:
4737     A Perl value.
4738     @@Return:
4739 wakaba 1.35 @@@Type: DOMString
4740 wakaba 1.1 @@@enDesc:
4741     A Perl lexical representation of <P::val>.
4742     @@@PerlDef:
4743     unless (defined $val) {
4744     $r = q<undef>;
4745     } elsif (ref $val eq 'ARRAY') {
4746     __DEEP{
4747 wakaba 1.36 $r = q<[> . <ClassM::ManakaiPCImplementation
4748 wakaba 1.14 .perlList> ($val) . q<]>;
4749 wakaba 1.1 }__;
4750     } elsif (ref $val eq 'HASH') {
4751     __DEEP{
4752 wakaba 1.31 $r = q<{>
4753 wakaba 1.36 . <ClassM::ManakaiPCImplementation.perlList>
4754 wakaba 1.31 ([map {$_ => $val->{$_}} sort {$a cmp $b} keys %$val])
4755     . q<}>;
4756 wakaba 1.1 }__;
4757 wakaba 1.38 } elsif (ref $val eq 'manakai::code') {
4758     $r = $$val;
4759 wakaba 1.1 } else {
4760     $val =~ s/(['\\])/\\$1/g;
4761     $r = q<'> . $val . q<'>;
4762     }
4763    
4764     @Method:
4765     @@Name: perlList
4766     @@enDesc:
4767     Perl code representation of a list.
4768     @@Param:
4769     @@@Name: val
4770 wakaba 1.35 @@@Type: DISPerl|ARRAY||ManakaiDOM|all
4771 wakaba 1.1 @@@enDesc:
4772     A Perl array reference.
4773     @@Return:
4774 wakaba 1.35 @@@Type: DOMString
4775 wakaba 1.1 @@@enDesc:
4776     A Perl lexical representation of <CODE::@$val>.
4777     @@@PerlDef:
4778     __DEEP{
4779 wakaba 1.36 $r = join (q<, >, map {<ClassM::ManakaiPCImplementation
4780 wakaba 1.1 .perlLiteral> ($_)} @{$val});
4781     }__;
4782 wakaba 1.5
4783     @Method:
4784     @@Name: createPerlSub
4785     @@enDesc:
4786 wakaba 1.35 Creates a new <IF::PerlSub> object.
4787 wakaba 1.5 @@Param:
4788     @@@Name: subName
4789 wakaba 1.35 @@@Type: DOMString
4790 wakaba 1.5 @@@enDesc:
4791     The name of the subroutine to create.
4792     @@@nullCase:
4793     @@@@enDesc:
4794     The subroutine created has no name.
4795     @@Return:
4796 wakaba 1.25 @@@Type: PerlSub
4797 wakaba 1.5 @@@enDesc:
4798     Newly created Perl subroutine object.
4799     @@@PerlDef:
4800 wakaba 1.35 __DEEP{
4801 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4802 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'sub');
4803     $r-><M::PerlSub.addPerlName> ($subName) if defined $subName;
4804     }__;
4805 wakaba 1.5
4806     @Method:
4807     @@Name: createPerlUnparsedCode
4808     @@enDesc:
4809     Creates a new <Class::ManakaiPerlUnparsedCode> object.
4810     @@Param:
4811     @@@Name: codeArg
4812 wakaba 1.35 @@@Type: DOMString
4813 wakaba 1.5 @@@enDesc:
4814     The code fragment.
4815     @@@nullCase:
4816     @@@@enDesc:
4817     The fragment initially has no code.
4818     @@Return:
4819 wakaba 1.25 @@@Type: PerlUnparsedCode
4820 wakaba 1.5 @@@enDesc:
4821     Newly created Perl code object.
4822     @@@PerlDef:
4823 wakaba 1.35 __DEEP{
4824 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4825 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'unparsed');
4826     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4827     }__;
4828 wakaba 1.6
4829     @Method:
4830     @@Name: createPerlInlineContainer
4831     @@enDesc:
4832 wakaba 1.35 Creates a new <IF::PerlInlineContainer> object.
4833 wakaba 1.6 @@Return:
4834 wakaba 1.25 @@@Type: PerlCodeInlines
4835 wakaba 1.6 @@@enDesc:
4836     Newly created Perl code object.
4837     @@@PerlDef:
4838 wakaba 1.35 __DEEP{
4839 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4840 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'inlineContainer');
4841     }__;
4842 wakaba 1.6
4843     @Method:
4844     @@Name: createPerlInlineUnparsedCode
4845     @@enDesc:
4846 wakaba 1.35 Creates a new <IF::PerlInlineUnparsedCode> object.
4847 wakaba 1.6 @@Param:
4848     @@@Name: codeArg
4849 wakaba 1.35 @@@Type: DOMString
4850 wakaba 1.6 @@@enDesc:
4851     The code fragment.
4852     @@@nullCase:
4853     @@@@enDesc:
4854     The fragment initially has no code.
4855     @@Return:
4856 wakaba 1.25 @@@Type: PerlInlineUnparsedCode
4857 wakaba 1.6 @@@enDesc:
4858     Newly created Perl code object.
4859     @@@PerlDef:
4860 wakaba 1.35 __DEEP{
4861 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4862 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'inlineUnparsed');
4863     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4864     }__;
4865 wakaba 1.6
4866     @Method:
4867     @@Name: createPerlBare
4868     @@enDesc:
4869 wakaba 1.35 Creates a new <IF::PerlTokens> object.
4870 wakaba 1.6 @@Param:
4871     @@@Name: codeArg
4872 wakaba 1.35 @@@Type: DOMString
4873 wakaba 1.6 @@@enDesc:
4874     The code fragment.
4875     @@Return:
4876 wakaba 1.25 @@@Type: PerlTokens
4877 wakaba 1.6 @@@enDesc:
4878     Newly created Perl code object.
4879     @@@PerlDef:
4880 wakaba 1.35 __DEEP{
4881 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4882 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'tokens');
4883     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4884     }__;
4885 wakaba 1.6
4886     @Method:
4887     @@Name: createPerlAtom
4888     @@enDesc:
4889 wakaba 1.35 Creates a new <IF::PerlAtom> object.
4890 wakaba 1.6 @@Param:
4891     @@@Name: codeArg
4892 wakaba 1.35 @@@Type: DOMString
4893 wakaba 1.6 @@@enDesc:
4894     The code fragment.
4895     @@Return:
4896 wakaba 1.25 @@@Type: PerlAtom
4897 wakaba 1.6 @@@enDesc:
4898     Newly created Perl code object.
4899     @@@PerlDef:
4900 wakaba 1.35 __DEEP{
4901 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4902 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'atom');
4903     $r-><AS::Node.textContent> ($codeArg) if defined $codeArg;
4904     }__;
4905 wakaba 1.6
4906     @Method:
4907     @@Name: createPerlStringLiteral
4908     @@enDesc:
4909 wakaba 1.35 Creates a new <IF::PerlStringLiteral> object.
4910 wakaba 1.6 @@Param:
4911     @@@Name: stringArg
4912 wakaba 1.35 @@@Type: DOMString
4913 wakaba 1.6 @@@enDesc: A string.
4914     @@Return:
4915 wakaba 1.25 @@@Type: PerlStringLiteral
4916 wakaba 1.6 @@@enDesc:
4917     Newly created Perl code object.
4918     @@@PerlDef:
4919 wakaba 1.35 __DEEP{
4920 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4921 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'stringLiteral');
4922     $r-><AS::Node.textContent> ($stringArg);
4923     }__;
4924 wakaba 1.6
4925     @Method:
4926     @@Name: createPerlVariable
4927     @@enDesc:
4928 wakaba 1.35 Creates a new <IF::PerlVariable> object.
4929 wakaba 1.6 @@Param:
4930     @@@Name: variableType
4931 wakaba 1.35 @@@Type: DOMString
4932 wakaba 1.6 @@@enDesc:
4933     Variable prefix.
4934 wakaba 1.16 @@@nullCase:
4935     @@@@enDesc:
4936     If the <P::packageName> is <DOM::null>, then
4937     the <P::variableType> is detected by the prefix of
4938     <P::localName>. Otherwise, it is an unprefixed variable
4939     such as file handle.
4940 wakaba 1.6 @@Param:
4941     @@@Name: packageName
4942 wakaba 1.35 @@@Type: DOMString
4943 wakaba 1.6 @@@enDesc:
4944     Package name.
4945     @@@nullCase:
4946     @@@@enDesc:
4947     The variable belongs to the current package or a
4948     lexical-scoped variable.
4949     @@Param:
4950     @@@Name: localName
4951 wakaba 1.35 @@@Type: DOMString
4952 wakaba 1.6 @@@enDesc:
4953 wakaba 1.16 Variable name. If both <P::variableType> and <P::packageName>
4954     is <DOM::null>, the <P::localName> value may be prefixed
4955     by any possible <P::variableType> value.
4956 wakaba 1.6 @@Return:
4957 wakaba 1.25 @@@Type: PerlVariable
4958 wakaba 1.6 @@@enDesc:
4959     Newly created Perl variable object.
4960     @@@PerlDef:
4961 wakaba 1.35 __DEEP{
4962 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4963 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'variable');
4964     if (not $variableType and not $packageName and
4965     $localName =~ s/^(\\?[\$\@%&*])//) {
4966     $variableType = $1;
4967     }
4968     $r-><AS::PerlVariable.variableType> ($variableType)
4969     if defined $variableType;
4970     $r-><AS::PerlVariable.packageName> ($packageName)
4971     if defined $packageName;
4972     $r-><AS::PerlVariable.pcLocalName> ($localName);
4973     }__;
4974 wakaba 1.8
4975     @Method:
4976     @@Name: createPerlBlock
4977     @@enDesc:
4978 wakaba 1.35 Creates a new <IF::PerlBlock> object.
4979 wakaba 1.8 @@Return:
4980 wakaba 1.25 @@@Type: PerlBlock
4981 wakaba 1.8 @@@enDesc:
4982     Newly created Perl code object.
4983     @@@PerlDef:
4984 wakaba 1.35 __DEEP{
4985 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
4986 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'block');
4987     }__;
4988 wakaba 1.9
4989     @Method:
4990     @@Name: createPerlBlockContainer
4991     @@enDesc:
4992     Creates a new <Class::ManakaiPerlBlockContainer> object.
4993     @@Return:
4994 wakaba 1.25 @@@Type: PerlCodeBlocks
4995 wakaba 1.9 @@@enDesc:
4996     Newly created Perl code object.
4997     @@@PerlDef:
4998 wakaba 1.35 __DEEP{
4999 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5000 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'blockContainer');
5001     }__;
5002 wakaba 1.11
5003     @Method:
5004     @@Name: createPerlStatement
5005     @@enDesc:
5006     Creates a new Perl statement.
5007     @@Param:
5008     @@@Name: codeArg
5009 wakaba 1.35 @@@Type: DOMString
5010 wakaba 1.11 @@@enDesc:
5011     A Perl statement without terminating <Perl::;>.
5012     @@@nullCase:
5013     @@@@enDesc:
5014     No initial content.
5015     @@Return:
5016 wakaba 1.25 @@@Type: PerlStatement
5017 wakaba 1.11 @@@enDesc:
5018     The newly created Perl code object.
5019     @@@PerlDef:
5020 wakaba 1.35 __DEEP{
5021 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5022 wakaba 1.35 -><M::Document.createElementNS> (<Q::pc:>, 'statement');
5023     if (defined $codeArg) {
5024     $r-><M::PerlCodeUnits.appendBare> ($codeArg);
5025     }
5026     }__;
5027 wakaba 1.12
5028     @Method:
5029     @@Name: createPerlIf
5030     @@enDesc:
5031 wakaba 1.35 Creates a <IF::PerlIf> object.
5032 wakaba 1.12 @@Param:
5033     @@@Name: conditionArg
5034 wakaba 1.35 @@@Type: PerlCodeInlines
5035 wakaba 1.12 @@@enDesc:
5036     Conditoon code fragment object.
5037     @@Param:
5038     @@@Name: trueArg
5039 wakaba 1.35 @@@Type: PerlCodeBlocks
5040 wakaba 1.12 @@@enDesc:
5041     A true code fragment object.
5042     @@@nullCase:
5043     @@@@enDesc: No true code.
5044     @@Param:
5045     @@@Name: falseArg
5046 wakaba 1.35 @@@Type: PerlCodeBlocks
5047 wakaba 1.12 @@@enDesc:
5048     A false code fragment object.
5049     @@@nullCase:
5050     @@@@enDesc: No false code.
5051     @@Return:
5052 wakaba 1.25 @@@Type: PerlIf
5053 wakaba 1.12 @@@RaiseException:
5054     @@@@@:BAD_CHILD_ERR
5055     @@@@enDesc:
5056     An attempt is made to append a child
5057     that is not valid type.
5058     @@@RaiseException:
5059     @@@@@:IN_USE_NODE_ERR
5060     @@@@enDesc:
5061     An attempt is made to append a node that is
5062     already used elsewhere.
5063     @@@PerlDef:
5064 wakaba 1.35 for my $arg ([conditionArg => $conditionArg]) {
5065     if ({
5066     atom => 1, tokens => 1, inlineContainer => 1, assignment => true,
5067     inlineUnparsed => 1, variable => 1, stringLiteral => true,
5068 wakaba 1.41 list => true, arrayRefLiteral => true, hashRefLiteral => true,
5069 wakaba 1.35 }->{$arg->[1]-><AG::Node.localName>}) {
5070     if ($arg->[1]-><AG::Node.parentNode>) {
5071     __EXCEPTION{IN_USE_NODE_ERR::
5072     pc:childNode => {$arg->[1]},
5073     MDOMX:param-name => {$arg->[0]},
5074     }__;
5075     }
5076     } else {
5077     __EXCEPTION{BAD_CHILD_ERR::
5078     pc:parentNode => {$self},
5079     pc:childNode => {$arg->[1]},
5080     MDOMX:param-name => {$arg->[0]},
5081     }__;
5082     }
5083     } # c
5084    
5085     for my $arg ([trueArg => $trueArg],
5086     [falseArg => $falseArg]) {
5087     next unless $arg->[1];
5088     if ({
5089     blockContainer => true,
5090     }->{$arg->[1]-><AG::Node.localName>}) {
5091     if ($arg->[1]-><AG::Node.parentNode>) {
5092     __EXCEPTION{IN_USE_NODE_ERR::
5093     pc:childNode => {$arg->[1]},
5094     MDOMX:param-name => {$arg->[0]},
5095     }__;
5096     }
5097     } else {
5098     __EXCEPTION{BAD_CHILD_ERR::
5099     pc:parentNode => {$self},
5100     pc:childNode => {$arg->[1]},
5101     MDOMX:param-name => {$arg->[0]},
5102     }__;
5103     }
5104     } # t/f
5105    
5106     __DEEP{
5107 wakaba 1.41 $r = $self-><M::DOMImpl.createDocument> (<Q::pc:>, 'file')
5108 wakaba 1.35 -><M::Document.createElementNS>
5109     (<Q::pc:>, 'if');
5110     $r-><AS::PerlIf.condition> ($conditionArg) if $conditionArg;
5111     $r-><AS::PerlIf.trueCode> ($trueArg) if $trueArg;
5112     $r-><AS::PerlIf.falseCode> ($falseArg) if $falseArg;
5113     }__;
5114 wakaba 1.25 ##PCImplementation
5115 wakaba 1.1
5116 wakaba 1.5 ResourceDef:
5117 wakaba 1.35 @QName: DOMImpl
5118     @AliasFor: DOMCore|DOMImplementation
5119 wakaba 1.41 @For: ManakaiDOM|DOM
5120    
5121     ResourceDef:
5122     @QName: NodeList
5123     @AliasFor: DOMCore|NodeList
5124 wakaba 1.35 @For: ManakaiDOM|DOM
5125    
5126     ResourceDef:
5127     @QName: Node
5128     @AliasFor: DOMCore|Node
5129     @For: ManakaiDOM|DOM
5130    
5131     ResourceDef:
5132     @QName: Element
5133     @AliasFor: DOMCore|Element
5134     @For: ManakaiDOM|DOM
5135    
5136     ResourceDef:
5137     @QName: Document
5138     @AliasFor: DOMCore|Document
5139     @For: ManakaiDOM|DOM
5140    
5141 wakaba 1.4 ## -- Exceptions
5142    
5143 wakaba 1.25 ResourceDef:
5144     @rdf:type:
5145     @@@: dis|MultipleResource
5146     @@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
5147     @resourceFor: ManakaiDOM|ForIF
5148     @resourceFor: ManakaiDOM|ForClass
5149    
5150     @For: ManakaiDOM|Perl
5151    
5152     @rdf:type:
5153 wakaba 1.33 @@@: dx|Interface
5154 wakaba 1.25 @@ForCheck: ManakaiDOM|ForIF
5155    
5156     @rdf:type:
5157 wakaba 1.33 @@@: dx|Class
5158 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
5159    
5160     @Implement:
5161 wakaba 1.35 @@@: ||ManakaiDOM|ManakaiDOM|ManakaiDOM||ManakaiDOM|ForIF
5162     @@ContentType: DISCore|TFPQNames
5163     @@ForCheck: ManakaiDOM|ForClass
5164     @Implement:
5165     @@@: ||ManakaiDOM|ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
5166 wakaba 1.25 @@ContentType: DISCore|TFPQNames
5167     @@ForCheck: ManakaiDOM|ForClass
5168 wakaba 1.35 @dx:implementedBy: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForClass
5169 wakaba 1.25
5170 wakaba 1.35 @f:implements: pc|CoreFeature10
5171 wakaba 1.25
5172     @ISA:
5173 wakaba 1.33 @@@: dx|Exception||ManakaiDOM|Perl
5174 wakaba 1.25 @@ForCheck: ManakaiDOM|ForClass
5175    
5176     @IFQName: PCException
5177 wakaba 1.35 @QName:
5178     @@@: ManakaiPCException
5179     @@ForCheck: ManakaiDOM|ForClass
5180 wakaba 1.25
5181 wakaba 1.4 @enDesc:
5182 wakaba 1.25 Exceptions for the <Module::Util:PerlCode> module.
5183    
5184     @ResourceDef:
5185 wakaba 1.33 @@ForCheck: ManakaiDOM|ForIF
5186     @@rdf:type: DISLang|ConstGroup
5187 wakaba 1.25
5188     @@IFQName: PCExceptionCode
5189    
5190 wakaba 1.4 @@enDesc:
5191 wakaba 1.25 Exception codes for <IF::PCException>.
5192    
5193 wakaba 1.33 @@Type: idl|unsignedShort||ManakaiDOM|all
5194     @@rdfs:subClassOf: idl|unsignedShort||ManakaiDOM|all
5195 wakaba 1.25
5196 wakaba 1.5 @@XConstDef:
5197     @@@Name: HIERARCHY_REQUEST_ERR
5198 wakaba 1.27 @@@Value:
5199     @@@@@:3
5200     @@@@ContentType: DISCore|Integer
5201 wakaba 1.5 @@@enDesc:
5202     An attempt is made to break the hierarchy.
5203     @@@XSubTypeDef:
5204     @@@@QName: BAD_CHILD_ERR
5205     @@@@enDesc:
5206     An attempt is made to append a node as a child whose type
5207     is not allowed.
5208     @@@@XParam:
5209     @@@@@QName: childNode
5210     @@@@@enDesc:
5211     The node attempted to append.
5212     @@@@XParam:
5213     @@@@@QName: parentNode
5214     @@@@@enDesc:
5215     The node to whose child list an attempt to append is made.
5216     @@@XSubTypeDef:
5217     @@@@QName: IN_USE_NODE_ERR
5218     @@@@enDesc:
5219     An attempt is made to append a node that has already been used
5220     elsewhere.
5221     @@@@XParam:
5222     @@@@@QName: childNode
5223     @@@@@enDesc:
5224     The node attempted to append.
5225     @@@@XParam:
5226     @@@@@QName: parentNode
5227     @@@@@enDesc:
5228     The parent node of the <XP::childNode>.
5229 wakaba 1.4 @@XConstDef:
5230     @@@Name: NOT_SUPPORTED_ERR
5231 wakaba 1.27 @@@Value:
5232     @@@@@:9
5233     @@@@ContentType: DISCore|Integer
5234 wakaba 1.4 @@@enDesc:
5235     An attempt is made to do something the implementation does not support.
5236     @@@XSubTypeDef:
5237     @@@@QName: UNSUPPORTED_OPERATOR_ERR
5238     @@@@enDesc:
5239     The implementation does not support the specified operator.
5240     @@@@XParam:
5241     @@@@@QName: operator
5242     @@@@@enDesc:
5243     The operator that is not supported.
5244     @@@@enMufDef:
5245     Operator "%p (name => {<Q::pc:operator>});" is not supported
5246 wakaba 1.25 ##PCException
5247 wakaba 1.4
5248     ElementTypeBinding:
5249     @Name: XConstDef
5250     @ElementType:
5251     dis:ResourceDef
5252     @ShadowContent:
5253 wakaba 1.33 @@rdf:type: dx|ErrorCode
5254 wakaba 1.4
5255     ElementTypeBinding:
5256     @Name: XSubTypeDef
5257     @ElementType:
5258     dis:ResourceDef
5259     @ShadowContent:
5260 wakaba 1.33 @@rdf:type: dx|ErrorSubCode
5261 wakaba 1.4
5262     ElementTypeBinding:
5263     @Name: XParam
5264     @ElementType:
5265 wakaba 1.33 ecore:hasParameter
5266 wakaba 1.4
5267     ElementTypeBinding:
5268     @Name: XParamDef
5269     @ElementType:
5270     dis:ResourceDef
5271     @ShadowContent:
5272 wakaba 1.33 @@rdf:type: ecore|Parameter
5273 wakaba 1.27 @@For: =ManakaiDOM|all
5274 wakaba 1.4
5275     ElementTypeBinding:
5276     @Name: enMufDef
5277     @ElementType:
5278 wakaba 1.40 ecore:defaultMessage
5279 wakaba 1.4 @ShadowContent:
5280     @@ContentType:
5281     lang:muf
5282     @@lang:en
5283    
5284 wakaba 1.1 ElementTypeBinding:
5285     @Name: Method
5286     @ElementType:
5287     dis:ResourceDef
5288     @ShadowContent:
5289     @@rdf:type:
5290     DISLang:Method
5291    
5292     ElementTypeBinding:
5293     @Name: ToStringMethod
5294     @ElementType:
5295     dis:ResourceDef
5296     @ShadowContent:
5297     @@rdf:type:
5298     DISLang:Method
5299     @@Operator:
5300     @@@@:
5301     DISPerl:AsStringMethod
5302 wakaba 1.35 @@@ContentType: DISCore|QName
5303 wakaba 1.1 @@Description:
5304     @@@lang:en
5305     @@@@:
5306     Returns the textual Perl source code representation of this object.
5307 wakaba 1.9
5308 wakaba 1.14 ElementTypeBinding:
5309     @Name: NumValMethod
5310     @ElementType:
5311     dis:ResourceDef
5312     @ShadowContent:
5313     @@rdf:type:
5314     DISLang:Method
5315     @@Operator:
5316     @@@@: 0+
5317     @@@ContentType:
5318     lang:Perl
5319     @@Description:
5320     @@@lang:en
5321     @@@@:
5322     Returns the numeric value of this object.
5323 wakaba 1.9
5324     ElementTypeBinding:
5325 wakaba 1.1 @Name: IntMethod
5326     @ElementType:
5327     dis:ResourceDef
5328     @ShadowContent:
5329     @@rdf:type:
5330     DISLang:Method
5331     @@ManakaiDOM:isForInternal:1
5332    
5333     ElementTypeBinding:
5334     @Name: Attr
5335     @ElementType:
5336     dis:ResourceDef
5337     @ShadowContent:
5338     @@rdf:type:
5339     DISLang:Attribute
5340    
5341     ElementTypeBinding:
5342     @Name: Return
5343     @ElementType:
5344     dis:ResourceDef
5345     @ShadowContent:
5346     @@rdf:type:
5347     DISLang:MethodReturn
5348    
5349     ElementTypeBinding:
5350     @Name: Get
5351     @ElementType:
5352     dis:ResourceDef
5353     @ShadowContent:
5354     @@rdf:type:
5355     DISLang:AttributeGet
5356    
5357     ElementTypeBinding:
5358     @Name: Set
5359     @ElementType:
5360     dis:ResourceDef
5361     @ShadowContent:
5362     @@rdf:type:
5363     DISLang:AttributeSet
5364    
5365     ElementTypeBinding:
5366     @Name: Param
5367     @ElementType:
5368     dis:ResourceDef
5369     @ShadowContent:
5370     @@rdf:type:
5371     DISLang:MethodParameter
5372    
5373     ElementTypeBinding:
5374     @Name: PerlDef
5375     @ElementType:
5376     dis:Def
5377     @ShadowContent:
5378     @@ContentType:
5379     lang:Perl
5380 wakaba 1.27 @@ForCheck: ManakaiDOM|ForClass
5381 wakaba 1.28
5382     ElementTypeBinding:
5383     @Name: PerlCDef
5384     @ElementType:
5385     dis:Def
5386     @ShadowContent:
5387     @@ContentType:
5388     lang:Perl
5389 wakaba 1.1
5390     ElementTypeBinding:
5391     @Name: disDef
5392     @ElementType:
5393     dis:Def
5394     @ShadowContent:
5395     @@ContentType:
5396     lang:dis
5397 wakaba 1.27 @@ForCheck: ManakaiDOM|ForClass
5398 wakaba 1.1
5399     ElementTypeBinding:
5400     @Name: InCase
5401     @ElementType:
5402     dis:ResourceDef
5403     @ShadowContent:
5404     @@rdf:type:
5405     ManakaiDOM:InCase
5406    
5407     ElementTypeBinding:
5408     @Name: nullCase
5409     @ElementType:
5410     dis:ResourceDef
5411     @ShadowContent:
5412     @@rdf:type:
5413     ManakaiDOM:InCase
5414     @@Value:
5415     @@@is-null:1
5416    
5417     ElementTypeBinding:
5418     @Name: TrueCase
5419     @ElementType:
5420     dis:ResourceDef
5421     @ShadowContent:
5422     @@rdf:type:
5423     ManakaiDOM:InCase
5424 wakaba 1.27 @@Value:
5425     @@@@:1
5426     @@@ContentType: DISCore|Boolean
5427 wakaba 1.1 @@Type:
5428 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
5429 wakaba 1.1
5430    
5431     ElementTypeBinding:
5432     @Name: FalseCase
5433     @ElementType:
5434     dis:ResourceDef
5435     @ShadowContent:
5436     @@rdf:type:
5437     ManakaiDOM:InCase
5438 wakaba 1.27 @@Value:
5439     @@@@:0
5440     @@@ContentType: DISCore|Boolean
5441 wakaba 1.1 @@Type:
5442 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
5443 wakaba 1.1
5444     ElementTypeBinding:
5445     @Name: enDesc
5446     @ElementType:
5447     dis:Description
5448     @ShadowContent:
5449     @@lang:en
5450    
5451     ElementTypeBinding:
5452     @Name: PropDef
5453     @ElementType:
5454     dis:ResourceDef
5455     @ShadowContent:
5456     @@rdf:type:
5457     rdf:Property
5458 wakaba 1.27 @@For: =ManakaiDOM|all
5459 wakaba 1.1
5460     ElementTypeBinding:
5461     @Name: NamedParam
5462     @ElementType:
5463     dis:ResourceDef
5464     @ShadowContent:
5465     @@rdf:type:
5466     DISLang:MethodParameter
5467     @@DISPerl:isNamedParameter:1
5468    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24