/[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.41 - (hide annotations) (download)
Tue Nov 15 03:12:57 2005 UTC (19 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.40: +362 -15 lines
++ manakai/lib/Message/Util/ChangeLog	15 Nov 2005 03:09:25 -0000
2005-11-15  Wakaba  <wakaba@suika.fam.cx>

	* Makefile: Rules to make |DIS/Test.pm| added. |DIS/common.dis| rules
	added.

	* DIS.dis (DIS:): Removed (moved to |DIS/common.dis|).

2005-11-13  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PCList, PCArrayRefLiteral, PCHashRefLiteral):
	New interfaces.
	(createPCLiteral, appendNewPCLiteral): New methods.
	(PCDocument): New interface.
	(factory methods): Namespace URI and local name of document
	element arguments added to |createDocument| to obtain
	an instance of |PCDocument|.

++ manakai/lib/Message/Util/DIS/ChangeLog	15 Nov 2005 03:11:47 -0000
2005-11-15  Wakaba  <wakaba@suika.fam.cx>

	* DISDoc.dis, DISDump.dis, DISPerl.dis (Require): References
	new |common.dis| module for the sake of |DIS:| module group.

	* common.dis: New module.

	* DISPerl.dis (plCodeFragment): Throws an exception
	if a "ISA" package does not have Perl name.

	* Value.dis: Type name |dis:TypeQName| changed to |DISCore:QName|.

++ manakai/lib/Message/DOM/ChangeLog	15 Nov 2005 03:09:45 -0000
2005-11-15  Wakaba  <wakaba@suika.fam.cx>

	* DOMFeature.dis (stringifyFeatures): Don't double |SPACE|
	characters between feature names and versions.

2005-11-13  Wakaba  <wakaba@suika.fam.cx>

	* DOMFeature.dis (stringifyFeatures): A test code added.

++ manakai/lib/manakai/ChangeLog	15 Nov 2005 03:12:39 -0000
	* Test.dis: New module.

	* Makefile: |Test.dis| added.

2005-11-13  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24