/[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.43 - (hide annotations) (download)
Wed Dec 14 11:57:13 2005 UTC (19 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.42: +532 -11 lines
++ manakai/lib/Message/Util/ChangeLog	14 Dec 2005 11:45:31 -0000
2005-12-14  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCExpression, PCChoose, PCWhen, PCOtherwise): New
	interfaces and element types.
	(getChildElementByType): New code.
	(PCFunctionCall): New interface and element type.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24