/[suikacvs]/messaging/manakai/lib/Message/Util/DIS.dis
Suika

Contents of /messaging/manakai/lib/Message/Util/DIS.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.35 - (hide annotations) (download)
Wed May 11 14:07:41 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.34: +28 -8 lines
LSInput for bootstrap added; lib/Message/DOM/DOMLS.dis is now dac-compilable

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14 wakaba 1.14 This module provides an object model for <QUOTE::dis> document format.
15 wakaba 1.1
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24 wakaba 1.19 manakai <CODE::lib/manakai/dis.pl> and <CODE::bin/cdis2pm.pl>
25 wakaba 1.1 @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.35 $Date: 2005/05/09 11:59:32 $
32 wakaba 1.1 @@ContentType:
33     dis:Date.RCS
34    
35     @Require:
36     @@Module:
37     @@@Name: SuikaWikiConfig21
38 wakaba 1.5 @@@QName:
39     Markup:SuikaWikiConfig21
40 wakaba 1.1 @@@WithFor:
41 wakaba 1.3 swcfg21:ForLatest
42     @@Module:
43     @@@Name: DIS
44     @@@WithFor:
45     DIS:ForLatest
46 wakaba 1.12 @@Module:
47     @@@Name: PerlCode
48     @@@WithFor:
49     ManakaiDOM:Perl
50 wakaba 1.3
51     @DefaultFor:
52     DIS:ForLatest
53 wakaba 1.1
54     Namespace:
55     @DIS:
56     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
57     @dis:
58     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
59     @dis2pm:
60     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
61 wakaba 1.5 @DISlib:
62     http://suika.fam.cx/~wakaba/archive/2004/dis/
63 wakaba 1.13 @disPerl:
64     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl--
65 wakaba 1.3 @DOMCore:
66     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
67 wakaba 1.30 @DOMException:
68     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#
69 wakaba 1.3 @DOMLS:
70     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
71     @DOMMain:
72     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
73     @infoset:
74     http://www.w3.org/2001/04/infoset#
75 wakaba 1.1 @lang:
76     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
77     @license:
78     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
79     @ManakaiDOM:
80     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
81 wakaba 1.5 @Markup:
82     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
83 wakaba 1.3 @MDOMX:
84     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
85 wakaba 1.1 @owl:
86     http://www.w3.org/2002/07/owl#
87     @Perl:
88     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
89     @rdf:
90     http://www.w3.org/1999/02/22-rdf-syntax-ns#
91     @rdfs:
92     http://www.w3.org/2000/01/rdf-schema#
93 wakaba 1.32 @s:
94     http://suika.fam.cx/~wakaba/archive/2004/dis/Markup#
95 wakaba 1.3 @swcfg21:
96     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
97 wakaba 1.1 @TreeCore:\
98     @Util:
99     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
100    
101     ## -- "For" definitions
102    
103     ForDef:
104     @QName:
105     DIS:ForLatest
106     @Description:
107     @@lang:en
108     @@@:
109     For latest version of the <Module::Util:DIS> module implementation
110     @ISA:
111     ManakaiDOM:Perl
112    
113     ## -- Features
114    
115     ElementTypeBinding:
116     @Name: FeatureDef
117     @ElementType:
118     dis:ResourceDef
119     @ShadowContent:
120     @@rdf:type:
121     DOMMain:DOMFeature
122 wakaba 1.24 @@ForCheck:
123     ManakaiDOM:all
124 wakaba 1.1
125     ElementTypeBinding:
126     @Name: FeatureVerDef
127     @ElementType:
128     dis:ResourceDef
129     @ShadowContent:
130     @@rdf:type:
131     DOMMain:DOMFeature
132    
133     ElementTypeBinding:
134     @Name: featureQName
135     @ElementType:
136     dis:AppName
137     @ShadowContent:
138     @@ContentType:
139     dis:TypeQName
140    
141     FeatureDef:
142     @QName: Core
143     @FeatureVerDef:
144     @@QName: CoreFeature10
145     @@Version: 1.0
146 wakaba 1.24 @@DOMMetaImpl:instanceFeatureOf: Core
147 wakaba 1.1 @@FullName:
148     @@@lang:en
149     @@@@:
150     The <QUOTE::dis> object model, version 1.0
151     @@Description:
152     @@@lang:en
153     @@@@:
154     The <QUOTE::dis> object model, version 1.0.
155     @@DOMMain:requireFeature:
156     swcfg21:CoreFeature21
157    
158     ## -- SuikaWikiConfig/2.1 extended classes
159    
160     ClsDef:
161     @ClsQName: ManakaiDISImplementation
162     @ClsISA:
163 wakaba 1.3 swcfg21:ManakaiSWCFGImplementation::swcfg21:ForLatest
164 wakaba 1.1 @Description:
165     @@lang:en
166     @@@:
167     A <QUOTE::dis> implementation object.
168    
169     @Method:
170     @@Name: createDISDocument
171     @@Description:
172     @@@lang:en
173     @@@@:
174     Creates an empty <Class::ManakaiDISDocument> object.
175     @@Return:
176     @@@Type:ManakaiDISDocument
177     @@@Description:
178     @@@@lang:en
179     @@@@@:
180     The newly created <QUOTE::dis> document object.
181     @@@PerlDef:
182 wakaba 1.29 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
183     .createSWCFGDocument>,
184     <ClassName::ManakaiDISDocument>;
185 wakaba 1.3 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
186     .defaultElementTypeNamespaceURI>
187 wakaba 1.1 (<Q::dis:>);
188    
189     @Method:
190 wakaba 1.2 @@Name: createDISParser
191     @@Description:
192     @@@lang:en
193     @@@@:
194 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
195 wakaba 1.2 @@Return:
196     @@@Type: ManakaiDISParser
197     @@@Description:
198     @@@@lang:en
199     @@@@@:
200 wakaba 1.1 A newly created <QUOTE::dis> parser.
201 wakaba 1.2 @@@PerlDef:
202 wakaba 1.3 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
203     .createSWCFGParser>,
204 wakaba 1.1 <ClassName::ManakaiDISParser>;
205    
206     @Method:
207 wakaba 1.2 @@Name: createDISDatabase
208 wakaba 1.1 @@Description:
209     @@@lang:en
210     @@@@:
211 wakaba 1.2 Creates a new <QUOTE::dis> database.
212 wakaba 1.1 @@Return:
213 wakaba 1.2 @@@Type:ManakaiDISDatabase
214 wakaba 1.4 @@@Description:
215     @@@@lang:en
216     @@@@@:
217 wakaba 1.2 A newly created <QUOTE::dis> parser.
218 wakaba 1.4 @@@PerlDef:
219 wakaba 1.2 $r = bless {
220     forDef => {
221 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
222 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
223     isa => {<Q::ManakaiDOM:all> => 1},
224     revISA => {},
225 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
226 wakaba 1.2 },
227     resDef => {},
228 wakaba 1.9 modDef => {},
229     seq => 0,
230 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
231    
232     @Method:
233     @@Name: tfurisToURI
234     @@Description:
235     @@@lang:en
236     @@@@:
237     Converts a pair of name URI reference and <QUOTE::for> URI reference
238     into a <TYPE::dis:TFQNames>-expanded URI reference.
239     @@Param:
240     @@@Name: typeURI
241     @@@Type: NameURI
242     @@@Description:
243     @@@@lang:en
244     @@@@@:
245     A URI reference to identify a resource.
246     @@@InCase:
247     @@@@Value:
248     @@@@@is-null:1
249     @@@@Description:
250     @@@@@lang:en
251     @@@@@@:
252     Equivalent to <Q::DOMMain:any> (for historical reason).
253     @@Param:
254     @@@Name: forURI
255     @@@Type: ForURI
256     @@@Description:
257     @@@@lang:en
258     @@@@@:
259     A <QUOTE::for> URI reference.
260     @@@InCase:
261     @@@@Value:
262     @@@@@is-null:1
263     @@@@Description:
264     @@@@@lang:en
265     @@@@@@:
266     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
267     @@Return:
268     @@@Type:
269     DISCore:TFURI::ManakaiDOM:all
270     @@@Description:
271     @@@@lang:en
272     @@@@@:
273     The <TYPE::dis:TFQNames>-expanded URI references.
274     @@@PerlDef:
275     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
276     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
277 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
278    
279     @ResourceDef:
280     @@QName: tfurisToURI
281     @@rdf:type:
282     dis2pm:BlockCode
283     @@enDesc:
284     Converts a pair of name URI reference and <QUOTE::for> URI reference
285     into a <TYPE::dis:TFQNames>-expanded URI reference.
286     @@PerlDef:
287     if ($furi eq <Q::ManakaiDOM:all>) {
288     $uri = $turi;
289 wakaba 1.3 } else {
290     ## NOTE: [RFC 3986]
291     ## fragment := *(pchar / "/" / "?")
292     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
293     ## unreserved := ALPHA / DIGIT / [._~-]
294     ## sub-delims := [!$&'()*+,;=]
295     ## NOTE: [XPointer Framework]
296     ## SchemeData := *EscapedData
297     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
298     ## / "(" SchemeData ")"
299     ## NormalChar := UnicodeChar - [()^]
300 wakaba 1.5 my $__turi = $turi;
301     my $__furi = $furi;
302     for my $__uri ($__turi, $__furi) {
303 wakaba 1.4 $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
304 wakaba 1.3 }
305 wakaba 1.4 $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
306 wakaba 1.5 qq<t:tf($__turi,$__furi)>;
307 wakaba 1.3 }
308 wakaba 1.2
309 wakaba 1.5 @ResourceDef:
310 wakaba 1.6 @@QName: tfpurisToURI
311     @@rdf:type:
312     dis2pm:BlockCode
313     @@enDesc:
314     Converts a set of name URI reference and <QUOTE::for> URI reference
315     and <QUOTE::for+> URI references into a URi reference.
316     @@PerlDef:
317     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
318     $uri = $turi;
319     } elsif (@{$forp}) {
320     my $__turi = $turi;
321     my $__furi = $furi;
322     for my $__uri ($__turi, $__furi) {
323     $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
324     }
325     my @__fp;
326     for my $__uri (@{$forp}) {
327     my $__fpuri = $__uri;
328     $__fpuri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}
329     {sprintf '%%%02X', ord $1}ge;
330     push @__fp, $__fpuri;
331     }
332     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
333     qq<t:tfp($__turi,$__furi,>.join (',', @__fp).q<)>;
334     } else {
335     my $__turi = $turi;
336     my $__furi = $furi;
337     for my $__uri ($__turi, $__furi) {
338     $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
339     }
340     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
341     qq<t:tf($__turi,$__furi)>;
342     }
343    
344     @ResourceDef:
345 wakaba 1.5 @@QName: getChildResourceURI
346     @@rdf:type:
347     dis2pm:BlockCode
348     @@enDesc:
349     Gets an anonymous URI reference of a child resource of another
350     resource.
351     @@PerlDef:
352     my $__parent = $parentURI;
353     my $__ln = $localName;
354     for my $__uri ($__parent, $__ln) {
355 wakaba 1.6 $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
356 wakaba 1.5 }
357     $result = q<data:,200411tf#xmlns(t=data:,200411tf%23)>.
358     qq<t:child($__parent,$__ln)>;
359    
360 wakaba 1.8 @IntMethod:
361     @@Name: camelCaseToUnderscoreName
362     @@enDesc:
363     Converts a camelCase name to a underscored_name.
364     @@ManakaiDOM:isStatic:1
365     @@Param:
366     @@@Name: camelName
367     @@@Type:
368 wakaba 1.18 DISLang:String::ManakaiDOM:all
369 wakaba 1.8 @@@enDesc:
370     The source name.
371     @@Return:
372     @@@Type:
373 wakaba 1.18 DISLang:String::ManakaiDOM:all
374 wakaba 1.8 @@@enDesc:
375     The result name.
376     @@@PerlDef:
377     $r = $camelName;
378     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
379     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
380     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
381     $r =~ s/([A-Z])/"_".lc $1/ge;
382     $r =~ s/(?=[0-9](?!$))/_/g;
383 wakaba 1.9
384     @Method:
385     @@Name: plLoadDISDatabase
386     @@enDesc:
387     Loads a database from a file that was saved by
388     <M::ManakaiDISDatabase.plStore>.
389     \
390     {NOTE:: <QUOTE::dis> documents restored from external file
391     would have different <A::ManakaiDISDocument.implementation>
392     than this <Class::ManakaiDISImplementation>, even if
393     it has been created by this implementation
394     and stored in the same session.
395     \
396     }
397     @@Param:
398     @@@Name:fileName
399     @@@Type:
400 wakaba 1.18 DISLang:String::ManakaiDOM:all
401 wakaba 1.9 @@@enDesc:
402     An environment-dependent file name.
403     @@Return:
404     @@@Type: ManakaiDISDatabase
405     @@@SimpleException:
406     @@@PerlDef:
407     use Storable qw/retrieve/;
408     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
409     $r = retrieve $fileName;
410    
411     ## Restores weak references
412     require Scalar::Util;
413     for my $doc (values %{$r->{<Q::DIS:sourceFile>}}) {
414     Scalar::Util::weaken ($doc->{<Q::TreeCore:node>}->{<Q::DIS:db>});
415     }
416     for my $def (values %{$r->{modDef}},
417     values %{$r->{forDef}},
418     values %{$r->{resDef}}) {
419     Scalar::Util::weaken ($def->{db});
420     }
421 wakaba 1.24
422     @DOMMetaImpl:provideFeature: CoreFeature10
423 wakaba 1.1 ##DISImplementation
424    
425 wakaba 1.9 ElementTypeBinding:
426     @Name: SimpleException
427     @ElementType:
428     dis:Description
429     @ShadowContent:
430     @@lang:en
431     @@@:
432     - Exception of type <PerlModule::Error::Simple>:::
433     I/O error or other error reported by <PerlModule::Storable>.
434    
435     ## TODO: Formal description required for simple exception
436    
437 wakaba 1.1 ClsDef:
438     @ClsQName: ManakaiDISParser
439     @ClsISA:
440 wakaba 1.3 swcfg21:ManakaiSWCFGParser::swcfg21:ForLatest
441 wakaba 1.1 @Description:
442     @@lang:en
443     @@@:
444     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
445     @Method:
446 wakaba 1.3 @@Name: parse
447     @@Description:
448     @@@lang:en
449     @@@@:
450 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
451 wakaba 1.3 @@Param:
452     @@@Name: input
453     @@@Type:
454     DOMLS:LSInput::ManakaiDOM:ManakaiDOM3
455     @@@Description:
456     @@@@lang:en
457     @@@@@:
458 wakaba 1.1 The input source.
459 wakaba 1.3 @@Return:
460     @@@Type: ManakaiDISDocument
461     @@@Description:
462     @@@@lang:en
463     @@@@@:
464 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
465     @@@RaiseException:
466     @@@@@:
467     swcfg21:SWCFG_PARSE_ERR
468     @@@@Description:
469     @@@@@lang:en
470     @@@@@@:
471     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
472     document.
473     @@@PerlDef:
474     __DEEP{
475 wakaba 1.28 $r = $self->SUPER::parse ($input)
476     ## NOTE: Method name directly written
477     #< M::swcfg21:ManakaiSWCFGParser
478     # ::swcfg21:ForLatest.parse> ($input)
479 wakaba 1.1 }__;
480     if (defined $r) {
481     $r = bless $r, <ClassName::ManakaiDISDocument>;
482 wakaba 1.4 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
483     .defaultElementTypeNamespaceURI>
484     (<Q::dis:>);
485 wakaba 1.1 }
486     ##DISParser
487    
488     ClsDef:
489     @ClsQName: ManakaiDISNode
490     @Description:
491     @@lang:en
492     @@@:
493     <QUOTE::dis> node objects.
494 wakaba 1.7 @ImplNote:
495     @@lang:en
496     @@@:
497     This class does not inherit
498     <Class::swcfg21:ManakaiSWCFGNode::swcfg21:ForLatest>, since
499     inheriting classes such as <Class::ManakaiDISElement> indirectly
500     inherit it.
501 wakaba 1.1
502     @MethodRedef:
503     @@Name:lookupNamespacePrefix
504     @@Description:
505     @@@lang:en
506     @@@@:
507     Looks up the namespace prefix associated to the given
508     namespace URI. The default namespaces are ignored.
509     @@Param:
510     @@@Name:namespaceURI
511 wakaba 1.3 @@@Type: AnyURI
512 wakaba 1.1 @@@Description:
513     @@@@lang:en
514     @@@@@:
515     The namespace URI to look for.
516     @@@InCase:
517     @@@@Value:
518     @@@@@is-null:1
519     @@@@Description:
520     @@@@@lang:en
521     @@@@@@:
522     The <DOM::null> namespace.
523     @@NamedParam:
524     @@@Name: makeNewBinding
525     @@@Type:
526 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
527 wakaba 1.1 @@@Description:
528     @@@@lang:en
529     @@@@@:
530     Whether a new namespace prefix should be bound when
531     no namespace URI has been associated yet.
532     @@@InCase:
533     @@@@Value:true
534     @@@@Description:
535     @@@@@lang:en
536     @@@@@@:
537     New binding is made if no prefix associated.
538     @@@InCase:
539     @@@@Value:false
540     @@@@Description:
541     @@@@@lang:en
542     @@@@@@:
543     Simply returns the <DOM::null> if no prefix associated.
544     @@Return:
545     @@@Type:
546 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
547 wakaba 1.1 @@@Description:
548     @@@@lang:en
549     @@@@@:
550     An associated namespace prefix. If more than one prefix
551     are associated to the namespace URI, the returned prefix
552     is implementation dependent.
553     @@@InCase:
554     @@@@Value:
555     @@@@@is-null:1
556     @@@@Description:
557     @@@@@lang:en
558     @@@@@@:
559     No associated namespace prefix found.
560     @@@PerlDef:
561     $r = null;
562 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
563     .ownerDocument> || $self;
564 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
565 wakaba 1.1 if (defined $namespaceURI) {
566     FIND: {
567     for my $prefix (keys %$binds) {
568     if (defined $binds->{$prefix} and
569     $binds->{$prefix} eq $namespaceURI) {
570     $r = $prefix;
571     last FIND;
572     }
573     }
574 wakaba 1.7
575     ## From module list
576     try {
577     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
578     -><AG::ManakaiDISDocument.disDatabase>;
579     for my $mod_uri (keys %{$db->{modDef}}) {
580     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
581     my $mod_ln = $mod-><AG::ManakaiDISModuleDefinition.localName>;
582     next if exists $binds->{$mod_ln};
583     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
584     .getPropertyText>
585     (<Q::dis:Namespace>, '');
586     if ($ns_uri eq $namespaceURI) {
587     $r = $mod_ln;
588     last FIND;
589     }
590     }
591     } catch <Class::ManakaiDISException> with {
592     my $err = shift;
593     $err->throw
594     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
595     };
596    
597 wakaba 1.1 last FIND unless $makeNewBinding;
598     ## Not found
599     if ($namespaceURI =~ /(\w+)$/) {
600     my $prefix = $1;
601     unless (exists $binds->{$prefix}) {
602     $binds->{$prefix} = $namespaceURI;
603     $r = $prefix;
604     last FIND;
605     }
606     }
607     my $i = 1;
608     {
609     unless (exists $binds->{'ns'.$i}) {
610     $binds->{$r = 'ns'.$i} = $namespaceURI;
611     last FIND;
612     }
613     $i++;
614     redo;
615     }
616     } # FIND
617     } else { ## Null namespace
618     FIND: {
619     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
620     $r = 'nu'.'ll';
621     last FIND;
622     }
623     for my $prefix (keys %$binds) {
624     if (not defined $prefix) {
625     $r = $prefix;
626     last FIND;
627     }
628     }
629     last FIND unless $makeNewBinding;
630     ## Not found
631     my $i = '';
632     {
633     unless (exists $binds->{'nu'.'ll'.$i}) {
634     $binds->{$r = 'nu'.'ll'.$i} = null;
635     last FIND;
636     }
637     $i++;
638     redo;
639     }
640     }
641     }
642    
643     @MethodRedef:
644     @@Name:lookupNamespaceURI
645     @@Description:
646     @@@lang:en
647     @@@@:
648     Looks up the namespace URI associated to the given prefix.
649     @@Param:
650     @@@Name:prefix
651     @@@Type:
652 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
653 wakaba 1.1 @@@Description:
654     @@@@lang:en
655     @@@@@:
656     The namespace URI to look for.
657     @@NamedParam:
658     @@@Name: makeNewBinding
659     @@@Type:
660 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
661 wakaba 1.1 @@@Description:
662     @@@@lang:en
663     @@@@@:
664     Whether a new binding should be created if no namespace URI
665     is associated with the <P::prefix> or not.
666     @@@InCase:
667     @@@@Value:true
668     @@@@Description:
669     @@@@@lang:en
670     @@@@@@:
671     A new binding to the temporary namespace URI
672     exactly same as <P::prefix> is created
673     if no binding found.
674     @@@InCase:
675     @@@@Value:false
676     @@@@Description:
677     @@@@@lang:en
678     @@@@@@:
679     No new binding is created if no binding found. Note that
680     even if no association newly created, this method
681     returns the <DOM::null> value.
682 wakaba 1.12 @@NamedParam:
683     @@@Name: raisePrefixException
684     @@@Type:
685 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
686 wakaba 1.12 @@@enDesc:
687     Whehter an exception should be thrown if <P::prefix>
688     is not declared or not.
689 wakaba 1.1 @@Return:
690 wakaba 1.3 @@@Type: AnyURI
691 wakaba 1.1 @@@Description:
692     @@@@lang:en
693     @@@@@:The associated namespace URI.
694     @@@InCase:
695     @@@@Value:
696     @@@@@is-null:1
697     @@@@Description:
698     @@@@@lang:en
699     @@@@@@:
700 wakaba 1.3 No namespace URI is associated to the prefix or
701 wakaba 1.1 the <DOM::null> namespace is associated.
702 wakaba 1.12 @@@UndeclaredPrefixException:
703 wakaba 1.1 @@@PerlDef:
704 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
705     .ownerDocument> || $self;
706 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
707 wakaba 1.1 if (exists $binds->{$prefix}) {
708     $r = $binds->{$prefix};
709     } else {
710 wakaba 1.7 ## From module list
711     FIND: {
712     try {
713     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
714     -><AG::ManakaiDISDocument.disDatabase>;
715     for my $mod_uri (keys %{$db->{modDef}}) {
716     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
717     if ($mod-><AG::ManakaiDISModuleDefinition.localName>
718     eq $prefix) {
719     $r = $mod-><M::ManakaiDISPropertyAccessor
720     .getPropertyText>
721     (<Q::dis:Namespace>, null);
722     last FIND;
723     }
724     }
725     } catch <Class::ManakaiDISException> with {
726     my $err = shift;
727     $err->throw
728     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
729     };
730     if ($makeNewBinding) {
731     $r = $binds->{$prefix} = $prefix;
732 wakaba 1.12 } elsif ($raisePrefixException) {
733     __EXCEPTION{DIS:UNDECLARED_NS_PREFIX_ERR::
734     infoset:prefix => {$prefix},
735     MDOMX:param-name => 'prefix',
736     DIS:sourceNode => {$self},
737     }__;
738 wakaba 1.7 } else {
739     $r = null;
740     }
741     } # FIND
742 wakaba 1.1 }
743    
744     @IntMethod:
745     @@Name:getNodeReference
746     @@Description:
747     @@@lang:en
748     @@@@:
749     Returns a new reference to the node object.
750     @@ManakaiDOM:isStatic:1
751     @@Param:
752     @@@Name:object
753     @@@Type:
754     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
755     @@@Description:
756     @@@@lang:en
757     @@@@@:
758     The node object to be referred.
759     @@Return:
760     @@@Type: ManakaiDISNode
761     @@@Description:
762     @@@@lang:en
763     @@@@@:
764     A newly created reference.
765     @@@PerlDef:
766     my $class;
767 wakaba 1.5 if ($object->{<Q::swcfg21:nodeType>} eq '#element') {
768 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
769 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#comment') {
770 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
771 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#document') {
772 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
773 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#fragment') {
774 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
775     } else {
776     __ASSERT{DISPerl:invariant::
777 wakaba 1.5 msg => {qq[Node type: "$object->{<Q::swcfg21:nodeType>}" ].
778 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
779     }__;
780     }
781     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
782     .newReference> ($class);
783    
784 wakaba 1.2 @Attr:
785     @@Name:ownerDISDocument
786     @@Description:
787     @@@lang:en
788     @@@@:
789     The <QUOTE::dis> document object associated with this node.
790     @@Get:
791 wakaba 1.3 @@@Type:ManakaiDISDocument
792 wakaba 1.2 @@@Description:
793     @@@@lang:en
794     @@@@@:
795     The document object associated with this node.
796     @@@InCase:
797     @@@@Value:
798     @@@@@is-null:1
799     @@@@Description:
800     @@@@@lang:en
801     @@@@@@:
802     This node is a document node.
803     @@@PerlDef:
804     $r = <ClassM::ManakaiDISNode.getNodeReference>
805 wakaba 1.22 ($self->{<Q::TreeCore:node>}->{<Q::swcfg21:ownerDocument>})
806     if $self->{<Q::TreeCore:node>}->{<Q::swcfg21:ownerDocument>};
807 wakaba 1.1 ##DISNode
808    
809     ClsDef:
810     @ClsQName: ManakaiDISElement
811 wakaba 1.7 @ClsISA: ManakaiDISNode
812 wakaba 1.1 @ClsISA:
813 wakaba 1.3 swcfg21:ManakaiSWCFGElement::swcfg21:ForLatest
814 wakaba 1.1 @Description:
815     @@lang:en
816     @@@:
817     <QUOTE::dis> element node objects.
818    
819     @Method:
820     @@Name: forMatch
821     @@Description:
822     @@@lang:en
823     @@@@:
824     Tests whether this element is for a <QUOTE::for> or not.
825     @@Param:
826     @@@Name: forArg
827     @@@Type: ForURI
828     @@@Description:
829     @@@@lang:en
830     @@@@@:
831     The <QUOTE::For> URI reference to test against.
832     @@Param:
833     @@@Name: forpArg
834     @@@Type: ForURIList
835     @@@Description:
836     @@@@lang:en
837     @@@@@:
838     The <QUOTE::For+> URI references to test against.
839     @@@InCase:
840     @@@@Value:
841     @@@@@is-null:1
842     @@@@Description:
843     @@@@@lang:en
844     @@@@@@:
845     No additional <QUOTE::For> URI reference.
846 wakaba 1.3 Equivalent to an empty array reference.
847 wakaba 1.1 @@Return:
848     @@@Type:
849 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
850 wakaba 1.1 @@@Description:
851     @@@@lang:en
852     @@@@@:
853     Whether this element is for <P::forArg> and <P::forpArg> or not.
854 wakaba 1.2 @@@UndeclaredPrefixException:
855     @@@NoDBException:
856     @@@PerlDef:
857 wakaba 1.3 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
858     $forpArg ||= [];
859 wakaba 1.2
860     FORMATCH: {
861     __DEEP{
862 wakaba 1.10 my $for_res = $self-><AG::ManakaiDISNode.ownerDISDocument>
863     -><AG::ManakaiDISDocument.disDatabase>
864     -><M::ManakaiDISDatabase.getFor> ($forArg);
865     my $forp_res = [map {
866     $self-><AG::ManakaiDISNode.ownerDISDocument>
867     -><AG::ManakaiDISDocument.disDatabase>
868     -><M::ManakaiDISDatabase.getFor> ($_)
869     } @{$forpArg}];
870    
871     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
872 wakaba 1.2 for my $ce (@ce) {
873 wakaba 1.3 my $et = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
874     .expandedURI>;
875 wakaba 1.2 if ($et eq <Q::dis:ForCheck>) {
876 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
877     ::swcfg21:ForLatest.value>];
878 wakaba 1.9 FCs: for my $f (@$fors) {
879 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
880 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
881 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
882     -><AG::ManakaiDISDocument.disDatabase>
883     -><M::ManakaiDISDatabase.getFor> ($uri);
884 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
885 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
886     if ($arg_res eq $for) {
887 wakaba 1.2 $r = false;
888     last FORMATCH;
889     }
890     }
891     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
892 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
893 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
894     -><AG::ManakaiDISDocument.disDatabase>
895     -><M::ManakaiDISDatabase.getFor> ($uri);
896 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
897 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
898     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
899 wakaba 1.2 $r = false;
900     last FORMATCH;
901     }
902     }
903     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
904 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
905 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
906     -><AG::ManakaiDISDocument.disDatabase>
907     -><M::ManakaiDISDatabase.getFor> ($uri);
908 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
909 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
910     if ($arg_res eq $for) {
911 wakaba 1.2 next FCs;
912     }
913     }
914     $r = false;
915     last FORMATCH;
916     } else { ## -- ISA
917 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
918 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
919     -><AG::ManakaiDISDocument.disDatabase>
920     -><M::ManakaiDISDatabase.getFor> ($uri);
921 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
922 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
923     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
924 wakaba 1.2 next FCs;
925     }
926     }
927     $r = false;
928     last FORMATCH;
929     }
930     } # FCs
931     } # dis:ForCheck
932     } # children
933    
934     my $has_for = false;
935     for my $ce (@ce) {
936 wakaba 1.11 if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
937 wakaba 1.3 .expandedURI> eq
938 wakaba 1.2 <Q::dis:For>) {
939 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
940     ::swcfg21:ForLatest.value>];
941 wakaba 1.2 my $ok = true;
942     $has_for = true;
943 wakaba 1.9 AFOR: for my $f (@$fors) {
944 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
945 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
946 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
947     -><AG::ManakaiDISDocument.disDatabase>
948     -><M::ManakaiDISDatabase.getFor> ($uri);
949 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
950 wakaba 1.10 if ($for eq $for_res) {
951 wakaba 1.2 $ok = false;
952     last AFOR;
953     }
954     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
955 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
956 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
957     -><AG::ManakaiDISDocument.disDatabase>
958     -><M::ManakaiDISDatabase.getFor> ($uri);
959 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
960 wakaba 1.10 if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
961 wakaba 1.2 $ok = false;
962     last AFOR;
963     }
964     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
965 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
966 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
967     -><AG::ManakaiDISDocument.disDatabase>
968     -><M::ManakaiDISDatabase.getFor> ($uri);
969 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
970 wakaba 1.10 unless ($for eq $for_res) {
971 wakaba 1.2 $ok = false;
972     last AFOR;
973     }
974     } else { ## -- ISA
975 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
976 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
977     -><AG::ManakaiDISDocument.disDatabase>
978     -><M::ManakaiDISDatabase.getFor> ($uri);
979 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
980 wakaba 1.10 unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
981 wakaba 1.2 $ok = false;
982     last AFOR;
983     }
984     }
985     } # AFOR
986 wakaba 1.3 if ($ok) {
987     $r = true;
988     last FORMATCH;
989     }
990 wakaba 1.2 } # dis:For
991     } # $ce
992     $r = $has_for ? false : true;
993     }__;
994     } # FORMATCH
995 wakaba 1.1
996     @Method:
997     @@Name: mediaTypeMatch
998     @@Description:
999     @@@lang:en
1000     @@@@:
1001     Tests whether the content media type of this element matches to
1002     a type or not.
1003     @@Param:
1004     @@@Name: mediaType
1005     @@@Type: MediaTypeURI
1006     @@@Description:
1007     @@@@lang:en
1008     @@@@@:
1009     A media type URI reference to test against.
1010     @@Param:
1011 wakaba 1.3 @@@Name: defaultMediaType
1012 wakaba 1.1 @@@Type: MediaTypeURI
1013     @@@Description:
1014     @@@@lang:en
1015     @@@@@:
1016     The default media type for this element.
1017     @@@InCase:
1018     @@@@Value:
1019     @@@@@is-null:1
1020     @@@@Description:
1021     @@@@@lang:en
1022     @@@@@@:
1023     No default type provided. All <P::mediaType> will match.
1024 wakaba 1.12 @@ForParam:
1025     @@ForpParam:
1026 wakaba 1.1 @@Return:
1027     @@@Type:
1028 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1029 wakaba 1.1 @@@Description:
1030     @@@@lang:en
1031     @@@@@:
1032     Whether this element is of <P::mediaType> or not.
1033 wakaba 1.2 @@@PerlDef:
1034     if (defined $mediaType) {
1035     __DEEP{
1036     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1037 wakaba 1.12 (<Q::dis:ContentType>, for_arg => $forArg,
1038     forp_arg => $forpArg);
1039 wakaba 1.2 my $ct;
1040     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1041     $ct = $defaultMediaType unless defined $ct;
1042     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1043     -><AG::ManakaiDISDocument.disDatabase>
1044     -><M::ManakaiDISDatabase.getResource> ($ct);
1045     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
1046 wakaba 1.7 unless ($res-><M::ManakaiDISResourceDefinition
1047 wakaba 1.10 .isSubsetOfURI> ($mediaType)) {
1048 wakaba 1.2 $r = false;
1049     } else {
1050     $r = true;
1051     }
1052     }__;
1053     } else {
1054     $r = true;
1055     }
1056 wakaba 1.1
1057     @Method:
1058 wakaba 1.10 @@Name:mediaTypeURI
1059     @@enDesc:
1060     The URI reference of the media type of this element.
1061     @@Type: MediaTypeURI
1062     @@NamedParam:
1063     @@@Name:defaultMediaType
1064     @@@Type:MediaTypeURI
1065     @@@enDesc:
1066     The default media type URI reference.
1067     @@@nullCase:
1068     @@@@enDesc:
1069     No default is specified.
1070     @@ForParam:
1071     @@ForpParam:
1072     @@Return:
1073     @@@enDesc:
1074     The media type URI reference of this element.
1075     @@@nullCase:
1076     @@@@enDesc:
1077     This element has no media type information and
1078     <P::defaultMediaType> parameter is not provided.
1079     @@@UndeclaredPrefixException:
1080     @@@PerlDef:
1081     __DEEP{
1082     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1083     (<Q::dis:ContentType>, for_arg => $forArg,
1084     forp_arg => $forpArg);
1085     $r = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1086     }__;
1087    
1088     @Method:
1089 wakaba 1.1 @@Name: prefixToURI
1090     @@Description:
1091     @@@lang:en
1092     @@@@:
1093     Converts a namespace prefix into associated URI reference.
1094     @@Param:
1095     @@@Name: prefix
1096     @@@Type:
1097 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
1098 wakaba 1.1 @@@Description:
1099     @@@@lang:en
1100     @@@@@:
1101     A namespace prefix to look for.
1102     @@@InCase:
1103     @@@@Value:
1104     @@@@@is-null:1
1105     @@@@Description:
1106     @@@@@lang:en
1107     @@@@@@:
1108     Returns the default namespace URI.
1109     @@NodeParam:
1110     @@Return:
1111 wakaba 1.3 @@@Type: AnyURI
1112 wakaba 1.1 @@@Description:
1113     @@@@lang:en
1114     @@@@@: The URI references associated.
1115     @@@UndeclaredPrefixException:
1116     @@@PerlDef:
1117 wakaba 1.3 if (defined $prefix) {
1118 wakaba 1.1 __DEEP{
1119 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1120     .lookupNamespaceURI> ($prefix);
1121 wakaba 1.1 }__;
1122     unless (defined $r) {
1123     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
1124     infoset:prefix => {$prefix},
1125     MDOMX:param-name => 'prefix',
1126     DIS:sourceNode => {$node},
1127     }__;
1128     }
1129 wakaba 1.7 } else { ## Default namespace
1130     __DEEP{
1131     $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
1132     -><AG::ManakaiDISDocument.moduleElement>
1133     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
1134     }__;
1135 wakaba 1.1 }
1136    
1137     @Method:
1138     @@QName: qnameToURI
1139     @@Description:
1140     @@@lang:en
1141     @@@@:
1142     Converts a qualified name (<TYPE::dis:TypeQName>) to
1143     an expanded URI reference.
1144     @@Param:
1145     @@@Name: qname
1146     @@@Type:
1147 wakaba 1.18 dis:TypeQName::ManakaiDOM:all
1148 wakaba 1.1 @@@Description:
1149     @@@@lang:en
1150     @@@@@:
1151     A qualified name.
1152     @@NodeParam:
1153 wakaba 1.13 @@NamedParam:
1154     @@@Name: defaultNamespaceURI
1155     @@@Type: AnyURI
1156     @@@enDesc:
1157     Default namespace URI reference.
1158     @@@nullCase:
1159     @@@@enDesc:
1160     The default namespace is the namespace defined by the module
1161     to which this resource belongs.
1162 wakaba 1.1 @@Return:
1163     @@@Type: AnyURI
1164     @@@Description:
1165     @@@@lang:en
1166     @@@@@:
1167     The expanded URI reference.
1168     @@@UndeclaredPrefixException:
1169     @@@PerlDef:
1170     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1171 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1172 wakaba 1.1 __DEEP{
1173     if (defined $lname) {
1174     $r = $self-><M::ManakaiDISElement.prefixToURI> ($prefix) . $lname;
1175     } else { ## In default namespace
1176 wakaba 1.13 if (defined $defaultNamespaceURI) {
1177     $r = $defaultNamespaceURI . $prefix;
1178     } else {
1179     $r = $self-><M::ManakaiDISElement.prefixToURI> (null) . $prefix;
1180     }
1181 wakaba 1.1 }
1182 wakaba 1.4 }__;
1183 wakaba 1.1
1184     @Method:
1185     @@QName: qnameToPair
1186     @@Description:
1187     @@@lang:en
1188     @@@@:
1189     Converts a qualified name (<TYPE::dis:TypeQName>) to
1190     a pair of namespace URI and local name.
1191     @@Param:
1192     @@@Name: qname
1193     @@@Type:
1194 wakaba 1.18 dis:TypeQName::ManakaiDOM:all
1195 wakaba 1.1 @@@Description:
1196     @@@@lang:en
1197     @@@@@:
1198     A qualified name.
1199     @@NodeParam:
1200     @@Return:
1201     @@@Type:
1202 wakaba 1.18 Perl:ARRAY::ManakaiDOM:all
1203 wakaba 1.1 @@@Description:
1204     @@@@lang:en
1205     @@@@@:
1206     A list of namespace URI and local name.
1207     @@@UndeclaredPrefixException:
1208     @@@PerlDef:
1209     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1210 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1211 wakaba 1.1 __DEEP{
1212     if (defined $lname) {
1213     $r = [$self-><M::ManakaiDISElement.prefixToURI> ($prefix), $lname];
1214     } else { ## In default namespace
1215     $r = [$self-><M::ManakaiDISElement.prefixToURI> (null), $prefix];
1216     }
1217 wakaba 1.4 }__;
1218 wakaba 1.1
1219     @Method:
1220 wakaba 1.3 @@Name: tfqnamesToURI
1221 wakaba 1.1 @@Description:
1222     @@@lang:en
1223     @@@@:
1224 wakaba 1.3 Converts a <TYPE::dis:TFQNames>
1225 wakaba 1.1 into an expanded URI reference.
1226     @@Param:
1227     @@@Name: tfqnames
1228     @@@Type:
1229 wakaba 1.18 dis:TFQNames::ManakaiDOM:all
1230 wakaba 1.1 @@@Description:
1231     @@@@lang:en
1232     @@@@@:
1233 wakaba 1.3 A <TYPE::dis:TFQNames> to identify a resource.
1234 wakaba 1.1 @@Param:
1235     @@@Name: defaultTypeURI
1236     @@@Type: NameURI
1237     @@@Description:
1238     @@@@lang:en
1239     @@@@@:
1240     A name URI reference used if it is missing from
1241     <P::tfqnames>.
1242     @@@InCase:
1243     @@@@Value:
1244     @@@@@is-null:1
1245     @@@@Description:
1246     @@@@@lang:en
1247     @@@@@@:
1248     Equivalent to <Q::DOMMain:any>.
1249     @@Param:
1250     @@@Name: defaultForURI
1251     @@@Type: ForURI
1252     @@@Description:
1253     @@@@lang:en
1254     @@@@@:
1255     A <QUOTE::for> URI reference used if it is missing from
1256     <P::tfqnames>.
1257     @@@InCase:
1258     @@@@Value:
1259     @@@@@is-null:1
1260     @@@@Description:
1261     @@@@@lang:en
1262     @@@@@@:
1263     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1264     @@NodeParam:
1265     @@Return:
1266     @@@Type:
1267 wakaba 1.3 DISCore:TFURI::ManakaiDOM:all
1268 wakaba 1.1 @@@Description:
1269     @@@@lang:en
1270     @@@@@:
1271 wakaba 1.3 The <TYPE::dis:TFQNames>-expanded URI references.
1272 wakaba 1.1 @@@UndeclaredPrefixException:
1273     @@@PerlDef:
1274 wakaba 1.15 my ($typeq, $forq) = split /\s*[:|][:|]\s*/, $tfqnames, 2;
1275 wakaba 1.1 my ($typeURI, $forURI);
1276     if (defined $forq) {
1277     __DEEP{
1278     $typeURI = $typeq eq ''
1279     ? defined $defaultTypeURI ? $defaultTypeURI
1280     : <Q::DOMMain:any>
1281     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1282     }__;
1283     if (length $forq) {
1284     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
1285     } else {
1286     $forURI = <Q::ManakaiDOM:all>;
1287     }
1288     } else { ## "For" omitted
1289     __DEEP{
1290     $typeURI = $typeq eq ''
1291     ? defined $defaultTypeURI ? $defaultTypeURI
1292     : <Q::DOMMain:any>
1293     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1294     }__;
1295 wakaba 1.3 $forURI = defined $defaultForURI ? $defaultForURI
1296     : <Q::ManakaiDOM:all>;
1297 wakaba 1.1 }
1298 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
1299 wakaba 1.2
1300     @Method:
1301 wakaba 1.33 @@Name: tfpqnamesToURI
1302     @@Description:
1303     @@@lang:en
1304     @@@@:
1305     Converts a <TYPE::DISCore:TFPQNames>
1306     into an expanded URI reference.
1307     @@Param:
1308     @@@Name: tfpqnames
1309     @@@Type:
1310     DISCore:TFPQNames::ManakaiDOM:all
1311     @@@Description:
1312     @@@@lang:en
1313     @@@@@:
1314     A <TYPE::DISCore:TFPQNames> to identify a resource.
1315     @@Param:
1316     @@@Name: defaultTypeURI
1317     @@@Type: NameURI
1318     @@@Description:
1319     @@@@lang:en
1320     @@@@@:
1321     A name URI reference used if it is missing from
1322     <P::tfqnames>.
1323     @@@InCase:
1324     @@@@Value:
1325     @@@@@is-null:1
1326     @@@@Description:
1327     @@@@@lang:en
1328     @@@@@@:
1329     Equivalent to <Q::DOMMain:any>.
1330     @@Param:
1331     @@@Name: defaultForURI
1332     @@@Type: ForURI
1333     @@@Description:
1334     @@@@lang:en
1335     @@@@@:
1336     A <QUOTE::for> URI reference used if it is missing from
1337     <P::tfqnames>.
1338     @@@InCase:
1339     @@@@Value:
1340     @@@@@is-null:1
1341     @@@@Description:
1342     @@@@@lang:en
1343     @@@@@@:
1344     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1345     @@NodeParam:
1346     @@Return:
1347     @@@Type:
1348     DISCore:TFURI::ManakaiDOM:all
1349     @@@Description:
1350     @@@@lang:en
1351     @@@@@:
1352     The <TYPE::dis:TFQNames>-expanded URI references.
1353     @@@UndeclaredPrefixException:
1354     @@@PerlDef:
1355     my ($typeq, $forq, @forpq) = split /\s*[:|][:|]\s*/, $tfpqnames;
1356     my ($typeURI, $forURI);
1357     my $forpURI = [];
1358     undef $forq if defined $forq and $forq eq '+';
1359     if (defined $forq) {
1360     __DEEP{
1361     $typeURI = $typeq eq ''
1362     ? defined $defaultTypeURI ? $defaultTypeURI
1363     : <Q::DOMMain:any>
1364     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1365     if (length $forq) {
1366     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
1367     } else {
1368     $forURI = <Q::ManakaiDOM:all>;
1369     }
1370     }__;
1371     } else { ## "For" omitted
1372     __DEEP{
1373     $typeURI = $typeq eq ''
1374     ? defined $defaultTypeURI ? $defaultTypeURI
1375     : <Q::DOMMain:any>
1376     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1377     }__;
1378     $forURI = defined $defaultForURI ? $defaultForURI
1379     : <Q::ManakaiDOM:all>;
1380     }
1381     __DEEP{
1382     for my $forpq (@forpq) {
1383     push @$forpURI, $self-><M::ManakaiDISElement.qnameToURI>
1384     ($forpq, %opt);
1385     }
1386     }__;
1387     __CODE{tfpurisToURI:: $turi => $typeURI, $furi => $forURI,
1388     $forp => $forpURI, $uri => $r}__;
1389    
1390     @Method:
1391 wakaba 1.2 @@Name: disGetAttribute
1392     @@enDesc:
1393     Gets an attribute node.
1394     @@Param:
1395     @@@Name: attrName
1396     @@@Type: AnyURI
1397     @@@enDesc:
1398     The name expanded URI of the node to retrieve.
1399     @@ForParam:
1400     @@ForpParam:
1401     @@MediaTypeParam:
1402     @@MediaTypeDefaultParam:
1403     @@Return:
1404     @@@Type: ManakaiDISElement
1405     @@@enDesc:
1406     The attribute (property) element node.
1407     @@@nullCase:
1408     @@@@enDesc:
1409     No attribute node found.
1410     @@@PerlDef:
1411 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1412     (for_arg => $forArg, forp_arg => $forpArg)}) {
1413 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1414     .expandedURI> eq $attrName and
1415 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1416     ($mediaType, $defaultMediaType,
1417     for_arg => $forArg, forp_arg => $forpArg)) {
1418 wakaba 1.2 $r = $c;
1419     last;
1420     }
1421     }
1422    
1423     @Method:
1424     @@Name: disGetAttributeList
1425     @@enDesc:
1426     Gets attribute nodes.
1427 wakaba 1.3 @@Param:
1428     @@@Name: attrName
1429     @@@Type: AnyURI
1430     @@@enDesc:
1431     The name expanded URI of the node to retrieve.
1432 wakaba 1.2 @@ForParam:
1433     @@ForpParam:
1434     @@MediaTypeParam:
1435     @@MediaTypeDefaultParam:
1436     @@Return:
1437     @@@Type: ManakaiDISElementList
1438     @@@enDesc:
1439     The attribute (property) element nodes.
1440     @@@PerlDef:
1441     $r = bless [], <ClassName::ManakaiDISElementList>;
1442 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1443     (for_arg => $forArg, forp_arg => $forpArg)}) {
1444 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1445     .expandedURI> eq $attrName and
1446 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1447     ($mediaType, $defaultMediaType,
1448     for_arg => $forArg, forp_arg => $forpArg)) {
1449 wakaba 1.2 push @$r, $c;
1450     }
1451     }
1452    
1453 wakaba 1.4 @Method:
1454 wakaba 1.2 @@Name: disChildElements
1455     @@enDesc:
1456 wakaba 1.10 A list of child elements, with <QUOTE::for> check.
1457 wakaba 1.4 @@ForParam:
1458     @@ForpParam:
1459     @@Return:
1460     @@@Type: ManakaiDISElementList
1461 wakaba 1.2 @@@enDesc:
1462     The current snapshot of child nodes.
1463     @@@PerlDef:
1464 wakaba 1.4 $r = bless [], <ClassName::ManakaiDISElementList>;
1465     __DEEP{
1466     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1467     .childNodes>}) {
1468     ## $cn is an #element.
1469     my $dn = $cn->{<Q::TreeCore:node>}
1470     -><M::ManakaiDOM:ManakaiDOMNodeObject
1471     ::ManakaiDOM:Perl.newReference>
1472     (<ClassName::ManakaiDISElement>);
1473     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1474     push @$r, $dn;
1475     }
1476     }__;
1477 wakaba 1.5
1478 wakaba 1.10 @Method:
1479     @@Name: disAllChildElements
1480     @@enDesc:
1481     A list of child elements, without <QUOTE::for> check.
1482     @@Return:
1483     @@@Type: ManakaiDISElementList
1484     @@@enDesc:
1485     The current snapshot of child nodes.
1486     @@@PerlDef:
1487     $r = bless [], <ClassName::ManakaiDISElementList>;
1488     __DEEP{
1489     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1490     .childNodes>}) {
1491     ## $cn is an #element.
1492     my $dn = $cn->{<Q::TreeCore:node>}
1493     -><M::ManakaiDOM:ManakaiDOMNodeObject
1494     ::ManakaiDOM:Perl.newReference>
1495     (<ClassName::ManakaiDISElement>);
1496     push @$r, $dn;
1497     }
1498     }__;
1499    
1500 wakaba 1.2 @Attr:
1501     @@Name: qnameValueURI
1502     @@enDesc:
1503     The element value (written as <TYPE::dis:TypeQName>), as URI reference.
1504     \
1505     {NOTE:: What should be if list value?
1506     \
1507     }
1508     @@Get:
1509     @@@Type:AnyURI
1510     @@@nullCase:
1511     @@@@enDesc:
1512     No value.
1513     @@@UndeclaredPrefixException:
1514 wakaba 1.3 @@@PerlDef:
1515 wakaba 1.4 __DEEP{
1516 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1517 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1518 wakaba 1.14 $r = $self-><M::ManakaiDISElement.qnameToURI> ($v, node => $self);
1519 wakaba 1.4 } else {
1520     $r = null;
1521     }
1522     }__;
1523    
1524     @Attr:
1525     @@Name: qnameValueLocalName
1526     @@enDesc:
1527     The local name part of the element value (assumed as
1528     written as <TYPE::dis:TypeQName>).
1529     \
1530     {NOTE:: What should be if list value?
1531     \
1532     }
1533     @@Get:
1534     @@@Type:
1535 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
1536 wakaba 1.4 @@@nullCase:
1537     @@@@enDesc:
1538     No value.
1539     @@@PerlDef:
1540     __DEEP{
1541 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1542 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1543 wakaba 1.15 my ($n, $v) = split /\s*[:|]\s*/, $v, 2;
1544 wakaba 1.4 $r = defined $v ? $v : $n;
1545     } else {
1546     $r = null;
1547     }
1548     }__;
1549    
1550     @Attr:
1551     @@Name: qnameValueNamespaceURI
1552     @@enDesc:
1553     The namespace URI of the element value (assumed as written
1554     in <TYPE::dis:TypeQName>).
1555     \
1556     {NOTE:: What should be if list value?
1557     \
1558     }
1559     @@Get:
1560     @@@Type:AnyURI
1561     @@@nullCase:
1562     @@@@enDesc:
1563     No value.
1564     @@@UndeclaredPrefixException:
1565     @@@PerlDef:
1566     __DEEP{
1567 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1568 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1569 wakaba 1.15 my ($p, $v) = split /\s*[:|]\s*/, $v, 2;
1570 wakaba 1.14 $r = $self-><M::ManakaiDISElement.prefixToURI>
1571 wakaba 1.4 (defined $v ? $p : null);
1572     } else {
1573     $r = null;
1574     }
1575     }__;
1576 wakaba 1.2
1577 wakaba 1.6 @Method:
1578 wakaba 1.3 @@Name: tfqnamesValueURI
1579 wakaba 1.2 @@enDesc:
1580 wakaba 1.3 The element value (written as <TYPE::dis:TFQNames>),
1581 wakaba 1.2 as URI reference.
1582     \
1583     {NOTE:: What should be if list value?
1584     \
1585     }
1586 wakaba 1.6 @@Param:
1587     @@@Name: defaultTypeURI
1588     @@@Type: NameURI
1589     @@@Description:
1590     @@@@lang:en
1591     @@@@@:
1592     A name URI reference used if it is missing from
1593     <P::tfqnames>.
1594     @@@InCase:
1595     @@@@Value:
1596     @@@@@is-null:1
1597     @@@@Description:
1598     @@@@@lang:en
1599     @@@@@@:
1600     Equivalent to <Q::DOMMain:any>.
1601     @@Param:
1602     @@@Name: defaultForURI
1603     @@@Type: ForURI
1604     @@@Description:
1605     @@@@lang:en
1606     @@@@@:
1607     A <QUOTE::for> URI reference used if it is missing from
1608     <P::tfqnames>.
1609     @@@InCase:
1610     @@@@Value:
1611     @@@@@is-null:1
1612     @@@@Description:
1613     @@@@@lang:en
1614     @@@@@@:
1615     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1616 wakaba 1.33 @@ForParam:
1617     @@ForpParam:
1618 wakaba 1.6 @@Return:
1619 wakaba 1.2 @@@Type:ResourceURI
1620     @@@nullCase:
1621     @@@@enDesc:
1622     No value.
1623     @@@UndeclaredPrefixException:
1624 wakaba 1.3 @@@PerlDef:
1625 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1626 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1627     __DEEP{
1628 wakaba 1.33 if ($self-><M::ManakaiDISElement.mediaTypeMatch>
1629     (<Q::DISCore:TFPQNames>, <Q::dis:TFQNames>,
1630     for_arg => $forArg, forp_arg => $forpArg)) {
1631     $r = $self-><M::ManakaiDISElement.tfpqnamesToURI>
1632     ($v, $defaultTypeURI, $defaultForURI,
1633     node => $self);
1634     } else {
1635     $r = $self-><M::ManakaiDISElement.tfqnamesToURI>
1636     ($v, $defaultTypeURI, $defaultForURI,
1637     node => $self);
1638     }
1639 wakaba 1.2 }__;
1640     } else {
1641     $r = null;
1642     }
1643 wakaba 1.7
1644     @Method:
1645     @@Name: elementTypeMatch
1646     @@enDesc:
1647     Returns whether the element type of this element matches
1648     with another element type (either the same element type or
1649     this type is a subtype of another type).
1650     @@Param:
1651     @@@Name: etype
1652     @@@Type: ResourceURI
1653     @@@enDesc:
1654     An element type name URI reference to test.
1655     @@Return:
1656     @@@Type:
1657 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1658 wakaba 1.7 @@@TrueCase:
1659     @@@@enDesc:
1660     Either the element type expanded URI reference of this element is
1661     same as <P::etype> or it is a sub-element type of <P::etype>.
1662     @@@FalseCase:
1663     @@@@enDesc:
1664     This element is not of <P::etype>.
1665     @@@NoDBException:
1666     @@@PerlDef:
1667     __DEEP{
1668 wakaba 1.14 my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1669 wakaba 1.7 .expandedURI>;
1670     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1671     -><AG::ManakaiDISDocument.disDatabase>
1672     -><M::ManakaiDISDatabase.getResource> ($et);
1673     $r = $rdef-><M::ManakaiDISResourceDefinition.isSubsetOfURI> ($etype);
1674     }__;
1675    
1676     @Attr:
1677     @@Name: isResourceElement
1678     @@enDesc:
1679     Whether this element defines a resource or not.
1680     \
1681     {NOTE:: An element defines a resource if its element type is
1682     <Q::dis:ResourceDef> or its subtype.
1683     \
1684     }
1685     @@Get:
1686     @@@Type:
1687 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1688 wakaba 1.7 @@@TrueCase:
1689     @@@@enDesc:
1690     This element defines a resource.
1691     @@@FalseCase:
1692     @@@@enDesc:
1693     This element does not define any resource.
1694     @@@NoDBException:
1695     @@@PerlDef:
1696     __DEEP{
1697     $r = $self-><M::ManakaiDISElement.elementTypeMatch>
1698     (<Q::dis:ResourceDef>);
1699     }__;
1700    
1701     @Attr:
1702     @@Name: isPropertyElement
1703     @@enDesc:
1704     Whether this element is a property or not.
1705     \
1706     {NOTE:: An element is a property if its element type is
1707     <Q::rdf:type> or if its element type's <Q::rdf:type>
1708     property is <Q::rdf:Property> or is <Q::dis:subsetOf>
1709     <Q::rdf:Property>.
1710     \
1711     }
1712     @@Get:
1713     @@@Type:
1714 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1715 wakaba 1.7 @@@TrueCase:
1716     @@@@enDesc:
1717     This element is a property.
1718     @@@FalseCase:
1719     @@@@enDesc:
1720     This element is not a property.
1721     @@@NoDBException:
1722     @@@PerlDef:
1723     __DEEP{
1724     my $xn = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1725     .expandedURI>;
1726     if ($xn eq <Q::rdf:type>) {
1727     $r = true;
1728     } else {
1729     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1730     -><AG::ManakaiDISDocument.disDatabase>
1731     -><M::ManakaiDISDatabase.getResource> ($xn);
1732     $r = $rdef-><M::ManakaiDISResourceDefinition.isTypeURI>
1733     (<Q::rdf:Resource>);
1734     }
1735     }__;
1736 wakaba 1.18
1737     @Attr:
1738     @@Name: plImplementation
1739     @@enDesc:
1740     The <Class::PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl>
1741     object.
1742     @@Type:
1743     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
1744     @@Get:
1745     @@@nullCase:
1746     @@@@enDesc:
1747     There is no implementation that supports the feature
1748     <Feature::Util:PerlCode> version <FeatureVer:1.0>.
1749     @@@PerlDef:
1750     $r = ($self-><AG::SWCFGNode.ownerDocument> or
1751     $self)-><AG::SWCFGDoc.implementation>
1752     -><M::DOMMinImpl.getFeature>
1753     (<Q::Util:PerlCode> => '1.0');
1754    
1755     @Method:
1756     @@Name: plValueCodeFragment
1757     @@enDesc:
1758     A Perl code fragment for value attribute.
1759     @@Param:
1760     @@@Name: attrURI
1761     @@@Type: AnyURI
1762     @@@enDesc:
1763     The URI reference name of an attribute.
1764 wakaba 1.19 @@@nullCase:
1765     @@@@enDesc:
1766     This node itself is used.
1767 wakaba 1.18 @@Param:
1768 wakaba 1.23 @@@Name: disResource
1769     @@@Type: ManakaiDISResourceDefinition
1770 wakaba 1.18 @@@enDesc:
1771 wakaba 1.23 The <QUOTE::dis> resource object against which a value is evaluated.
1772 wakaba 1.18 @@ForParam:
1773     @@ForpParam:
1774     @@NamedParam:
1775     @@@Name:dataTypeURI
1776     @@@Type:
1777     ResourceURI
1778     @@@enDesc:
1779     The URI reference of a data type. It is used to convert
1780     untyped value and to define default value if <P::useDefaultValue>
1781     is set to <DOM::true>.
1782     @@@nullCase:
1783     @@@@enDesc:
1784     No data type. If the value is untyped, it is treated
1785     as if <Q::DISCore:String>.
1786     @@NamedParam:
1787     @@@Name:useDefaultValue
1788     @@@Type:
1789     DOMMain:boolean::ManakaiDOM:all
1790     @@@enDesc:
1791     Whether some default value should be provided if possible or not.
1792     @@Type:
1793     MPLCodeFragment
1794     @@Return:
1795     @@@enDesc:
1796     Perl code fragment object for value attribute.
1797     @@@nullCase:
1798     @@@@enDesc:
1799     There is no <P::attrURI> attribute.
1800     @@@UndeclaredPrefixException:
1801     @@@RaiseException:
1802     @@@@@:NO_PERL_CODE_IMPL_ERR
1803     @@@@enDesc:
1804     There is no implementation that implements
1805     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
1806     @@@PerlDef:
1807     __DEEP{
1808     my $dataType;
1809 wakaba 1.19 my $vnode = defined $attrURI
1810     ? $self-><M::ManakaiDISElement.disGetAttribute>
1811 wakaba 1.18 ($attrURI,
1812     for_arg => $forArg,
1813 wakaba 1.19 forp_arg => $forpArg)
1814     : $self;
1815 wakaba 1.18 my $plimpl = $self-><AG::ManakaiDISElement.plImplementation>;
1816     if ($vnode) {
1817     unless ($plimpl) {
1818     __UNDEEP{__EXCEPTION{NO_PERL_CODE_IMPL_ERR}__}__;
1819     }
1820     my $isnull = $vnode-><M::ManakaiDISElement.disGetAttribute>
1821     (<Q::dis:is-null>,
1822     for_arg => $forArg,
1823     forp_arg => $forpArg);
1824     if ($isnull and $isnull-><M::SWCFGNode.value>) {
1825     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('null');
1826     } else {
1827     my $vnode_type_uri = $vnode-><M::ManakaiDISElement.mediaTypeURI>;
1828     my $vnode_value = $vnode-><M::SWCFGNode.value>;
1829     if ($vnode_type_uri) {
1830 wakaba 1.23 my $vnode_type = $disResource->{db}
1831     -><M::ManakaiDISDatabase.getResource>
1832 wakaba 1.18 ($vnode_type_uri);
1833     if ($vnode_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1834     (<Q::dis:Boolean>)) {
1835     $r = $plimpl-><M::MPLImpl.createPerlAtom>
1836     ($vnode_value ? true : false);
1837     } elsif ($vnode_type-><M::ManakaiDISResourceDefinition
1838     .isSubsetOfURI>
1839     (<Q::dis:TypeQName>)) {
1840     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1841 wakaba 1.19 ($vnode-><M::ManakaiDISElement
1842 wakaba 1.18 .qnameToURI> ($vnode_value,
1843     node => $vnode));
1844 wakaba 1.23 } elsif ($vnode_type-><M::ManakaiDISResourceDefinition
1845     .isSubsetOfURI> (<Q::lang:Perl>)) {
1846     $r = $disResource-><M::ManakaiDISResourceDefinition
1847     .plPreprocessPerlStatement>
1848     ($vnode_value,
1849     node => $self,
1850     contains_statements => false);
1851 wakaba 1.18 } else { ## DISCore:String or some
1852     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1853     ($vnode_value);
1854     }
1855     } elsif ($dataTypeURI) {
1856 wakaba 1.23 $dataType ||= $disResource->{db}
1857     -><M::ManakaiDISDatabase.getResource>
1858 wakaba 1.21 ($dataTypeURI);
1859     if ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1860     (<Q::DISIDL:AnyRealNumber>)) {
1861     $r = $plimpl-><M::MPLImpl.createPerlAtom> (0 + $vnode_value);
1862     } else { ## DOMMain:DOMString or some
1863 wakaba 1.18 $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1864     ($vnode_value);
1865 wakaba 1.21 }
1866 wakaba 1.18 } else { ## Untyped
1867     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>($vnode_value);
1868     }
1869     }
1870     } # has value
1871    
1872     if (not $r and $useDefaultValue) {
1873 wakaba 1.23 $dataType ||= $disResource->{db}-><M::ManakaiDISDatabase.getResource>
1874 wakaba 1.18 ($dataTypeURI);
1875     if ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1876     (<Q::DISLang:String>)) {
1877     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral> ('');
1878     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1879     (<Q::DOMMain:boolean>) or
1880     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1881 wakaba 1.21 (<Q::DISIDL:AnyRealNumber>)) {
1882 wakaba 1.18 $r = $plimpl-><M::MPLImpl.createPerlAtom> ('0');
1883     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1884     (<Q::Perl:ARRAY>)) {
1885     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('[]');
1886     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1887     (<Q::Perl:hash>)) {
1888     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('{}');
1889     }
1890     }
1891     }__;
1892 wakaba 1.19
1893     @Method:
1894     @@Name:plCodeFragment
1895     @@enDesc:
1896     Converts <Q::lang:dis> into Perl code.
1897     @@Param:
1898     @@@Name:disResource
1899     @@@Type:ManakaiDISResourceDefinition
1900     @@@enDesc:
1901     A <QUOTE::dis> resource with which code is evaluated.
1902     @@ForParam:
1903     @@ForpParam:
1904     @@NamedParam:
1905     @@@Name:containsStatements
1906     @@@Type:
1907     DOMMain:boolean::ManakaiDOM:all
1908     @@@enDesc:
1909     Whether the code is block-level or inline-level.
1910     @@Return:
1911     @@@Type: MPLCodeFragment
1912     @@@enDesc:
1913     Perl code converted from this node.
1914     @@@disPerlException:
1915     @@@PerlDef:
1916     __DEEP{
1917     my $plimpl = $self-><AG::ManakaiDISElement.plImplementation>;
1918     my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1919     .expandedURI>;
1920     if ($et eq <Q::dis:Def>) {
1921     my $value = $self-><M::SWCFGNode.value>;
1922     if (defined $value) {
1923     __UNDEEP{__EXCEPTION{DISPERL_NO_VALUE_ALLOWED_ERR::
1924     DIS:sourceNode => {$self},
1925     DIS:elementType => {$et},
1926     }__}__;
1927     }
1928     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
1929     for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1930     (for_arg => $forArg, forp_arg => $forpArg)}) {
1931     my $ccode = $c-><M::ManakaiDISElement.plCodeFragment>
1932     ($disResource,
1933 wakaba 1.31 for_arg => $forArg, forp_arg => $forpArg,
1934     contains_statements => $containsStatements);
1935 wakaba 1.30 $r-><M::PLBlockCon.appendCodeFragment> ($ccode->clone) if $ccode;
1936 wakaba 1.19 }
1937     } elsif ({
1938     <Q::DISLang:constValue> => true,
1939     <Q::DISPerl:cloneCode> => true,
1940     }->{$et}) {
1941     my ($qname, $const_name, $on) = split /\s*\.\s*/,
1942     $self-><M::SWCFGNode.value>, 3;
1943 wakaba 1.31 my $parentResource = $disResource-><M::ManakaiDISPropertyAccessor
1944     .getPropertyResource>
1945     (<Q::dis2pm:parentResource>);
1946 wakaba 1.19 my $uri = $self-><M::ManakaiDISElement.tfqnamesToURI>
1947 wakaba 1.31 ($qname,
1948     ($parentResource-><M::ManakaiDISPropertyAccessor
1949     .getPropertyResource>
1950     (<Q::dis2pm:parentResource>) ||
1951     $parentResource || $disResource)->
1952     <AG::ManakaiDISResourceDefinition.nameURI>,
1953     $forArg, node => $self);
1954 wakaba 1.19 my $const;
1955     if (defined $const_name) {
1956     my $owner = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
1957     ($uri);
1958     $owner-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1959     if ($et eq <Q::DISLang:constValue>) {
1960     $const = $owner-><M::ManakaiDISResourceDefinition
1961     .getConstResourceByName> ($const_name);
1962     unless (defined $const) {
1963     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1964 wakaba 1.30 DIS:parentURI => {$uri},
1965 wakaba 1.19 DIS:localName => {$const_name},
1966     DIS:sourceNode => {$self},
1967     DIS:elementType => {$et},
1968     DIS:expectedType => {<Q::ManakaiDOM:Const>},
1969     }__}__;
1970     }
1971     } else {
1972     $const = $owner-><M::ManakaiDISResourceDefinition
1973     .getChildResourceByNameAndType>
1974     ($const_name, <Q::DISLang:AnyMethod>);
1975     unless (defined $const) {
1976     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1977 wakaba 1.30 DIS:parentURI => {$uri},
1978 wakaba 1.19 DIS:localName => {$const_name},
1979     DIS:sourceNode => {$self},
1980     DIS:elementType => {$et},
1981     DIS:expectedType => {<Q::DISLang:AnyMethod>},
1982     }__}__;
1983     }
1984     }
1985     } else {
1986     $const = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
1987     ($uri);
1988     }
1989     if ($const-><M::ManakaiDISResourceDefinition.isTypeURI>
1990     (<Q::ManakaiDOM:Const>)) {
1991     $const-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1992    
1993     my $data_type = $const-><AG::ManakaiDISResourceDefinition
1994     .disActualDataTypeResource>;
1995     my $val = $const->{src}-><M::ManakaiDISElement
1996     .plValueCodeFragment>
1997 wakaba 1.23 (<Q::dis:Value>, $disResource,
1998 wakaba 1.19 for_arg => $forArg,
1999     forp_arg => $forpArg,
2000     data_type_uri => $data_type
2001     -><AG::ManakaiDISResourceDefinition.uri>);
2002     unless (defined $val) {
2003     __UNDEEP{__EXCEPTION{NO_CONST_VALUE_ERR::
2004     DIS:uri => {$const->{uri}},
2005     DIS:localName => {$const->{localName}},
2006     DIS:sourceNode => {$const->{src}},
2007     DIS:elementType => {$et},
2008     }__}__;
2009     }
2010    
2011     if ($containsStatements) {
2012     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
2013     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
2014     ('$', null, 'r');
2015     $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
2016     } else {
2017     $r = $val;
2018     }
2019     } elsif ($const-><M::ManakaiDISResourceDefinition.isTypeURI>
2020     (<Q::DISLang:AnyMethod>)) {
2021 wakaba 1.22 my $ret = $const-><M::ManakaiDISResourceDefinition
2022 wakaba 1.19 .getChildResourceByType>
2023     ($const-><M::ManakaiDISResourceDefinition
2024     .isTypeURI> (<Q::DISLang:Method>)
2025     ? <Q::DISLang:MethodReturn>
2026     : ($on and $on eq 'set')
2027     ? <Q::DISLang:AttributeSet>
2028     : <Q::DISLang:AttributeGet>);
2029     unless ($ret) {
2030     __UNDEEP{
2031     if ($const-><M::ManakaiDISResourceDefinition
2032     .isTypeURI> (<Q::DISLang:Method>)) {
2033     __EXCEPTION{NO_METHOD_RETURN_ERR::
2034     DIS:errResource => {$const},
2035     DIS:sourceNode => {$const->{src}},
2036     DIS:elementType => {$et},
2037 wakaba 1.22 DIS:uri => {$const->{uri}},
2038     DIS:localName => {$const->{localName}},
2039 wakaba 1.19 }__;
2040     } elsif ($on and $on eq 'set') {
2041     __EXCEPTION{NO_ATTR_SET_ERR::
2042     DIS:errResource => {$const},
2043     DIS:sourceNode => {$const->{src}},
2044     DIS:elementType => {$et},
2045     }__;
2046     } else {
2047     __EXCEPTION{NO_ATTR_GET_ERR::
2048     DIS:errResource => {$const},
2049     DIS:sourceNode => {$const->{src}},
2050     DIS:elementType => {$et},
2051     }__;
2052     }
2053     }__; # UNDEEP
2054     }
2055     $r = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
2056     } else {
2057     if ($et eq <Q::DISLang:constValue>) {
2058     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2059     DIS:uri => {$const->{uri}},
2060     DIS:localName => {$const->{localName}},
2061     DIS:sourceNode => {$self->{src}},
2062     DIS:expectedType => {<Q::ManakaiDOM:Const>},
2063     }__}__;
2064     } else { # DISPerl:cloneCode
2065     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2066     DIS:uri => {$const->{uri}},
2067     DIS:localName => {$const->{localName}},
2068     DIS:sourceNode => {$self->{src}},
2069     DIS:expectedType => {<Q::DISLang:AnyMethod>},
2070     }__}__;
2071     }
2072     }
2073     } elsif ($et eq <Q::DISLang:value>) {
2074     my $val = $self-><M::ManakaiDISElement
2075     .plValueCodeFragment>
2076 wakaba 1.23 (null, $disResource,
2077 wakaba 1.19 for_arg => $forArg,
2078     forp_arg => $forpArg);
2079 wakaba 1.22 $r = $plimpl-><M::MPLImpl.createPerlStatement>;
2080     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
2081 wakaba 1.19 ('$', null, 'r');
2082 wakaba 1.22 $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
2083 wakaba 1.19 } elsif ({
2084     <Q::dis:GetProp> => true,
2085     <Q::dis:GetPropNode> => true,
2086     <Q::swcfg21:GetPropNode> => true,
2087     }->{$et}) {
2088     my $prop_uri = $self-><AG::ManakaiDISElement.qnameValueURI>;
2089     $disResource->{db}
2090     -><M::ManakaiDISDatabase.getResource> ($prop_uri)
2091     -><AS::ManakaiDISResourceDefinition.isReferred> ($self);
2092     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
2093     my $val = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
2094     $val-><M::PLInCon.appendCode> ('$self->{node}->{');
2095     $val-><M::PLAnyCon.appendStringLiteral> ($prop_uri);
2096     $val-><M::PLInCon.appendCode> ('}');
2097     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
2098     ('$', null, 'r');
2099     $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
2100    
2101     if ({<Q::dis:GetPropNode> => true,
2102     <Q::swcfg21:GetPropNode> => true}->{$et}) {
2103     my $q = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
2104     $q-><M::PLBlockCon.appendCodeFragment> ($r);
2105     $q-><M::PLBlockCon.appendNewIf>
2106     ($plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
2107     ('defined $r'),
2108     my $qt = $plimpl-><M::MPLImpl.createPerlBlockContainer>);
2109     $qt-><M::PLBlockCon.appendStatement>
2110     -><M::PLAnyCon.appendNewAssignment>
2111     ($rvar->clone => my $qtr = $plimpl-><M::MPLImpl
2112     .createPerlInlineContainer>);
2113     my $cls = $disResource->{db}-><M::ManakaiDISDatabase
2114     .getResource> ({
2115     <Q::dis:GetPropNode> => <Q::DOMCore:ManakaiDOMNode>,
2116     <Q::swcfg21:GetPropNode> =>
2117     <Q::swcfg21:ManakaiSWCFGNode>,
2118     }->{$et}, for_arg => $forArg);
2119     $cls-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
2120     $qtr-><M::PLInCon.appendCode>
2121     ($cls-><AG::ManakaiDISResourceDefinition
2122     .plFullyQualifiedName> . q[->_get_node_reference ($r)]);
2123     $r = $q;
2124     }
2125     } elsif ($et eq <Q::dis:SetProp>) {
2126     my $prop_uri = $self-><AG::ManakaiDISElement.qnameValueURI>;
2127     $disResource->{db}
2128     -><M::ManakaiDISDatabase.getResource> ($prop_uri)
2129     -><AS::ManakaiDISResourceDefinition.isReferred> ($self);
2130     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
2131     my $val = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
2132     $val-><M::PLInCon.appendCode> ('$self->{node}->{');
2133     $val-><M::PLAnyCon.appendStringLiteral> ($prop_uri);
2134     $val-><M::PLInCon.appendCode> ('}');
2135     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
2136     ('$', null, 'given');
2137     $r-><M::PLAnyCon.appendNewAssignment> ($val => $rvar);
2138     my $chk = $self-><M::ManakaiDISElement.disGetAttribute>
2139     (<Q::dis:CheckReadOnly>);
2140     if ($chk and $chk-><M::SWCFGNode.value>) {
2141 wakaba 1.31 my $q = $plimpl-><M::MPLImpl.createPerlIf>
2142 wakaba 1.19 (my $qc = $plimpl-><M::MPLImpl.createPerlInlineContainer>,
2143     my $qt = $plimpl-><M::MPLImpl.createPerlBlockContainer>);
2144     $qc-><M::PLInCon.appendCode> ('$self->{node}->{');
2145     $qc-><M::PLAnyCon.appendStringLiteral> (<Q::DOMCore:read-only>);
2146     $qc-><M::PLInCon.appendCode> ('}');
2147    
2148 wakaba 1.31 my $for_uri = $disResource->{db}-><M::ManakaiDISDatabase.getFor>
2149 wakaba 1.19 ($forArg)-><M::ManakaiDISForDefinition.isaURI>
2150     (<Q::ManakaiDOM:ManakaiDOM1>)
2151     ? $forArg : <Q::ManakaiDOM:ManakaiDOMLatest>;
2152 wakaba 1.31 my $cls = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
2153 wakaba 1.19 (<Q::DOMCore:DOMException>,
2154     for_arg => $for_uri);
2155 wakaba 1.31 my $const = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
2156 wakaba 1.19 (<Q::DOMCore:NO_MODIFICATION_ALLOWED_ERR>,
2157     for_arg => $for_uri);
2158 wakaba 1.31 my $subtype = $disResource->{db}
2159     -><M::ManakaiDISDatabase.getResource>
2160 wakaba 1.19 (<Q::MDOMX:NOMOD_THIS>,
2161     for_arg => $for_uri);
2162     $_-><AS::ManakaiDISResourceDefinition.isReferred>
2163     ($self) for $cls, $const, $subtype;
2164     my $context_param = $disResource-><M::ManakaiDISResourceDefinition
2165     .plGetContextParameter>;
2166     $disResource-><M::ManakaiDISResourceDefinition
2167     .plAppendThrow>
2168     ($qt, $cls, $const, $subtype,
2169     {%$context_param});
2170     $r = $q;
2171     } # Read-only checking
2172     } elsif ($et eq <Q::DOMMain:raiseException>) {
2173     my ($cls, $const, $subtype)
2174     = @{$disResource->{db}-><M::ManakaiDISDatabase.xcrefToResource>
2175     ($self-><M::SWCFGNode.value>,
2176     $self,
2177     node => $self,
2178     for_arg => $forArg)};
2179     my $context_param = $disResource-><M::ManakaiDISResourceDefinition
2180     .plGetContextParameter>;
2181     $disResource-><M::ManakaiDISResourceDefinition
2182     .plAppendThrow>
2183     ($r = $plimpl-><M::MPLImpl.createPerlBlockContainer>,
2184     $cls, $const, $subtype,
2185     {%$context_param});
2186     } elsif ({
2187     <Q::dis:ContentType> => true,
2188     <Q::dis:For> => true, <Q::dis:ForCheck> => true,
2189     <Q::dis:ImplNote> => true,
2190     <Q::DISLang:nop> => true,
2191     }->{$et}) {
2192     #
2193     } else {
2194     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
2195     DIS:sourceNode => {$self},
2196     DIS:elementType => {$et},
2197     }__}__;
2198     }
2199     }__; # DEEP
2200 wakaba 1.1 ##DISElement
2201    
2202 wakaba 1.19 ElementTypeBinding:
2203     @Name: disPerlException
2204     @ElementType:
2205     ManakaiDOM:raises
2206     @ShadowContent:
2207     @@@: DISPERL_NO_VALUE_ALLOWED_ERR
2208     @@Description:
2209     @@@lang:en
2210     @@@@:
2211     An element value is specified where it is not allowed.
2212     @ShadowSibling:
2213     @@ManakaiDOM:raises:
2214     @@@@: RESOURCE_NOT_DEFINED_ERR
2215     @@@Description:
2216     @@@@lang:en
2217     @@@@@:
2218     An undefined resource is referred or a referred resource
2219     is defined but have different type than the one expected.
2220     @@ManakaiDOM:raises:
2221     @@@@: NO_CONST_VALUE_ERR
2222     @@@Description:
2223     @@@@lang:en
2224     @@@@@:
2225     A constant value definition does not have its <Q::dis:Value>
2226     attribute.
2227     @@ManakaiDOM:raises:
2228     @@@@: NO_METHOD_RETURN_ERR
2229     @@@Description:
2230     @@@@lang:en
2231     @@@@@:
2232     A method definition does not have a <Q::DISLang:MethodReturn>
2233     child resource.
2234     @@ManakaiDOM:raises:
2235     @@@@: NO_ATTR_GET_ERR
2236     @@@Description:
2237     @@@@lang:en
2238     @@@@@:
2239     An attribute definition does not have a <Q::DISLang:AttributeGet>
2240     child resource.
2241     @@ManakaiDOM:raises:
2242     @@@@: NO_ATTR_SET_ERR
2243     @@@Description:
2244     @@@@lang:en
2245     @@@@@:
2246     An attribute setter is referred but the attribute definition
2247     does not have <Q::DISLang:AttributeSet> child resource.
2248     @@ManakaiDOM:raises:
2249     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
2250     @@@Description:
2251     @@@@lang:en
2252     @@@@@:
2253     An unsupported type of element has appeared.
2254    
2255    
2256 wakaba 1.1 ClsDef:
2257 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
2258     @ClsISA: ManakaiDISElement
2259     @enDesc:
2260     The <Q::dis:Module> elements.
2261    
2262     @Attr:
2263     @@Name: requireElement
2264     @@enDesc:
2265     The <Q::dis:Require> child element. The element is
2266     newly created if not exist.
2267     @@Type: ManakaiDISElement
2268     @@Get:
2269     @@@PerlDef:
2270     __DEEP{
2271 wakaba 1.29 $r = bless $self-><M::swcfg21:SWCFGNode
2272 wakaba 1.4 ::swcfg21:ForLatest.getAttributeNS>
2273 wakaba 1.29 (<Q::dis:>, 'Require', make_new_node => true),
2274     <ClassName::ManakaiDISElement>;
2275 wakaba 1.4 }__;
2276    
2277     @Attr:
2278     @@Name: defaultForURI
2279     @@enDesc:
2280     The value of <Q::dis:DefaultFor> attribute.
2281     @@Type: ForURI
2282     @@Get:
2283     @@@enDesc:
2284     The value of <Q::dis:DefaultFor> child element. If missing,
2285     <Q::ManakaiDOM:all> is returned.
2286     @@@PerlDef:
2287     __DEEP{
2288     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2289     .getAttributeNS>
2290     (<Q::dis:>, 'DefaultFor');
2291     if ($df) {
2292 wakaba 1.29 $r = (bless $df, <ClassName::ManakaiDISElement>)
2293     -><AG::ManakaiDISElement.qnameValueURI>
2294 wakaba 1.4 || <Q::ManakaiDOM:all>;
2295     } else {
2296     $r = <Q::ManakaiDOM:all>;
2297     }
2298     }__;
2299     @@Set:
2300     @@@PerlDef:
2301     __DEEP{
2302     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
2303     (<Q::dis:>, 'DefaultFor' => $given);
2304     }__;
2305 wakaba 1.7
2306     @Attr:
2307     @@Name: definingNamespaceURI
2308     @@enDesc:
2309     The value of <Q::dis:NamespaceURI> attribute, i.e.
2310     the URI reference of the namespace that this module primary
2311     defines.
2312     \
2313     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
2314     \
2315     }
2316     @@Type: AnyURI
2317     @@Get:
2318     @@@PerlDef:
2319     __DEEP{
2320     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2321     .getAttributeNS>
2322     (<Q::dis:>, 'Namespace');
2323     if ($df) {
2324 wakaba 1.14 $r = $df-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2325 wakaba 1.7 } else {
2326     __ASSERT{DISPerl:invariant::
2327     msg => {qq["dis:Namespace" attribute not found]},
2328     }__;
2329     }
2330     }__;
2331     @@Set:
2332     @@@PerlDef:
2333     __DEEP{
2334     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
2335     (<Q::dis:>, 'Namespace' => $given);
2336     }__;
2337 wakaba 1.4 ##DISModuleElement
2338    
2339     ClsDef:
2340 wakaba 1.2 @ClsQName: ManakaiDISElementList
2341     @enDesc:
2342     @@lang:en
2343     @@@:
2344     Lists of elements.
2345     \
2346     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
2347     later changes to the tree does not affect this type of objects.
2348     \
2349     }
2350     ##DISElementList
2351    
2352     ClsDef:
2353 wakaba 1.1 @ClsQName: ManakaiDISComment
2354 wakaba 1.7 @ClsISA: ManakaiDISNode
2355 wakaba 1.1 @ClsISA:
2356 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
2357 wakaba 1.1 @Description:
2358     @@lang:en
2359     @@@:
2360     <QUOTE::dis> comment node objects.
2361     ##DISComment
2362    
2363     ClsDef:
2364     @ClsQName: ManakaiDISDocumentFragment
2365 wakaba 1.7 @ClsISA: ManakaiDISNode
2366 wakaba 1.1 @ClsISA:
2367 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
2368 wakaba 1.1 @Description:
2369     @@lang:en
2370     @@@:
2371     <QUOTE::dis> document fragment node objects.
2372     ##DISDocumentFragment
2373    
2374     ClsDef:
2375     @ClsQName: ManakaiDISDocument
2376 wakaba 1.7 @ClsISA: ManakaiDISNode
2377 wakaba 1.1 @ClsISA:
2378 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
2379 wakaba 1.1 @Description:
2380     @@lang:en
2381     @@@:
2382     <QUOTE::dis> document node objects.
2383 wakaba 1.2
2384     @Attr:
2385 wakaba 1.4 @@Name: moduleElement
2386     @@enDesc:
2387     The <Q::dis:Module> element in this document. The element is
2388     newly created if not exist.
2389     @@Type: ManakaiDISModuleElement
2390     @@Get:
2391     @@@PerlDef:
2392     __DEEP{
2393     $r = $self-><M::swcfg21:SWCFGNode
2394     ::swcfg21:ForLatest.getAttributeNS>
2395     (<Q::dis:>, 'Module', make_new_node => true);
2396     }__;
2397     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
2398    
2399     @Attr:
2400 wakaba 1.2 @@Name: disDatabase
2401     @@enDesc:
2402     Associated <QUOTE::dis> database.
2403    
2404     @@Type: ManakaiDISDatabase
2405     @@Get:
2406     @@@NoDBException:
2407     @@@PerlDef:
2408     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
2409 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
2410 wakaba 1.2 } else {
2411     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
2412     }
2413     @@Set:
2414     @@@PerlDef:
2415     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
2416     require Scalar::Util;
2417     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
2418 wakaba 1.5
2419     @Method:
2420     @@Name: disChildElements
2421     @@enDesc:
2422 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
2423 wakaba 1.5 @@ForParam:
2424     @@ForpParam:
2425     @@Return:
2426     @@@Type: ManakaiDISElementList
2427     @@@enDesc:
2428     The current snapshot of child nodes.
2429     @@@PerlDef:
2430     $r = bless [], <ClassName::ManakaiDISElementList>;
2431     __DEEP{
2432     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2433     .childNodes>}) {
2434     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2435     .nodeType> eq '#element';
2436     my $dn = $cn->{<Q::TreeCore:node>}
2437     -><M::ManakaiDOM:ManakaiDOMNodeObject
2438     ::ManakaiDOM:Perl.newReference>
2439     (<ClassName::ManakaiDISElement>);
2440     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
2441     push @$r, $dn;
2442     }
2443     }__;
2444 wakaba 1.10
2445     @Method:
2446     @@Name: disAllChildElements
2447     @@enDesc:
2448     A list of child elements, without <QUOTE::for> checks.
2449     @@Return:
2450     @@@Type: ManakaiDISElementList
2451     @@@enDesc:
2452     The current snapshot of child nodes.
2453     @@@PerlDef:
2454     $r = bless [], <ClassName::ManakaiDISElementList>;
2455     __DEEP{
2456     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2457     .childNodes>}) {
2458     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2459     .nodeType> eq '#element';
2460     my $dn = $cn->{<Q::TreeCore:node>}
2461     -><M::ManakaiDOM:ManakaiDOMNodeObject
2462     ::ManakaiDOM:Perl.newReference>
2463     (<ClassName::ManakaiDISElement>);
2464     push @$r, $dn;
2465     }
2466     }__;
2467 wakaba 1.1 ##DISDocument
2468 wakaba 1.2
2469     PropDef:
2470     @QName: db
2471     @enDesc:
2472     Associated <QUOTE::dis> database.
2473     @rdfs:domain: ManakaiDISDocument
2474     @rdfs:range: ManakaiDISDatabase
2475    
2476     ## -- Definition object database
2477    
2478     ClsDef:
2479     @ClsQName: ManakaiDISDatabase
2480     @enDesc:
2481     Resource database created from <QUOTE::dis> source data.
2482 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2483 wakaba 1.2
2484     @Method:
2485     @@Name: getModule
2486     @@Description:
2487     @@@lang:en
2488     @@@@:
2489     Returns a <QUOTE::dis> module definition.
2490     @@Param:
2491 wakaba 1.9 @@@Name: moduleURI
2492 wakaba 1.2 @@@Type: ModuleURI
2493     @@@Description:
2494     @@@@lang:en
2495     @@@@@:
2496     A <QUOTE::dis> module URI reference.
2497 wakaba 1.9 @@ForParam:
2498 wakaba 1.2 @@Return:
2499     @@@Type: ManakaiDISModuleDefinition
2500     @@@Description:
2501     @@@@lang:en
2502     @@@@@:
2503     The module definition.
2504     @@@PerlDef:
2505 wakaba 1.9 my $modURI;
2506     if (defined $forArg) {
2507     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
2508     $uri => $modURI}__;
2509     } else {
2510     $modURI = $moduleURI;
2511     }
2512 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
2513     $r = $self->{modDef}->{$modURI};
2514     } else {
2515     $r = $self->{modDef}->{$modURI}
2516     = bless {
2517     uri => $modURI,
2518     db => $self,
2519     for => <Q::ManakaiDOM:all>,
2520     forp => [],
2521     }, <ClassName::ManakaiDISModuleDefinition>;
2522     require Scalar::Util;
2523     Scalar::Util::weaken ($r->{db});
2524     }
2525    
2526     @Method:
2527     @@Name: getFor
2528     @@Description:
2529     @@@lang:en
2530     @@@@:
2531     Returns a <QUOTE::for> definition object.
2532     @@Param:
2533     @@@Name: forURI
2534     @@@Type: ForURI
2535     @@@Description:
2536     @@@@lang:en
2537     @@@@@:
2538     A <QUOTE::for> URI reference.
2539     @@@InCase:
2540     @@@@Value:
2541     @@@@@is-null:1
2542     @@@@Description:
2543     @@@@@lang:en
2544     @@@@@@:
2545     Defaulted to <Q::ManakaiDOM:all>.
2546     @@Return:
2547     @@@Type: ManakaiDISForDefinition
2548     @@@PerlDef:
2549     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
2550     if (defined $self->{forDef}->{$forURI}) {
2551     $r = $self->{forDef}->{$forURI};
2552     } else {
2553     $r = $self->{forDef}->{$forURI}
2554     = bless {
2555     uri => $forURI,
2556     isa => {<Q::ManakaiDOM:all> => true},
2557     revISA => {},
2558     db => $self,
2559     }, <ClassName::ManakaiDISForDefinition>;
2560     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
2561     require Scalar::Util;
2562     Scalar::Util::weaken ($r->{db});
2563     }
2564    
2565     @Method:
2566     @@Name: getResource
2567     @@Description:
2568     @@@lang:en
2569     @@@@:
2570     Returns a <QUOTE::dis> resource definition.
2571     @@Param:
2572 wakaba 1.9 @@@Name: resourceURI
2573 wakaba 1.2 @@@Type: ResourceURI
2574     @@@Description:
2575     @@@@lang:en
2576     @@@@@:
2577     A <QUOTE::dis> resource URI reference.
2578 wakaba 1.3 @@@nullCase:
2579 wakaba 1.2 @@@@Description:
2580     @@@@@lang:en
2581     @@@@@@:
2582     Defaulted to <Q::DOMMain:any>.
2583 wakaba 1.9 @@ForParam:
2584 wakaba 1.2 @@Return:
2585     @@@Type: ManakaiDISResourceDefinition
2586     @@@Description:
2587     @@@@lang:en
2588     @@@@@:
2589     The resource definition.
2590     @@@PerlDef:
2591 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
2592     my $resURI;
2593     if (defined $forArg) {
2594     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
2595     $uri => $resURI}__;
2596     } else {
2597     $resURI = $resourceURI;
2598     }
2599 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
2600     $r = $self->{resDef}->{$resURI};
2601     } else {
2602     $r = $self->{resDef}->{$resURI}
2603     = bless {
2604     uri => $resURI,
2605 wakaba 1.6 aliasURI => {$resURI => true},
2606 wakaba 1.2 subOf => {},
2607     supOf => {},
2608     db => $self,
2609     for => <Q::ManakaiDOM:all>,
2610     forp => [],
2611 wakaba 1.9 seq => -1,
2612 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
2613     require Scalar::Util;
2614     Scalar::Util::weaken ($r->{db});
2615     }
2616 wakaba 1.3
2617     @Method:
2618     @@Name: getSourceFile
2619     @@enDesc:
2620     Gets <QUOTE::dis> source document.
2621     @@Param:
2622     @@@Name: fileName
2623     @@@Type: FileURI
2624     @@@enDesc:
2625     A URI reference identifying a file.
2626     @@Return:
2627     @@@Type: ManakaiDISDocument
2628     @@@enDesc:
2629     The <QUOTE::dis> source document.
2630     @@@nullCase:
2631     @@@@enDesc:
2632     No document associated with that <P::fileName>.
2633     @@@PerlDef:
2634     $r = $self->{<Q::sourceFile>}->{$fileName};
2635     @Method:
2636     @@Name: setSourceFile
2637     @@enDesc:
2638     Puts <QUOTE::dis> source document object.
2639     @@Param:
2640     @@@Name: fileName
2641     @@@Type: FileURI
2642     @@@enDesc:
2643 wakaba 1.4 A URI reference identifying a file. If there is already a
2644 wakaba 1.3 source document, then the association has been updated.
2645     @@Param:
2646     @@@Name: doc
2647     @@@Type: ManakaiDISDocument
2648     @@@enDesc:
2649     The document object to set.
2650     @@Return:
2651     @@@PerlDef:
2652     $self->{<Q::sourceFile>}->{$fileName} = $doc;
2653 wakaba 1.4
2654     @Method:
2655     @@Name: loadModule
2656     @@enDesc:
2657     Loads definitions from a <QUOTE::dis> document.
2658     @@Param:
2659     @@@Name: doc
2660     @@@Type:ManakaiDISDocument
2661     @@@enDesc:
2662     The source <QUOTE::dis> document object. Its
2663     <A::ManakaiDISDocument.disDatabase> must be this database.
2664     @@Param:
2665     @@@Name: resolver
2666     @@@Type: DISModuleResolver
2667     @@@enDesc:
2668     The resolver to convert module name into <QUOTE::dis> document object.
2669     @@ForParam:
2670 wakaba 1.32 @@NamedParam:
2671     @@@Name: onResourceRead
2672     @@@Type:
2673     Perl:CODE::ManakaiDOM:all
2674     @@@enDesc:
2675     An event handler called when a resource is read.
2676     @@@nullCase:
2677     @@@@enDesc:
2678     No event handler is read.
2679 wakaba 1.4 @@Return:
2680     @@@RaiseException:
2681     @@@@@: NO_MODULE_QNAME_ERR
2682     @@@@enDesc:
2683     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2684     @@@RaiseException:
2685     @@@@@: UNABLE_TO_GET_MODULE_ERR
2686     @@@@enDesc:
2687     The implementation is unable to get a module source.
2688 wakaba 1.5 @@@ForDefDupException:
2689     @@@ForDefNoQNameException:
2690     @@@ResDefDupException:
2691     @@@ElementNotAllowedException:
2692 wakaba 1.7 @@@RaiseException:
2693     @@@@@:NO_REQUIRED_ATTR_ERR
2694     @@@@enDesc:
2695     The <Q::dis:Module> element does not have
2696     <Q::dis:Namespace> attribute.
2697 wakaba 1.4 @@@PerlDef:
2698     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2699     if ref $resolver eq 'CODE';
2700     ## -- Module Name, URI
2701     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2702     my $mod_node;
2703     my $mod_name_node;
2704     __DEEP{
2705     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2706     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2707     ::swcfg21:ForLatest.getAttributeNS>
2708     (<Q::dis:>, 'QName');
2709     unless ($mod_name_node) {
2710     __UNDEEP{
2711     __EXCEPTION{NO_MODULE_QNAME_ERR::
2712     DIS:sourceNode => {$mod_node},
2713     }__;
2714     }__;
2715     }
2716 wakaba 1.29 $mod_name_node = bless $mod_name_node, <ClassName::ManakaiDISElement>;
2717 wakaba 1.5 my $mod_name_uri = $mod_name_node
2718     -><AG::ManakaiDISElement.qnameValueURI>;
2719 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2720     ($mod_name_uri, for_arg => $forArg);
2721 wakaba 1.4
2722 wakaba 1.14 unless ($mod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2723 wakaba 1.4 ## -- Initializes Module Definition Object
2724     $mod->{nameURI} = $mod_name_uri;
2725     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2726     .qnameValueLocalName>;
2727     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2728     .qnameValueNamespaceURI>;
2729     $mod->{for} = $forArg;
2730     $mod->{src} = $mod_node;
2731 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2732 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2733 wakaba 1.5 ($mod->{nameURI} => $doc);
2734    
2735 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2736     = $mod->{src}
2737     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2738     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2739     (<Q::swcfg21:fileName>);
2740 wakaba 1.5
2741 wakaba 1.12 ## -- Loads "for" definition
2742     my $root_elements
2743     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2744     if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2745     for my $el (@$root_elements) {
2746 wakaba 1.14 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2747 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2748     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2749     }
2750     }
2751    
2752 wakaba 1.5 ## -- Loads "for all"
2753 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2754     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2755 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2756     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2757 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2758     $mod->{localName}, <Q::ManakaiDOM:all>);
2759 wakaba 1.5 unless ($rdoc) {
2760     __UNDEEP{
2761     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2762 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2763 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2764     DIS:localName => {$mod->{localName}},
2765 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2766 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2767     }__;
2768     }__;
2769     }
2770     $self-><M::ManakaiDISDatabase.loadModule>
2771 wakaba 1.32 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>,
2772     on_resource_read => $onResourceRead);
2773 wakaba 1.5 } # Unless "for all" loaded
2774 wakaba 1.4
2775     ## -- Loads Required Modules
2776 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2777 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2778     .requireElement>;
2779 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2780     .disAllChildElements>}) {
2781 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2782     .expandedURI> eq <Q::dis:Module>;
2783     my ($uri, $nuri, $ln, $for);
2784 wakaba 1.14 my $mqn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2785 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'QName');
2786     if ($mqn) {
2787 wakaba 1.14 my $mqv = $mqn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2788 wakaba 1.4 .value>;
2789 wakaba 1.29 my $mqp = (bless $mqn, <ClassName::ManakaiDISElement>)
2790     -><M::ManakaiDISElement.qnameToPair>
2791 wakaba 1.4 ($mqv, node => $mqn);
2792     ($nuri, $ln) = @$mqp;
2793     } else {
2794 wakaba 1.14 my $mn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2795 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'Name');
2796     if ($mn) {
2797     $nuri = $mod->{namespaceURI};
2798 wakaba 1.14 $ln = $mn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2799 wakaba 1.4 } else {
2800     $nuri = $mod->{namespaceURI};
2801     $ln = $mod->{localName};
2802     }
2803     }
2804 wakaba 1.14 my $wfn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2805 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'WithFor');
2806     if ($wfn) {
2807 wakaba 1.29 $for = (bless $wfn, <ClassName::ManakaiDISElement>)
2808     -><AG::ManakaiDISElement.qnameValueURI>;
2809 wakaba 1.4 } else {
2810     $for = $mod->{for};
2811     }
2812 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2813     ($nuri . $ln, for_arg => $for);
2814 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2815     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2816 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2817 wakaba 1.4 unless ($rdoc) {
2818     __UNDEEP{
2819     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2820 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2821 wakaba 1.4 DIS:namespaceURI => {$nuri},
2822     DIS:localName => {$ln},
2823     DIS:for => {$for},
2824     DIS:sourceNode => {$rm},
2825     }__;
2826     }__;
2827     }
2828     $self-><M::ManakaiDISDatabase.loadModule>
2829 wakaba 1.32 ($rdoc, $resolver, for_arg => $for,
2830     on_resource_read => $onResourceRead);
2831 wakaba 1.4 }
2832     } # Child Module elements
2833    
2834 wakaba 1.12 ## -- Loads child resources
2835 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2836     (for_arg => $forArg);
2837 wakaba 1.5 for my $el (@$root_elements) {
2838 wakaba 1.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2839 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2840 wakaba 1.9 ($mod, null, null, $el,
2841 wakaba 1.32 for_arg => $forArg,
2842     on_resource_read => $onResourceRead);
2843 wakaba 1.7 } else {
2844 wakaba 1.14 my $et = $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2845 wakaba 1.7 .expandedURI>;
2846     if ({
2847 wakaba 1.5 <Q::dis:ForDef> => 1,
2848     <Q::dis:Module> => 1,
2849     <Q::dis:ImplNote> => 1,
2850 wakaba 1.7 }->{$et}) {
2851     #
2852     } else {
2853     __UNDEEP{
2854     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2855     DIS:elementType => {$et},
2856     DIS:sourceNode => {$el},
2857     DIS:uri => {$mod->{uri}},
2858     }__;
2859 wakaba 1.5 }__;
2860 wakaba 1.7 }
2861     } # element types
2862     }
2863    
2864     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2865     .getAttributeNS>
2866     (<Q::dis:>, 'Namespace');
2867 wakaba 1.14 unless ($dn and defined $dn-><M::swcfg21:SWCFGNode
2868     ::swcfg21:ForLatest.value>) {
2869 wakaba 1.7 __UNDEEP{
2870     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2871     DIS:elementType => {<Q::dis:Namespace>},
2872     DIS:sourceNode => {$mod_node},
2873 wakaba 1.5 }__;
2874 wakaba 1.7 }__;
2875 wakaba 1.5 }
2876     } # Unless this module loaded
2877     }__; # Deep
2878    
2879     @Method:
2880     @@Name: loadFor
2881     @@enDesc:
2882     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2883     @@Param:
2884     @@@Name: mod
2885     @@@Type: ManakaiDISModuleDefinition
2886     @@@enDesc:
2887     The module in which the <QUOTE::for> to load is defined.
2888     @@Param:
2889     @@@Name: el
2890     @@@Type:ManakaiDISElement
2891     @@@enDesc:
2892     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2893     @@Return:
2894     @@@ForDefDupException:
2895     @@@ForDefNoQNameException:
2896     @@@ElementNotAllowedException:
2897     @@@PerlDef:
2898     __DEEP{
2899     my $qn_node = $el-><M::swcfg21:SWCFGNode
2900     ::swcfg21:ForLatest.getAttributeNS>
2901     (<Q::dis:>, 'QName');
2902     unless ($qn_node) {
2903     __UNDEEP{
2904     __EXCEPTION{NO_FOR_QNAME_ERR::
2905     DIS:sourceNode => {$qn_node},
2906     }__;
2907     }__;
2908     }
2909 wakaba 1.29 $qn_node = bless $qn_node, <ClassName::ManakaiDISElement>;
2910 wakaba 1.5 my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2911     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2912    
2913 wakaba 1.14 unless ($for-><AG::ManakaiDISForDefinition.isDefined>) {
2914 wakaba 1.10 ## -- Initializes "For" Definition Object
2915 wakaba 1.5 $for->{src} = $el;
2916     $for->{<Q::isDefined>} = true;
2917     $for->{<Q::definingModule>} = $mod->{uri};
2918    
2919 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2920 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2921     .expandedURI>;
2922     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2923     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2924 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2925 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2926 wakaba 1.14 $sfor-><AS::ManakaiDISForDefinition.isReferred> ($ce);
2927 wakaba 1.5 ## TODO: warn if dis:Implement
2928     } elsif ({
2929     <Q::dis:Description> => 1,
2930     <Q::dis:ImplNote> => 1,
2931     <Q::dis:FullName> => 1,
2932     <Q::dis:QName> => 1,
2933     }->{$xn}) {
2934     #
2935     } else {
2936     __UNDEEP{
2937     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2938     DIS:elementType => {$xn},
2939     DIS:sourceNode => {$ce},
2940     DIS:uri => {$mod->{uri}},
2941     }__;
2942     }__;
2943     }
2944     }
2945     } else {
2946     __UNDEEP{
2947     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2948     DIS:sourceNode => {$el},
2949     DIS:anotherSourceNode => {$for->{src}},
2950 wakaba 1.35 DIS:uri => {$for->{uri}},
2951 wakaba 1.5 }__;
2952     }__;
2953     } # isDefine?
2954     }__; # DEEP
2955    
2956     @Method:
2957     @@Name: loadResource
2958     @@enDesc:
2959     Loads definition of a <QUOTE::dis> resource from a
2960     <Q::dis:ResourceDef> element.
2961     @@Param:
2962     @@@Name: mod
2963     @@@Type: ManakaiDISModuleDefinition
2964     @@@enDesc:
2965     The module in which the resource to load is defined.
2966     @@Param:
2967     @@@Name: parentResource
2968     @@@Type: ManakaiDISResourceDefinition
2969     @@@enDesc:
2970 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2971 wakaba 1.5 @@@nullCase:
2972     @@@@enDesc:
2973     The resource to load is a root resource, i.e. <P::el> is
2974     a direct child of the document node.
2975     @@Param:
2976 wakaba 1.7 @@@Name: dynParent
2977 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2978 wakaba 1.7 @@@enDesc:
2979     The dynamic parent resource of the resource to load.
2980 wakaba 1.9 @@@nullCase:
2981 wakaba 1.7 @@@@enDesc:
2982 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2983     a direct child of the document node.
2984 wakaba 1.7 @@Param:
2985 wakaba 1.5 @@@Name: el
2986     @@@Type:ManakaiDISElement
2987     @@@enDesc:
2988     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2989     @@ForParam:
2990     @@ForpParam:
2991 wakaba 1.32 @@NamedParam:
2992     @@@Name: onResourceRead
2993     @@@Type:
2994     Perl:CODE::ManakaiDOM:all
2995     @@@enDesc:
2996     An event handler called when a resource is read.
2997     @@@nullCase:
2998     @@@@enDesc:
2999     No event handler is read.
3000 wakaba 1.5 @@Return:
3001     @@@ResDefDupException:
3002     @@@ElementNotAllowedException:
3003     @@@PerlDef:
3004     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
3005     $forpArg ||= [];
3006     __DEEP{
3007 wakaba 1.6 ## -- Node names
3008    
3009     ## Unique resource identifier generated from node id
3010     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
3011     my $node_uri;
3012     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
3013     $forp => $forpArg, $uri => $node_uri}__;
3014    
3015     ## User defined resource identifiers
3016 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
3017     (<Q::dis:QName>, for_arg => $forArg,
3018     forp_arg => $forpArg);
3019     my $res;
3020     if ($qn_node) {
3021     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
3022 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
3023     ($qn_uri, for_arg => $forArg);
3024 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
3025 wakaba 1.5 __UNDEEP{
3026     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
3027 wakaba 1.9 DIS:uri => {$res->{uri}},
3028 wakaba 1.5 DIS:sourceNode => {$qn_node},
3029     DIS:anotherSourceNode => {$res->{src}},
3030     }__;
3031 wakaba 1.6 }__;
3032 wakaba 1.5 }
3033     $res->{nameURI} = $qn_uri;
3034     $res->{localName} = $qn_node-><AG::ManakaiDISElement
3035     .qnameValueLocalName>;
3036     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
3037     .qnameValueNamespaceURI>;
3038     } else { ## Anonymous or local
3039     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
3040     (<Q::dis:Name>, for_arg => $forArg,
3041     forp_arg => $forpArg);
3042     if ($n_node) {
3043     if ($parentResource) {
3044     my $puri = $parentResource->{uri};
3045     my $ru;
3046 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
3047     ::swcfg21:ForLatest.value>;
3048 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
3049     $localName => $ln,
3050     $result => $ru}__;
3051 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
3052     ($ru, for_arg => $forArg);
3053 wakaba 1.5 $res->{nameURI} = $ru;
3054 wakaba 1.14 $res->{localName} = $n_node-><M::swcfg21:SWCFGNode
3055     ::swcfg21:ForLatest.value>;
3056 wakaba 1.5 $res->{<Q::isAnon>} = true;
3057     } else { ## Root local name resource
3058 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
3059 wakaba 1.7 ::swcfg21:ForLatest.value>;
3060     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
3061     .getPropertyText>
3062     (<Q::dis:Namespace>, null);
3063     my $qn_uri = $ns_uri . $ln;
3064 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
3065     ($qn_uri, for_arg => $forArg);
3066 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
3067 wakaba 1.6 __UNDEEP{
3068     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
3069 wakaba 1.9 DIS:uri => {$res->{uri}},
3070 wakaba 1.6 DIS:sourceNode => {$n_node},
3071     DIS:anotherSourceNode => {$res->{src}},
3072     }__;
3073     }__;
3074     }
3075     $res->{nameURI} = $qn_uri;
3076 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
3077     $res->{localName} = $ln;
3078 wakaba 1.5 }
3079     } else {
3080 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
3081 wakaba 1.5 $res->{<Q::isAnon>} = true;
3082     }
3083 wakaba 1.6 } # anon
3084 wakaba 1.5 $res->{for} = $forArg;
3085     $res->{forp} = $forpArg;
3086     $res->{src} = $el;
3087     $res->{<Q::definingModule>} = $mod->{uri};
3088 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
3089     (<Q::DIS:resource>, $res);
3090 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
3091     = $parentResource ? $parentResource->{uri} : null;
3092     $res->{<Q::dynamicParentResource>}
3093 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
3094     unless ($res->{uri} eq $node_uri) {
3095     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
3096     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
3097     }
3098 wakaba 1.7 $res->{<Q::isDefined>} = true;
3099 wakaba 1.9 $res->{seq} = $self->{seq}++;
3100 wakaba 1.32 $res->{<Q::sourceNodeID>} = $node_id;
3101 wakaba 1.9
3102 wakaba 1.6 ## -- Alias
3103     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
3104     (<Q::dis:AliasFor>, for_arg => $forArg,
3105     forp_arg => $forpArg);
3106     if ($al_node) {
3107     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
3108 wakaba 1.33 ($node_id, $forArg,
3109     for_arg => $self->{for},
3110     forp_arg => $self->{forp});
3111 wakaba 1.6 my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
3112     ($canon_uri);
3113 wakaba 1.14 $canon_res-><AS::ManakaiDISResourceDefinition.isReferred> ($al_node);
3114 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
3115     ($res, node => $al_node);
3116 wakaba 1.6 $res = $canon_res;
3117     }
3118 wakaba 1.5
3119 wakaba 1.11 ## -- Registers as child
3120     $parentResource-><M::ManakaiDISPropertyAccessor
3121     .addPropertyResourceList>
3122     (<Q::DIS:childResource>, $res)
3123     if $parentResource;
3124     $dynParent-><M::ManakaiDISPropertyAccessor
3125     .addPropertyResourceList>
3126     (<Q::DIS:dynamicChildResource>, $res)
3127     if $dynParent;
3128    
3129 wakaba 1.7 my $is_multires = false;
3130     my @props;
3131     my @cres;
3132 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
3133     (for_arg => $forArg, forp_arg => $forpArg)};
3134 wakaba 1.7 while (@ce0) {
3135     my $ce = shift @ce0;
3136     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
3137     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
3138     $res->{<Q::rdf:type>}->{$type_uri} = true;
3139     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
3140 wakaba 1.14 $type-><AS::ManakaiDISResourceDefinition.isReferred> ($ce);
3141 wakaba 1.7 if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3142     (<Q::dis:MultipleResource>)) {
3143     $is_multires = true;
3144     }
3145     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
3146     (<Q::dis:subsetOf>)) {
3147     my $sres = $self-><M::ManakaiDISDatabase.getResource>
3148     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
3149 wakaba 1.33 ($node_id, $forArg,
3150     for_arg => $forArg, forp_arg => $forpArg));
3151 wakaba 1.7 $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
3152 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
3153 wakaba 1.7 push @cres, $ce;
3154     } else {
3155     ## Property and invalid element is not checked, since not
3156     ## all property definitions has loaded at this stage.
3157     push @props, $ce;
3158     }
3159     } # @ce0
3160    
3161     ## -- Child resources
3162     unless ($is_multires) {
3163     for my $re (@cres) {
3164     unless ($al_node) {
3165     $self-><M::ManakaiDISDatabase.loadResource>
3166     ($mod, $res, $res, $re,
3167 wakaba 1.32 for_arg => $forArg, forp_arg => $forpArg,
3168     on_resource_read => $onResourceRead);
3169 wakaba 1.5 } else {
3170 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
3171     (<Q::dis:aliasChild>, for_arg => $forArg,
3172     forp_arg => $forpArg);
3173     if ($ac and $ac-><M::swcfg21:SWCFGNode
3174     ::swcfg21:ForLatest.value>) {
3175     $self-><M::ManakaiDISDatabase.loadResource>
3176     ($mod, $res, $res, $re,
3177 wakaba 1.32 for_arg => $forArg, forp_arg => $forpArg,
3178     on_resource_read => $onResourceRead);
3179 wakaba 1.7 }
3180 wakaba 1.4 }
3181     }
3182 wakaba 1.7 }
3183 wakaba 1.5
3184 wakaba 1.7 ## -- Multiple representations
3185     if ($is_multires) {
3186     for my $pe (@props) {
3187     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
3188 wakaba 1.10 (<Q::dis:resourceFor>)) {
3189 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
3190 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
3191 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($pe);
3192 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
3193     ($mod, $parentResource, $res, $el,
3194     for_arg => $forArg,
3195 wakaba 1.32 forp_arg => [@{$forpArg}, $for_uri],
3196     on_resource_read => $onResourceRead);
3197 wakaba 1.7 }
3198     }
3199     }
3200 wakaba 1.32 ($onResourceRead or sub {})->($self, $res);
3201 wakaba 1.5 }__; # DEEP
3202 wakaba 1.8
3203     @Method:
3204     @@Name: checkUndefinedResource
3205     @@enDesc:
3206     Checks whether there is referred but undefined resource or not.
3207     @@Return:
3208     @@@RaiseException:
3209     @@@@@: FOR_NOT_DEFINED_ERR
3210     @@@@enDesc:
3211     There is a <QUOTE::for> that is referred but not defined.
3212     @@@RaiseException:
3213     @@@@@: RESOURCE_NOT_DEFINED_ERR
3214     @@@@enDesc:
3215     There is a resource that is referred but not defined.
3216     @@@PerlDef:
3217     for my $fd (values %{$self->{forDef}}) {
3218     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
3219     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
3220     __EXCEPTION{FOR_NOT_DEFINED_ERR::
3221     DIS:uri => {$fd->{uri}},
3222     DIS:sourceNode => {$ref},
3223     }__;
3224     }
3225     }
3226     for my $fd (values %{$self->{resDef}}) {
3227     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
3228     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
3229     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3230     DIS:uri => {$fd->{uri}},
3231     DIS:sourceNode => {$ref},
3232     }__;
3233     }
3234     }
3235 wakaba 1.5
3236 wakaba 1.9
3237     @Method:
3238     @@Name: plStore
3239     @@enDesc:
3240     Saves this database to an external file.
3241     \
3242     {NOTE:: Saved files can be loaded by
3243     <M::ManakaiDISImplementation.plLoadDISDatabase>.
3244     \
3245     }
3246     @@Param:
3247     @@@Name: fileName
3248     @@@Type:
3249 wakaba 1.18 DISLang:String::ManakaiDOM:all
3250 wakaba 1.9 @@@enDesc:
3251     An environment-dependent file name of external database to save.
3252     \
3253     {NOTE:: If there is already a file named as <P::fileName>, then
3254     it is overwritten.
3255     \
3256     }
3257     @@Return:
3258     @@@SimpleException:
3259     @@@PerlDef:
3260     use Storable qw/nstore/;
3261     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
3262     nstore $self, $fileName;
3263 wakaba 1.15
3264     @Method:
3265     @@Name: xcrefToResource
3266     @@enDesc:
3267     Returns a resource object selected by an exception code
3268     reference (<Q::DOMMain:XCodeRef>).
3269     @@Param:
3270     @@@Name: xcref
3271     @@@Type:
3272     DOMMain:XCodeRef::ManakaiDOM:all
3273     @@@enDesc:
3274     Exception code to select.
3275     @@Param:
3276     @@@Name: contextNode
3277     @@@Type: ManakaiDISElement
3278     @@@enDesc:
3279     A context element node. Namespace prefixes in
3280     <P::xcref> are resolved against this node.
3281 wakaba 1.16 @@ForParam:
3282 wakaba 1.15 @@NodeParam:
3283     @@Return:
3284     @@@Type:
3285     Perl:ARRAY::ManakaiDOM:all
3286     @@@enDesc:
3287     A reference to the array containing two or three
3288     resource definitions (<Class::ManakaiDISResourceDefinition>).
3289     The first (index <CODE::0>) resource is an exception class.
3290     The second (index <CODE::1>) resource is an exception code
3291     constant. The third (index <CODE::2>) resource
3292     is an exception subtype or <DOM::null> if the reference identifies
3293     no subtype.
3294     @@@RaiseException:
3295     @@@@@: RESOURCE_NOT_DEFINED_ERR
3296     @@@@enDesc:
3297     The resource identified by the <P::xcref> is not defined
3298     or not an exception.
3299     @@@PerlDef:
3300     my ($q1, $q2, $q3) = split /\s*\.\s*/, $xcref, 3;
3301     __DEEP{
3302     if (defined $q3) {
3303     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3304 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3305     ($q3, null, $forArg, node => $node));
3306 wakaba 1.15 $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
3307     .getPropertyResource>
3308     (<Q::dis2pm:parentResource>);
3309     } elsif (defined $q2) {
3310     if ($q2 =~ /:/) {
3311     $r->[1] = $self-><M::ManakaiDISDatabase.getResource>
3312 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3313     ($q2, null, $forArg, node => $node));
3314 wakaba 1.15 } else {
3315     $r->[0] = $self-><M::ManakaiDISDatabase.getResource>
3316 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3317     ($q1, null, $forArg, node => $node));
3318 wakaba 1.15 $r->[1] = $r->[0]-><M::ManakaiDISResourceDefinition
3319     .getConstResourceByName> ($q2);
3320     }
3321 wakaba 1.16 } else { ## $q1 only
3322 wakaba 1.15 $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3323 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3324     ($q1, null, $forArg, node => $node));
3325 wakaba 1.15 if ($r->[2]-><M::ManakaiDISResourceDefinition
3326     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
3327     $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
3328     .getPropertyResource>
3329     (<Q::dis2pm:parentResource>);
3330     } else {
3331     $r->[1] = $r->[2]; CORE::delete $r->[2];
3332     }
3333     }
3334    
3335     if ($r->[2] and
3336     not $r->[2]-><M::ManakaiDISResourceDefinition
3337     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
3338     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3339     DIS:uri => {$r->[2]->{uri}},
3340     DIS:expectedType => {<Q::ManakaiDOM:ExceptionOrWarningSubType>},
3341     DIS:sourceNode => {$node},
3342     DIS:sourceCode => {$xcref},
3343     }__}__;
3344     }
3345 wakaba 1.16 $r->[2]-><AS::ManakaiDISResourceDefinition.isReferred>
3346     ($node or $contextNode)
3347     if $r->[2];
3348 wakaba 1.15
3349     if (not $r->[1] or
3350     not $r->[1]-><M::ManakaiDISResourceDefinition
3351     .isTypeURI> (<Q::ManakaiDOM:Const>)) {
3352     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3353     DIS:uri => {$r->[1]->{uri}},
3354     DIS:localName => {$r->[1]->{localName}},
3355     DIS:expectedType => {<Q::ManakaiDOM:Const>},
3356     DIS:sourceNode => {$node},
3357     DIS:sourceCode => {$xcref},
3358     }__}__;
3359     }
3360 wakaba 1.16 $r->[1]-><AS::ManakaiDISResourceDefinition.isReferred>
3361 wakaba 1.15 ($node or $contextNode);
3362    
3363     unless ($r->[0]) {
3364     my $cg = $r->[1]-><M::ManakaiDISPropertyAccessor
3365     .getPropertyResource>
3366     (<Q::dis2pm:parentResource>);
3367     $r->[0] = $cg-><M::ManakaiDISPropertyAccessor
3368     .getPropertyResource>
3369     (<Q::dis2pm:parentResource>) if $cg;
3370     }
3371     if (not $r->[0] or
3372     not $r->[0]-><M::ManakaiDISResourceDefinition
3373 wakaba 1.16 .isTypeURI> (<Q::DOMException:AnyExceptionClass>)) {
3374 wakaba 1.15 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3375     DIS:uri => {$r->[0]->{uri}},
3376     DIS:localName => {$r->[0]->{localName}},
3377 wakaba 1.16 DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
3378 wakaba 1.15 DIS:sourceNode => {$node},
3379     DIS:sourceCode => {$xcref},
3380     }__}__;
3381     }
3382 wakaba 1.16 $r->[0]-><AS::ManakaiDISResourceDefinition.isReferred>
3383 wakaba 1.15 ($node or $contextNode);
3384     }__;
3385 wakaba 1.2 ##DISDatabase
3386    
3387 wakaba 1.8 PropDef:
3388 wakaba 1.32 @QName: sourceNodeID
3389     @enDesc:
3390     The URI reference of the source node identifier.
3391     @rdfs:domain: ManakaiDISResourceDefinition
3392    
3393     PropDef:
3394 wakaba 1.9 @QName: resource
3395     @enDesc:
3396     Resources defined in a module.
3397     @rdfs:range: ManakaiDISResourceDefinition
3398     @rdfs:domain: ManakaiDISModuleDefinition
3399    
3400     PropDef:
3401 wakaba 1.8 @QName:
3402     dis2pm:parentResource
3403     @enDesc:
3404     Static parent resource. No parent for root resources.
3405    
3406     PropDef:
3407     @QName: dynamicParentResource
3408     @enDesc:
3409     Dynamic parent resource. No parent for root resources.
3410    
3411 wakaba 1.11 PropDef:
3412     @QName: childResource
3413     @enDesc:
3414     Static child resources.
3415    
3416     PropDef:
3417     @QName: dynamicChildResource
3418     @enDesc:
3419     Dynamic child resources.
3420    
3421 wakaba 1.5 ElementTypeBinding:
3422     @Name: ForDefDupException
3423     @ElementType:
3424     ManakaiDOM:raises
3425     @ShadowContent:
3426     @@@: FOR_ALREADY_DEFINED_ERR
3427     @@Description:
3428     @@@lang:en
3429     @@@@:
3430     The <QUOTE::for> is already defined elsewhere.
3431    
3432     ElementTypeBinding:
3433     @Name: ForDefNoQNameException
3434     @ElementType:
3435     ManakaiDOM:raises
3436     @ShadowContent:
3437     @@@: NO_FOR_QNAME_ERR
3438     @@Description:
3439     @@@lang:en
3440     @@@@:
3441     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
3442    
3443     ElementTypeBinding:
3444     @Name: ResDefDupException
3445     @ElementType:
3446     ManakaiDOM:raises
3447     @ShadowContent:
3448     @@@: RESOURCE_ALREADY_DEFINED_ERR
3449     @@Description:
3450     @@@lang:en
3451     @@@@:
3452     The <QUOTE::dis> resource is already defined elsewhere.
3453    
3454     ElementTypeBinding:
3455     @Name: ElementNotAllowedException
3456     @ElementType:
3457     ManakaiDOM:raises
3458     @ShadowContent:
3459     @@@: ELEMENT_NOT_ALLOWED_ERR
3460     @@Description:
3461     @@@lang:en
3462     @@@@:
3463     An element has found where it is not allowed.
3464    
3465 wakaba 1.4 IFClsDef:
3466     @QName:
3467     @@@: DISModuleResolver
3468     @@ForCheck: ForIF
3469     @QName:
3470     @@@: ManakaiDISModuleResolver
3471     @@ForCheck: ForClass
3472     @enDesc:
3473     Objects implementing <IF::DISModuleResolver> interface
3474     are used to convert module name into <QUOTE::dis> document object.
3475     \
3476     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
3477     as a method parameter where <IF::DISModuleResolver> is
3478     expected.
3479     \
3480     }
3481     @Method:
3482     @@Name: uriToDocument
3483     @@enDesc:
3484     Returns a <QUOTE::dis> document from module name information.
3485     @@Param:
3486     @@@Name: disDB
3487     @@@Type: ManakaiDISDatabase
3488     @@@enDesc:
3489     The <QUOTE::dis> database.
3490     @@Param:
3491     @@@Name: moduleURI
3492     @@@Type: ModuleURI
3493     @@@enDesc:
3494     The URI reference of the module.
3495     \
3496     {NOTE:: This parameter is redundant, since it can be
3497     composed from other three parameters.
3498     \
3499     }
3500     @@Param:
3501     @@@Name: moduleNamespaceURI
3502     @@@Type: AnyURI
3503     @@@enDesc:
3504     The namespace URI of the module name.
3505     @@Param:
3506     @@@Name: moduleLocalName
3507     @@@Type:
3508 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
3509 wakaba 1.4 @@@enDesc:
3510     The local name of the module name.
3511     @@Param:
3512     @@@Name: moduleFor
3513     @@@Type: ForURI
3514     @@@enDesc:
3515     The <QUOTE::for> URI reference for which the module is defined.
3516     @@Return:
3517     @@@Type: ManakaiDISDocument
3518     @@@enDesc:
3519     The <QUOTE::dis> document. It don't have to be a newly created
3520     object.
3521     @@@nullCase:
3522     @@@@enDesc:
3523     The method is unable to resolve the reference.
3524     @@@PerlDef:
3525     $r = $self->(@_);
3526     @ManakaiDOM:inputNormalizer:
3527     @@ContentType:
3528     lang:Perl
3529     @@@:
3530     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
3531     if ref $INPUT eq 'CODE';
3532     @@ImplNote:
3533     @@@lang:en
3534     @@@@:
3535     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
3536     ##DISModuleResolver
3537    
3538 wakaba 1.3 PropDef:
3539     @QName: sourceFile
3540     @enDesc:
3541     Source <QUOTE::dis> documents.
3542     @rdfs:domain: ManakaiDISDatabase
3543     @rdfs:range: ManakaiDISDocument
3544    
3545 wakaba 1.2 ClsDef:
3546     @ClsQName: ManakaiDISModuleDefinition
3547     @enDesc:
3548     <QUOTE::dis> module definitions.
3549     @ClsISA: ManakaiDISPropertyAccessor
3550 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3551 wakaba 1.22 @ClsISA: ManakaiDISPerlModuleDefinition
3552 wakaba 1.2
3553     @Attr:
3554     @@Name: uri
3555     @@Type: ModuleURI
3556     @@Description:
3557     @@@lang:en
3558     @@@@:
3559     The URI reference of this <QUOTE::dis> module.
3560     @@Get:
3561     @@@PerlDef:
3562     $r = $self->{uri};
3563    
3564 wakaba 1.22 @IntMethod:
3565     @@Operator:
3566     @@@@:eq
3567     @@@ContentType:
3568     lang:Perl
3569     @@enDesc:
3570     Whether two <QUOTE::dis> module definitions are equal or not.
3571     Two <QUOTE::dis> module definitions are equal iff their canonical
3572     URI references are literally (in character-by-character) equivalent.
3573     @@Param:
3574     @@@Name: anotherModule
3575     @@@Type: ManakaiDISModuleDefinition
3576     @@@enDesc:
3577     Another <QUOTE::dis> module definition to compare.
3578     @@Return:
3579     @@@Type:
3580     DOMMain:boolean::ManakaiDOM:all
3581     @@@enDesc:
3582     Whether two resources are equal or not.
3583     @@@PerlDef:
3584     if (UNIVERSAL::isa ($anotherModule,
3585     <ClassName::ManakaiDISModuleDefinition>)) {
3586     $r = $self->{uri} eq $anotherModule->{uri};
3587     } else {
3588     $r = false;
3589     }
3590    
3591 wakaba 1.2 @Attr:
3592     @@Name: nameURI
3593     @@Type: NameURI
3594     @@enDesc:
3595     The URI reference of this module, without
3596     <QUOTE::for> identifier.
3597     @@Get:
3598 wakaba 1.3 @@@PerlDef:
3599 wakaba 1.4 $r = $self->{nameURI};
3600 wakaba 1.2
3601     @Attr:
3602     @@Name: localName
3603     @@enDesc:
3604     The local name of this module.
3605     @@Type:
3606 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3607 wakaba 1.2 @@Get:
3608     @@@PerlDef:
3609     $r = $self->{localName};
3610    
3611     @Attr:
3612     @@Name: namespaceURI
3613     @@Type: AnyURI
3614     @@enDesc:
3615     The namespace URI of the name of this resource.
3616     @@Get:
3617     @@@PerlDef:
3618     $r = $self->{namespaceURI};
3619    
3620     @Attr:
3621     @@Name: forURI
3622     @@Type: ForURI
3623     @@enDesc:
3624     The <QUOTE::for> URI reference for which this module is defined.
3625     @@Get:
3626     @@@PerlDef:
3627     $r = $self->{for};
3628    
3629     @Attr:
3630     @@Name: isDefined
3631     @@Description:
3632     @@@lang:en
3633     @@@@:
3634     Whether this module is defined or not.
3635     @@Type:
3636 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3637 wakaba 1.2 @@Get:
3638     @@@PerlDef:
3639     $r = $self->{<Q::isDefined>};
3640 wakaba 1.8
3641     @Attr:
3642     @@Name: plFullyQualifiedName
3643     @@enDesc:
3644     The fully-qualified Perl class package name.
3645     @@Type:
3646     Perl:package-name::ManakaiDOM:all
3647     @@Get:
3648     @@@NoPerlModuleNameException:
3649     @@@PerlDef:
3650     __DEEP{
3651     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3652     ($self->{namespaceURI});
3653     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3654     __UNDEEP{
3655     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3656     DIS:uri => {$self->{namespaceURI}},
3657     DIS:sourceNode => {$self->{src}},
3658     }__;
3659     }__;
3660     }
3661     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3662     (<Q::dis:AppName>, for_arg => $self->{for},
3663 wakaba 1.10 media_type => <Q::lang:Perl>,
3664     default_media_type => <Q::lang:Perl>);
3665 wakaba 1.8 if ($an) {
3666     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3667     $r =~ s/::$//g;
3668     $r .= '::' . $self->{localName};
3669     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3670     (<Q::ManakaiDOM:moduleSuffix>,
3671     for_arg => $self->{for},
3672     media_type => <Q::lang:Perl>,
3673     default_media_type => <Q::lang:Perl>);
3674     if ($sf) {
3675     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3676     }
3677     } else {
3678 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
3679 wakaba 1.8 }
3680     }__;
3681    
3682     @Attr:
3683     @@Name: plInterfaceName
3684     @@enDesc:
3685     The fully-qualified Perl interface package name.
3686     @@Type:
3687     Perl:package-name::ManakaiDOM:all
3688     @@Get:
3689     @@@NoPerlModuleNameException:
3690     @@@PerlDef:
3691     __DEEP{
3692     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3693     ($self->{namespaceURI});
3694     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3695     __UNDEEP{
3696     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3697     DIS:uri => {$self->{namespaceURI}},
3698     DIS:sourceNode => {$self->{src}},
3699     }__;
3700     }__;
3701     }
3702     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3703     (<Q::dis:AppName>, for_arg => $self->{for},
3704     forp_arg => [<Q::ManakaiDOM:ForIF>],
3705 wakaba 1.10 media_type => <Q::lang:Perl>,
3706     default_media_type => <Q::lang:Perl>);
3707 wakaba 1.8 if ($an) {
3708     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3709     $r =~ s/::$//g;
3710     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3711     (<Q::ManakaiDOM:moduleSuffix>,
3712     for_arg => $self->{for},
3713     forp_arg => [<Q::ManakaiDOM:ForIF>],
3714     media_type => <Q::lang:Perl>,
3715     default_media_type => <Q::lang:Perl>);
3716     if ($sf) {
3717     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3718     }
3719     } else {
3720 wakaba 1.14 $r = $self-><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>;
3721 wakaba 1.8 }
3722     }__;
3723 wakaba 1.22
3724     @Attr:
3725     @@Name: ownerModule
3726     @@ManakaiDOM:isRedefining:1
3727     @@enDesc:
3728     This module itself.
3729     @@Get:
3730     @@@Type: ManakaiDISModuleDefinition
3731     @@@PerlDef: $r = $self;
3732 wakaba 1.2 ##DISModuleDefinition
3733    
3734 wakaba 1.8 ElementTypeBinding:
3735     @Name: NoPerlModuleNameException
3736     @ElementType:
3737     ManakaiDOM:raises
3738     @ShadowContent:
3739     @@@: RESOURCE_NOT_DEFINED_ERR
3740     @@Description:
3741     @@@lang:en
3742     @@@@:
3743     The module group corresponding to the namespace URI
3744     of this module is not defined.
3745    
3746 wakaba 1.2 ClsDef:
3747     @ClsQName: ManakaiDISForDefinition
3748     @Description:
3749     @@lang:en
3750     @@@:
3751     <QUOTE::dis> <QUOTE::for> definitions.
3752 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3753 wakaba 1.2
3754     @Attr:
3755     @@Name: uri
3756     @@Type: ForURI
3757     @@Description:
3758     @@@lang:en
3759     @@@@:
3760     The URI reference of this <QUOTE::for>.
3761     @@Get:
3762     @@@PerlDef:
3763     $r = $self->{uri};
3764 wakaba 1.10
3765     @IntMethod:
3766     @@Operator:
3767     @@@@:eq
3768     @@@ContentType:
3769     lang:Perl
3770     @@enDesc:
3771     Whether two <QUOTE::for> definitions are equal or not.
3772     Two <QUOTE::for> definitions are equal iff one's URI reference
3773     is one of another's URI reference.
3774     \
3775     {NOTE:: Aliases for <QUOTE::for> is not allowed.
3776     \
3777     }
3778     @@ImplNote:
3779     @@@lang:en
3780     @@@@:
3781     In the current implementation, two are equal iff two are
3782     equal as reference.
3783     @@Param:
3784     @@@Name: anotherFor
3785     @@@Type: ManakaiDISForDefinition
3786     @@@enDesc:
3787     Another <QUOTE::for> definition to compare.
3788     @@Return:
3789     @@@Type:
3790 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3791 wakaba 1.10 @@@enDesc:
3792     Whether two resources are equal or not.
3793     @@@PerlDef:
3794     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
3795     $r = $self->{uri} eq $anotherFor->{uri};
3796     } else {
3797     $r = false;
3798     }
3799 wakaba 1.2
3800     @Method:
3801     @@Name: isaURI
3802     @@Description:
3803     @@@lang:en
3804     @@@@:
3805     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
3806     @@Param:
3807     @@@Name: superURI
3808     @@@Type: ForURI
3809     @@@Description:
3810     @@@@lang:en
3811     @@@@@:
3812     Another <QUOTE::for> URI reference to test.
3813     @@Return:
3814     @@@Type:
3815 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3816 wakaba 1.2 @@@TrueCase:
3817     @@@@enDesc:
3818     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
3819     @@@FalseCase:
3820     @@@@enDesc:
3821     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
3822     @@@PerlDef:
3823     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
3824    
3825     @Attr:
3826     @@Name: isDefined
3827     @@Description:
3828     @@@lang:en
3829     @@@@:
3830     Whether this <QUOTE::for> is already defined or not.
3831     @@Type:
3832 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3833 wakaba 1.2 @@Get:
3834     @@@TrueCase:
3835     This <QUOTE::for> is already defined.
3836     @@@FalseCase:
3837     This <QUOTE::for> is not defined.
3838     @@@PerlDef:
3839     $r = $self->{<Q::isDefined>};
3840    
3841     @Attr:
3842     @@Name: isReferred
3843     @@Description:
3844     @@@lang:en
3845     @@@@:
3846     Whether this <QUOTE::for> is referred somewhere or not.
3847 wakaba 1.9 @@Type: ManakaiDISElement
3848 wakaba 1.2 @@Get:
3849     @@@InCase:
3850     @@@@Type:ManakaiDISElement
3851     @@@@enDesc:
3852     This <QUOTE::for> is referred by the element.
3853     @@@nullCase:
3854     This <QUOTE::for> is not referred.
3855     @@@PerlDef:
3856     $r = $self->{<Q::isReferred>};
3857     @@Set:
3858     @@@InCase:
3859     @@@@Type:ManakaiDISElement
3860     @@@@enDesc:
3861     This <QUOTE::for> is referred by the element.
3862     @@@PerlDef:
3863 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3864 wakaba 1.2
3865     @Attr:
3866 wakaba 1.22 @@Name: ownerModule
3867     @@ManakaiDOM:isRedefining:1
3868 wakaba 1.2 @@Description:
3869     @@@lang:en
3870     @@@@:
3871     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3872     @@Type: ManakaiDISModuleDefinition
3873     @@Get:
3874     @@@Description:
3875     @@@@lang:en
3876     @@@@@:
3877     The module object.
3878 wakaba 1.3 @@@nullCase:
3879 wakaba 1.2 @@@@Description:
3880     @@@@@lang:en
3881     @@@@@@:
3882     This <QUOTE::for> is not associated to any module.
3883     @@@PerlDef:
3884     $r = $self->{db}
3885     -><M::ManakaiDISDatabase.getResource>
3886     ($self->{<Q::definingModule>})
3887     if defined $self->{<Q::definingModule>};
3888 wakaba 1.5
3889 wakaba 1.2 @Method:
3890 wakaba 1.5 @@Name: addISA
3891 wakaba 1.2 @@enDesc:
3892 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3893     <QUOTE::for>.
3894 wakaba 1.2 @@Param:
3895 wakaba 1.5 @@@Name: superFor
3896     @@@Type: ManakaiDISForDefinition
3897     @@@enDesc:
3898     A <QUOTE::for> definition object.
3899 wakaba 1.2 @@Return:
3900     @@@PerlDef:
3901 wakaba 1.5 my @from = ($self->{uri},
3902     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3903     my @to = ($superFor->{uri},
3904     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3905 wakaba 1.7 __DEEP{
3906     for my $from (@from) {
3907     for my $to (@to) {
3908     $self->{db}-><M::ManakaiDISDatabase.getFor>
3909     ($from)->{isa}->{$to} = true;
3910     $self->{db}-><M::ManakaiDISDatabase.getFor>
3911     ($to)->{revISA}->{$from} = true;
3912     }
3913 wakaba 1.5 }
3914 wakaba 1.7 }__;
3915 wakaba 1.5
3916 wakaba 1.2 ##DISForDefinition
3917    
3918     ClsDef:
3919 wakaba 1.22 @ClsQName: ManakaiDISPerlModuleDefinition
3920     @enDesc:
3921     A class inherited by classes whose object might (but not necessarily) define
3922     a Perl module.
3923     @ImplNote:
3924     @@lang:en
3925     @@@:
3926     Any object whose class inheriting this class must also inherit
3927     the <Class::ManakaiDISPropertyAccessor> class.
3928    
3929     @Method:
3930     @@Name: plGeneratePerlModuleFile
3931     @@enDesc:
3932     Generates a Perl file object.
3933     @@Return:
3934     @@@Type: PLFile
3935     @@@enDesc:
3936     A Perl file object generated from this resource.
3937     @@@RaiseException:
3938     @@@@@:NO_LICENSE_ATTR_ERR
3939     @@@@enDesc:
3940     The <Q::dis:Module> element does not have the
3941     <Q::dis:License> attribute.
3942     @@@NoPerlModuleNameException:
3943 wakaba 1.24 @@@RaiseException:
3944     @@@@@:RESOURCE_NOT_DEFINED_ERR
3945     @@@@enDesc:
3946     A feature referred from this module is not defined.
3947 wakaba 1.32 @@@RaiseException:
3948     @@@@@:RESOURCE_NOT_DEFINED_ERR
3949     @@@@enDesc:
3950     A markup vocabulary is referred but it is not defined
3951     or have a different type than the expected one.
3952 wakaba 1.22 @@@PerlDef:
3953     __DEEP{
3954     $r = $self-><AG::ManakaiDISPropertyAccessor.plImplementation>
3955     -><M::MPLImpl.createPerlFile>;
3956 wakaba 1.24
3957     ## -- Source information
3958 wakaba 1.22 $r-><AS::PLFile.sourceFile>
3959     ($self-><M::ManakaiDISPropertyAccessor.getPropertyText>
3960     (<Q::DIS:sourceFile>, ''));
3961     $r-><AS::PLFile.sourceModule> ($self->{nameURI});
3962     $r-><AS::PLFile.sourceFor> ($self->{for});
3963 wakaba 1.24
3964     ## -- License information
3965 wakaba 1.22 my $ownermod = $self-><AG::ManakaiDISPropertyAccessor.ownerModule>;
3966     my $license = $ownermod-><M::ManakaiDISPropertyAccessor
3967     .getPropertyResource> (<Q::dis:License>);
3968     unless ($license) {
3969     __UNDEEP{__EXCEPTION{NO_LICENSE_ATTR_ERR::
3970     DIS:sourceNode => {$ownermod->{src}},
3971     DIS:uri => {$ownermod->{uri}},
3972     }__}__;
3973     }
3974     $r-><AS::PLFile.licenseURI>
3975     ($license-><AG::ManakaiDISResourceDefinition.uri>);
3976    
3977 wakaba 1.24 ## -- Classes
3978 wakaba 1.22 ## TODO: Custom module construction support
3979 wakaba 1.27 my $thismod_name = $self-><AG::ManakaiDISModuleDefinition
3980     .plFullyQualifiedName>;
3981     my $thismod_pack = $r-><M::PLFile.getLastPackage>
3982     ($thismod_name, make_new_package => true);
3983     my %const;
3984 wakaba 1.22 for my $cls (@{$self-><M::ManakaiDISPropertyAccessor
3985     .getPropertyResourceList>
3986     (<Q::DIS:resource>)}) {
3987 wakaba 1.23 if ($cls-><AG::ManakaiDISResourceDefinition.ownerModule>
3988 wakaba 1.22 eq $ownermod) {
3989 wakaba 1.23 if ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
3990     (<Q::ManakaiDOM:Class>)) {
3991 wakaba 1.24 ## -- Subroutines and variables
3992 wakaba 1.23 my $pack = $cls-><AG::ManakaiDISResourceDefinition
3993     .plCodeFragment>;
3994     $r-><M::PLFile.appendPackage> ($pack);
3995 wakaba 1.24 my $pack_name = $cls-><AG::ManakaiDISResourceDefinition
3996     .plFullyQualifiedName>;
3997    
3998 wakaba 1.27 ## -- Constants
3999     for my $cr (@{$cls-><M::ManakaiDISPropertyAccessor
4000     .getPropertyResourceList>
4001     (<Q::DIS:childResource>)}) {
4002     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4003     (<Q::ManakaiDOM:Const>)) {
4004     $thismod_pack-><M::PLPack.addExport>
4005     (null,
4006     my $nm = $cr-><AG::ManakaiDISResourceDefinition.plName>);
4007     $const{$nm} = $cr-><AG::ManakaiDISResourceDefinition
4008     .plFullyQualifiedName>;
4009     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4010     (<Q::ManakaiDOM:ConstGroup>)) {
4011     my $tag = $cr-><AG::ManakaiDISResourceDefinition.plName>;
4012     for my $gcr (@{$cr-><M::ManakaiDISPropertyAccessor
4013     .getPropertyResourceList>
4014     (<Q::DIS:childResource>)}) {
4015     if ($gcr-><M::ManakaiDISResourceDefinition.isTypeURI>
4016     (<Q::ManakaiDOM:Const>)) {
4017     $thismod_pack-><M::PLPack.addExport>
4018     ($tag, my $nm = $gcr-><AG::ManakaiDISResourceDefinition
4019     .plName>);
4020     $const{$nm} = $gcr-><AG::ManakaiDISResourceDefinition
4021     .plFullyQualifiedName>;
4022     }
4023     }
4024     }
4025     }
4026    
4027 wakaba 1.24 ## -- Features
4028     my %feature;
4029     for my $el (@{$cls->{src}
4030     -><M::ManakaiDISElement.disChildElements>
4031 wakaba 1.35 (for_arg => $cls->{for},
4032     forp_arg => $cls->{forp})}) {
4033 wakaba 1.24 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
4034     .expandedURI> eq <Q::DOMMetaImpl:provideFeature>;
4035     my $furi = $el-><AG::ManakaiDISElement.qnameValueURI>;
4036     my $f = $self->{db}-><M::ManakaiDISDatabase.getResource>
4037     ($furi);
4038     unless ($f-><AS::ManakaiDISResourceDefinition.isDefined>) {
4039     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4040     DIS:sourceNode => {$el},
4041     DIS:uri => {$furi},
4042     DIS:expectedType => {<Q::DOMMain:DOMFeature>},
4043     }__}__;
4044     }
4045     for my $s ($f, @{$f-><M::ManakaiDISPropertyAccessor
4046     .getPropertyResourceList>
4047     (<Q::DOMMetaImpl:extendFeature>,
4048     recursive => true,
4049     default_media_type => <Q::dis:TypeQName>)}) {
4050     $feature{$s-><AG::ManakaiDISResourceDefinition.uri>}
4051     = [$s, $el];
4052     }
4053     }
4054     for my $f (values %feature) {
4055     my @fname = @{$f->[0]-><AG::ManakaiDISResourceDefinition
4056     .featureNameList>};
4057     my $fver = $f->[0]-><M::ManakaiDISPropertyAccessor
4058     .getPropertyText>
4059     (<Q::dis:Version>, null);
4060     next unless defined $fver;
4061     my $fi = $self-><M::ManakaiDISPerlModuleDefinition
4062     .plIsFeatureImplemented> ($f->[0]->{uri}) ? true : false;
4063     my @ec = @{$f->[1]-><M::ManakaiDISElement.disChildElements>
4064 wakaba 1.35 (for_arg => $cls->{for},
4065     forp_arg => $cls->{forp})};
4066 wakaba 1.24 if (@ec) {
4067     for my $ec (@ec) {
4068     next unless $ec-><AG::swcfg21:SWCFGElement
4069     ::swcfg21:ForLatest
4070     .expandedURI> eq <Q::DOMMetaImpl:providedThrough>;
4071     my $curi = $ec-><M::ManakaiDISElement.tfqnamesValueURI>
4072 wakaba 1.35 ($self->{<Q::DIS:sourceNodeID>}, $cls->{for},
4073     for_arg => $cls->{for},
4074     forp_arg => $cls->{forp});
4075 wakaba 1.24 my $c = $self->{db}-><M::ManakaiDISDatabase.getResource>
4076     ($curi);
4077     $c-><AS::ManakaiDISResourceDefinition.isReferred> ($ec);
4078     my $cp = $c-><AG::ManakaiDISResourceDefinition
4079     .plFullyQualifiedName>;
4080     for my $fname (@fname) {
4081     $r-><M::PLBlockCon.appendStatement>
4082 wakaba 1.28 ('$Message::DOM::ImplFeature{q<' . $cp .
4083     '>}->{q<' .
4084 wakaba 1.24 $fname . '>}->{q<' . $fver . '>} ||= '.$fi);
4085     $r-><M::PLBlockCon.appendStatement>
4086 wakaba 1.28 ('$Message::DOM::ImplFeature{q<' . $cp .
4087     '>}->{q<' . $fname . '>}->{q<>} = 1');
4088 wakaba 1.24 }
4089     }
4090     } else { ## No DOMMetaImpl:ProvidedThrough attribute
4091     for my $fname (@fname) {
4092     $r-><M::PLBlockCon.appendStatement>
4093 wakaba 1.28 ('$Message::DOM::ImplFeature{q<' . $pack_name .
4094     '>}->{q<' .
4095 wakaba 1.24 $fname . '>}->{q<' . $fver . '>} ||= '.$fi);
4096     $r-><M::PLBlockCon.appendStatement>
4097 wakaba 1.28 ('$Message::DOM::ImplFeature{q<' . $pack_name .
4098     '>}->{q<' . $fname . '>}->{q<>} = 1');
4099 wakaba 1.24 }
4100     }
4101     }
4102 wakaba 1.25
4103 wakaba 1.33 my %ifeature;
4104     my $ifpoint = 0;
4105     for my $feature (@{$cls-><M::ManakaiDISPropertyAccessor
4106     .getPropertyResourceList>
4107     (<Q::DOMMain:implementFeature>,
4108     isa_recursive => true,
4109     default_media_type => <Q::dis:TypeQName>)}) {
4110     my $fver = $feature-><M::ManakaiDISPropertyAccessor
4111     .getPropertyText>
4112     (<Q::dis:Version>, null);
4113     $ifpoint += $fver;
4114     my $fi = defined $fver
4115     ? $self-><M::ManakaiDISPerlModuleDefinition
4116     .plIsFeatureImplemented>
4117     ($feature->{uri}) ? true : false
4118     : true;
4119     for my $fname (@{$feature-><AG::ManakaiDISResourceDefinition
4120     .featureNameList>}) {
4121     $ifeature{$fname}->{$fver} = $fi;
4122     }
4123     }
4124     $r-><M::PLBlockCon.appendStatement>
4125     ('$Message::DOM::ClassFeature{q<' . $pack_name .
4126     '>} = ' . <ClassM::MPLImpl.perlLiteral> (\%ifeature));
4127 wakaba 1.34
4128     ## Score calculated from provided features
4129 wakaba 1.33 $r-><M::PLBlockCon.appendStatement>
4130     ('$Message::DOM::ClassPoint{q<' . $pack_name .
4131     '>} = ' . $ifpoint);
4132    
4133 wakaba 1.25 ## -- Roles
4134     for my $role (@{$cls-><M::ManakaiDISPropertyAccessor
4135 wakaba 1.26 .getPropertyResourceList>
4136     (<Q::DISLang:role>, isa_recursive => true,
4137     default_media_type => <Q::dis:TypeQName>)}) {
4138     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4139     (<Q::DOMMetaImpl:ImplementationSourceForManakaiDOMImplementationRegistry>)) {
4140     $r-><M::PLBlockCon.appendStatement>
4141     ('$Message::DOM::ManakaiDOMImplementationRegistry'.
4142     '::SourceClass{q<' . $pack_name . '>} = 1');
4143 wakaba 1.25 }
4144 wakaba 1.26 if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4145     (<Q::DOMMetaImpl:ImplementationForManakaiDOMImplementationSource>)) {
4146     $r-><M::PLBlockCon.appendStatement>
4147     ('$Message::DOM::ManakaiDOMImplementationSource'.
4148     '::SourceClass{q<' . $pack_name . '>} = 1');
4149     }
4150     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4151     (<Q::DOMMetaImpl:ImplementationCompatibleWithManakaiDOMMinimumImplementation>)
4152     ) {
4153 wakaba 1.25 $r-><M::PLBlockCon.appendStatement>
4154 wakaba 1.28 ('$Message::DOM::ManakaiDOMImplementation'.
4155 wakaba 1.26 '::CompatClass{q<' . $pack_name . '>} = 1');
4156 wakaba 1.25 }
4157 wakaba 1.32
4158     ## Node
4159     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4160     (<Q::DOMCore:ElementRole>)) {
4161     my $for_specific_et;
4162     for my $et (@{$cls-><M::ManakaiDISPropertyAccessor
4163     .getPropertyResourceList>
4164     (<Q::s:elementType>, isa_recursive => true,
4165     default_media_type => <Q::dis:TFQNames>)}) {
4166     $for_specific_et = true;
4167     my $ln = $et-><AG::ManakaiDISResourceDefinition
4168     .mvLocalName>;
4169     $ln = '*' unless defined $ln;
4170     my $ns = $et-><AG::ManakaiDISResourceDefinition
4171     .mvNamespaceURI>;
4172     $ns = '' unless defined $ns;
4173     ## ISSUE: Is NULL-namespace should be allowed here?
4174     $r-><M::PLBlockCon.appendStatement>
4175     ('$Message::DOM::ManakaiDOMElement' .
4176     '::CompatClassET{q<' . $ns . '>}->{q<' . $ln .
4177     '>}->{q<' . $pack_name . '>} = 1');
4178     }
4179     $r-><M::PLBlockCon.appendStatement>
4180     ('$Message::DOM::ManakaiDOMElement'.
4181     '::CompatClass{q<' . $pack_name . '>} = 1')
4182     unless $for_specific_et;
4183     }
4184     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4185     (<Q::DOMCore:AttributeRole>)) {
4186     my $for_specific_attr;
4187     for my $at (@{$cls-><M::ManakaiDISPropertyAccessor
4188     .getPropertyResourceList>
4189     (<Q::dis:DocAttr>, isa_recursive => true,
4190     default_media_type => <Q::dis:TFQNames>)}) {
4191     $for_specific_attr = true;
4192     my $ln = $at-><AG::ManakaiDISResourceDefinition
4193     .mvLocalName>;
4194     $ln = '*' unless defined $ln;
4195     my $ns = $at-><AG::ManakaiDISResourceDefinition
4196     .mvNamespaceURI>;
4197     $ns = '' unless defined $ns;
4198     my $et = $at-><AG::ManakaiDISResourceDefinition
4199     .mvOwnerElementResource>;
4200     my $etns = '*';
4201     my $etln = '*';
4202     if ($et) {
4203     $etns = $et-><AG::ManakaiDISResourceDefinition
4204     .mvLocalName>;
4205     $etln = '*' unless defined $etln;
4206     my $etns = $at-><AG::ManakaiDISResourceDefinition
4207     .mvNamespaceURI>;
4208     $etns = '' unless defined $etns;
4209     ## ISSUE: Should NULL-namespace be allowed here?
4210     }
4211    
4212     $r-><M::PLBlockCon.appendStatement>
4213     ('$Message::DOM::ManakaiDOMElement' .
4214     '::CompatClassAttr{q<' . $etns . '>}->{q<' . $etln .
4215     '>}->{q<' . $ns . '>}->{q<' . $ln . '>}->{q<' .
4216     $pack_name . '>} = 1');
4217     }
4218     $r-><M::PLBlockCon.appendStatement>
4219     ('$Message::DOM::ManakaiDOMAttr'.
4220     '::CompatClass{q<' . $pack_name . '>} = 1')
4221     unless $for_specific_attr;
4222     }
4223     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4224     (<Q::DOMCore:TextRole>)) {
4225     $r-><M::PLBlockCon.appendStatement>
4226     ('$Message::DOM::ManakaiDOMText'.
4227     '::CompatClass{q<' . $pack_name . '>} = 1');
4228     }
4229     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4230     (<Q::DOMCore:CommentRole>)) {
4231     $r-><M::PLBlockCon.appendStatement>
4232     ('$Message::DOM::ManakaiDOMComment'.
4233     '::CompatClass{q<' . $pack_name . '>} = 1');
4234     }
4235     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4236     (<Q::DOMCore:CDATASectionRole>)) {
4237     $r-><M::PLBlockCon.appendStatement>
4238     ('$Message::DOM::ManakaiDOMCDATASection'.
4239     '::CompatClass{q<' . $pack_name . '>} = 1');
4240     }
4241     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4242     (<Q::DOMCore:ProcessingInstructionRole>)) {
4243     $r-><M::PLBlockCon.appendStatement>
4244     ('$Message::DOM::ManakaiDOMProcessingInstruction'.
4245     '::CompatClass{q<' . $pack_name . '>} = 1');
4246     ## TODO: Target name dependent
4247     }
4248     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4249     (<Q::DOMCore:DocumentRole>)) {
4250 wakaba 1.34 my $for_specific_et;
4251     for my $et (@{$cls-><M::ManakaiDISPropertyAccessor
4252     .getPropertyResourceList>
4253     (<Q::s:rootElementType>, isa_recursive => true,
4254     default_media_type => <Q::dis:TFQNames>)}) {
4255     $for_specific_et = true;
4256     my $ln = $et-><AG::ManakaiDISResourceDefinition
4257     .mvLocalName>;
4258     $ln = '*' unless defined $ln;
4259     my $ns = $et-><AG::ManakaiDISResourceDefinition
4260     .mvNamespaceURI>;
4261     $ns = '' unless defined $ns;
4262     ## ISSUE: Is NULL-namespace should be allowed here?
4263     $r-><M::PLBlockCon.appendStatement>
4264     ('$Message::DOM::ManakaiDOMDocument' .
4265     '::CompatClassET{q<' . $ns . '>}->{q<' . $ln .
4266     '>}->{q<' . $pack_name . '>} = 1');
4267     }
4268 wakaba 1.32 $r-><M::PLBlockCon.appendStatement>
4269     ('$Message::DOM::ManakaiDOMDocument'.
4270 wakaba 1.34 '::CompatClass{q<' . $pack_name . '>} = 1')
4271     unless $for_specific_et;
4272 wakaba 1.32 ## TODO: by document type name and media type
4273     }
4274     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4275     (<Q::DOMCore:DocumentFragmentRole>)) {
4276     $r-><M::PLBlockCon.appendStatement>
4277     ('$Message::DOM::ManakaiDOMDocumentFragment'.
4278     '::CompatClass{q<' . $pack_name . '>} = 1');
4279     }
4280     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4281     (<Q::DOMCore:DocumentTypeRole>)) {
4282     $r-><M::PLBlockCon.appendStatement>
4283     ('$Message::DOM::ManakaiDOMDocumentType'.
4284     '::CompatClass{q<' . $pack_name . '>} = 1');
4285     ## TODO: Doctype name or public ID dependent
4286     }
4287     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4288     (<Q::DOMCore:EntityRole>)) {
4289     $r-><M::PLBlockCon.appendStatement>
4290     ('$Message::DOM::ManakaiDOMEntity'.
4291     '::CompatClass{q<' . $pack_name . '>} = 1');
4292     ## TODO: Entity name or public ID dependent
4293     }
4294     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4295     (<Q::DOMCore:EntityReferenceRole>)) {
4296     $r-><M::PLBlockCon.appendStatement>
4297     ('$Message::DOM::ManakaiDOMEntityReference'.
4298     '::CompatClass{q<' . $pack_name . '>} = 1');
4299     ## TODO: Entity name or public ID dependent
4300     }
4301     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4302     (<Q::DOMCore:NotationRole>)) {
4303     $r-><M::PLBlockCon.appendStatement>
4304     ('$Message::DOM::ManakaiDOMNotation'.
4305     '::CompatClass{q<' . $pack_name . '>} = 1');
4306     ## TODO: Notation name or public ID dependent
4307     }
4308     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4309     (<Q::DOMCore:NamespaceRole>)) {
4310     $r-><M::PLBlockCon.appendStatement>
4311     ('$Message::DOM::ManakaiDOMNamespace'.
4312     '::CompatClass{q<' . $pack_name . '>} = 1');
4313     }
4314 wakaba 1.35
4315     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4316     (<Q::DOMLS:ParserRole>)) {
4317     $r-><M::PLBlockCon.appendStatement>
4318     ('$Message::DOM::DOMLS::ParserClass{q<'.
4319     $pack_name . '>} = 1');
4320     }
4321     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4322     (<Q::DOMLS:SerializerRole>)) {
4323     $r-><M::PLBlockCon.appendStatement>
4324     ('$Message::DOM::DOMLS::SerializerClass{q<'.
4325     $pack_name . '>} = 1');
4326     }
4327 wakaba 1.25 }
4328 wakaba 1.23 } elsif ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
4329     (<Q::DISPerl:ScalarVariable>) and
4330     not $cls-><M::ManakaiDISPropertyAccessor
4331     .getPropertyResource> (<Q::dis2pm:parentResource>)) {
4332     $r-><M::PLBlockCon.appendCodeFragment>
4333     ($cls-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
4334     }
4335 wakaba 1.22 }
4336 wakaba 1.27 } # Classes
4337    
4338     ## -- Exporter (constants)
4339     if (keys %const) {
4340     my $map = <ClassM::MPLImpl.perlLiteral> (\%const);
4341     $thismod_pack-><M::PLBlockCon.appendStatement> ("sub $_ ()")
4342     for keys %const;
4343     $thismod_pack-><M::PLPack.getSub> ('AUTOLOAD', make_new_node => true)
4344     -><M::PLBlockCon.appendCode> (q[
4345     my $al = our $AUTOLOAD;
4346     $al =~ s/.+:://;
4347     if (] . $map . q[->{$al}) {
4348     no strict 'refs';
4349     *{$AUTOLOAD} = \&{] . $map . q[->{$al}};
4350     goto &{$AUTOLOAD};
4351     } else {
4352     require Carp;
4353     Carp::croak (qq<Can't locate method "$AUTOLOAD">);
4354     }
4355     ]);
4356     $thismod_pack-><M::PLPack.getSub> ('import', make_new_node => true)
4357     -><M::PLBlockCon.appendCode> (q[
4358     my $self = shift;
4359     if (@_) {
4360     local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
4361     $self->SUPER::import (@_);
4362     for (grep {not /\W/} @_) {
4363     eval qq{$_};
4364     }
4365     }
4366     ]);
4367 wakaba 1.22 }
4368    
4369 wakaba 1.24 ## -- Require'ing external modules
4370 wakaba 1.22 ## TODO: Custom module construction support
4371     for my $uri (@{$r-><M::MPLCodeFragment.disGetRequireURIList>}) {
4372     my $mod = $self->{db}-><M::ManakaiDISDatabase.getResource> ($uri)
4373     -><AG::ManakaiDISResourceDefinition.ownerModule>;
4374     next unless $mod;
4375     my $pack = $mod-><AG::ManakaiDISModuleDefinition
4376     .plFullyQualifiedName>;
4377 wakaba 1.29 $r-><M::MPLCodeFragment.addRequirePerlModuleName> ($pack)
4378 wakaba 1.22 unless $pack eq $thismod_name;
4379     }
4380 wakaba 1.24
4381    
4382 wakaba 1.22 }__;
4383    
4384 wakaba 1.24 @Method:
4385     @@Name: plIsFeatureImplemented
4386 wakaba 1.32 @@enDesc:
4387 wakaba 1.24 Returns whether a feature is implemented by this module
4388     or resource or not.
4389     \
4390     {NOTE:: For modules, tests for features not provided
4391     by the modules will return <DOM::true>. For
4392     resources, if it does not provides the support
4393     for the feature, then this method will return <DOM::true>.
4394     \
4395     }
4396     \
4397     {NOTE:: Feature inheritances are not taken into account.
4398     \
4399     }
4400     @@Param:
4401     @@@Name:featureResourceURI
4402     @@@Type: ResourceURI
4403     @@@enDesc:
4404     The URI reference of the resource definition for
4405     the feature to test.
4406     @@Return:
4407     @@@Type:
4408     DOMMain:boolean::ManakaiDOM:all
4409     @@@enDesc:
4410     Whether the feature is implemented or not.
4411     @@@PerlDef:
4412     __DEEP{
4413     if (defined $self->{<Q::DIS:isFeatureImplemented>}
4414     ->{$featureResourceURI}) {
4415     $r = $self->{<Q::DIS:isFeatureImplemented>}
4416     ->{$featureResourceURI};
4417     } elsif ($self->isa (<ClassName::ManakaiDISModuleDefinition>)) {
4418     $r = true;
4419     for my $cls (@{$self-><M::ManakaiDISPropertyAccessor
4420     .getPropertyResourceList>
4421     (<Q::DIS:resource>)}) {
4422     if ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
4423     (<Q::ManakaiDOM:Class>)) {
4424     unless ($cls-><M::ManakaiDISPerlModuleDefinition
4425     .plIsFeatureImplemented>
4426     ($featureResourceURI)) {
4427     $r = false;
4428     last;
4429     }
4430     }
4431     ## NOTE: DISPerl:ScalarVariable's are always implemented
4432     }
4433     $self->{<Q::DIS:isFeatureImplemented>}
4434     ->{$featureResourceURI} = $r;
4435     } else { ## Resource definition
4436     ## TODO: Custom module definition
4437     if ($self-><M::ManakaiDISResourceDefinition.isFeatureProvided>
4438     ($featureResourceURI)) {
4439     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4440     (<Q::DISLang:MethodReturn>) or
4441     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4442     (<Q::DISLang:AttributeGet>) or
4443     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4444     (<Q::DISLang:AttributeSet>)) {
4445     my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4446     (<Q::dis:Def>, for_arg => $self->{for},
4447     forp_arg => $self->{forp});
4448     $r = $def ? true : false;
4449     } else {
4450     $r = true;
4451     for my $res (@{$self-><M::ManakaiDISPropertyAccessor
4452     .getPropertyResourceList>
4453     (<Q::DIS:childResource>)}) {
4454     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
4455     (<Q::DISLang:AnyMethod>)) {
4456     unless ($res-><M::ManakaiDISPerlModuleDefinition
4457     .plIsFeatureImplemented>
4458     ($featureResourceURI)) {
4459     $r = false;
4460     last;
4461     }
4462     }
4463     } # for
4464     } # self.type
4465     } else {
4466     $r = true;
4467     }
4468     $self->{<Q::DIS:isFeatureImplemented>}->{$featureResourceURI} = $r;
4469     }
4470     }__;
4471 wakaba 1.22
4472     ##DISPerlModuleDefinition
4473    
4474 wakaba 1.24 PropDef:
4475     @QName: isFeatureImplemented
4476     @enDesc:
4477     The list of whether a feature is implemented or not.
4478    
4479 wakaba 1.22 ResourceDef:
4480     @QName: PLFile
4481     @AliasFor:
4482     PerlCode:ManakaiPerlFile::ManakaiDOM:Perl
4483     @rdf:type:
4484     rdfs:Class
4485    
4486     ClsDef:
4487 wakaba 1.2 @ClsQName: ManakaiDISResourceDefinition
4488     @enDesc:
4489     <QUOTE::dis> resource definitions.
4490     @ClsISA: ManakaiDISPropertyAccessor
4491 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
4492 wakaba 1.22 @ClsISA: ManakaiDISPerlModuleDefinition
4493 wakaba 1.21
4494     @IntMethod:
4495     @@Operator:
4496     @@@@:eq
4497     @@@ContentType:
4498     lang:Perl
4499     @@enDesc:
4500     Whether two <QUOTE::dis> resource definitions are equal or not.
4501     Two resource definitions are equal iff one's <A::.uri> is
4502     literally equal to another's <A::.uri>.
4503     @@Param:
4504     @@@Name: anotherResource
4505     @@@Type: ManakaiDISResourceDefinition
4506     @@@enDesc:
4507     Another resource definition to compare.
4508     @@Return:
4509     @@@Type:
4510     DOMMain:boolean::ManakaiDOM:all
4511     @@@enDesc:
4512     Whether two resources are equal or not.
4513     @@@PerlDef:
4514     if (UNIVERSAL::isa ($anotherResource,
4515     <ClassName::ManakaiDISResourceDefinition>)) {
4516     $r = $self->{uri} eq $anotherResource->{uri};
4517     } else {
4518     $r = false;
4519     }
4520 wakaba 1.2
4521     @Attr:
4522     @@Name: uri
4523     @@Type: ResourceURI
4524     @@Description:
4525     @@@lang:en
4526     @@@@:
4527     The URI reference of this <QUOTE::dis> resource.
4528     @@Get:
4529     @@@PerlDef:
4530     $r = $self->{uri};
4531    
4532     @Attr:
4533     @@Name: nameURI
4534     @@Type: NameURI
4535     @@enDesc:
4536     The URI reference of this <QUOTE::dis> resource, without
4537     <QUOTE::for> identifier.
4538     @@Get:
4539     @@@nullCase:
4540     @@@@enDesc:
4541     This resource does not have its name URI reference.
4542 wakaba 1.3 @@@PerlDef:
4543 wakaba 1.4 $r = $self->{nameURI};
4544 wakaba 1.2
4545     @Attr:
4546 wakaba 1.32 @@Name: sourceNodeID
4547     @@enDesc:
4548     The identifier URI reference of the source node.
4549     @@Type: ResourceURI
4550     @@Get:
4551     @@@nullCase:
4552     @@@@enDesc:
4553     The resource is not (yet) associated with any source node.
4554     @@@PerlDef:
4555     $r = $self->{<Q::DIS:sourceNodeID>};
4556     @@Set:
4557     @@@PerlDef:
4558     $self->{<Q::DIS:sourceNodeID>} = $given;
4559    
4560     @Attr:
4561 wakaba 1.2 @@Name: localName
4562     @@enDesc:
4563     The local name of this resource.
4564     @@Type:
4565 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
4566 wakaba 1.2 @@Get:
4567     @@@nullCase:
4568     @@@@enDesc:
4569     This resource does not have its local name.
4570     @@@PerlDef:
4571     $r = $self->{localName};
4572    
4573     @Attr:
4574     @@Name: namespaceURI
4575     @@Type: AnyURI
4576     @@enDesc:
4577     The namespace URI of the name of this resource.
4578     @@Get:
4579     @@@nullCase:
4580     The name of this resource does not have its namespace
4581     or this resource does not have its name.
4582     @@@PerlDef:
4583     $r = $self->{namespaceURI};
4584    
4585     @Attr:
4586     @@Name: isAnonymous
4587     @@enDesc:
4588     Whether this <QUOTE::dis> resource has name or not.
4589     @@Type:
4590 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4591 wakaba 1.2 @@Get:
4592     @@@TrueCase:
4593     This resource does not have any global unique name.
4594     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
4595     @@@FalseCase:
4596     This resource does have its formal name.
4597     <A::ManakaiDISResourceDefinition.uri> is a URI reference
4598     generated from the name and the <QUOTE::for> URI reference
4599     of this resource.
4600     @@@PerlDef:
4601     $r = $self->{<Q::isAnon>};
4602    
4603     @Attr:
4604     @@Name: forURI
4605     @@enDesc:
4606     The <QUOTE::for> URI reference for which this resource is defined.
4607     @@Type:ForURI
4608     @@Get:
4609     @@@PerlDef:
4610     $r = $self->{for};
4611    
4612     @Attr:
4613     @@Name: forpURI
4614     @@enDesc:
4615     The <QUOTE::for+> URI references for which this resource is defined.
4616     @@Type: ForURIList
4617     @@Get:
4618 wakaba 1.15 @@@enDesc:
4619     List of <QUOTE::for> URI references. Note that this list is
4620     <QUOTE::dead>.
4621 wakaba 1.3 @@@PerlDef:
4622 wakaba 1.15 $r = [@{$self->{forp}}];
4623    
4624     @Method:
4625     @@Name: isForURI
4626     @@enDesc:
4627     Tests whether this resource is defined for a <QUOTE::for>
4628     or <QUOTE::for+> URI reference or not.
4629     @@Param:
4630     @@@Name:forURI
4631     @@@Type:ForURI
4632     @@@enDesc:
4633     A <QUOTE::for> URI reference to test.
4634     @@Return:
4635     @@@Type:
4636     DOMMain:boolean::ManakaiDOM:all
4637     @@@TrueCase:
4638     @@@@enDesc:
4639     This resource is for <P::forURI>.
4640     @@@FalseCase:
4641     @@@@enDesc:
4642     This resource is not for <P::forURI>.
4643     @@@PerlDef:
4644     __DEEP{
4645     for my $this_for_uri ($self->{for}, @{$self->{forp}}) {
4646     if ($this_for_uri eq $forURI) { ## Shortcut
4647     $r = true;
4648     last;
4649     }
4650     my $this_for = $self->{db}-><M::ManakaiDISDatabase.getFor>
4651     ($this_for_uri);
4652     if ($this_for-><M::ManakaiDISForDefinition.isaURI> ($forURI)) {
4653     $r = true;
4654     last;
4655     }
4656     }
4657     }__;
4658 wakaba 1.2
4659     @Method:
4660 wakaba 1.7 @@Name: isSubsetOfURI
4661 wakaba 1.2 @@Description:
4662     @@@lang:en
4663     @@@@:
4664     Whether this resource is a subset of another resource or not.
4665     @@Param:
4666     @@@Name: superURI
4667     @@@Type: ResourceURI
4668     @@@Description:
4669     @@@@lang:en
4670     @@@@@:
4671     Another resource URI reference to test.
4672     @@Return:
4673     @@@Type:
4674 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4675 wakaba 1.2 @@@TrueCase:
4676     @@@@enDesc:
4677     <P::superURI> is a super-resource of this resource.
4678     @@@FalseCase:
4679     @@@@enDesc:
4680     <P::superURI> is not a super-resource of this resource.
4681     @@@PerlDef:
4682 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
4683 wakaba 1.2
4684 wakaba 1.7 @Method:
4685     @@Name: addSuperResource
4686     @@enDesc:
4687     Adds a <QUOTE::dis> resource to the list of super-resource
4688     of this <QUOTE::dis> resource.
4689     @@Param:
4690     @@@Name: superRes
4691     @@@Type: ManakaiDISResourceDefinition
4692     @@@enDesc:
4693     A <QUOTE::dis> resource definition object.
4694     @@Return:
4695     @@@PerlDef:
4696     my @from = ($self->{uri},
4697     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
4698     my @to = ($superRes->{uri},
4699     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
4700     __DEEP{
4701     for my $from (@from) {
4702     for my $to (@to) {
4703     $self->{db}-><M::ManakaiDISDatabase.getResource>
4704     ($from)->{subOf}->{$to} = true;
4705     $self->{db}-><M::ManakaiDISDatabase.getResource>
4706     ($to)->{supOf}->{$from} = true;
4707     }
4708     }
4709     }__;
4710    
4711 wakaba 1.2 @Attr:
4712     @@Name: isDefined
4713     @@Description:
4714     @@@lang:en
4715     @@@@:
4716     Whether this resource is already defined or not.
4717     @@Type:
4718 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4719 wakaba 1.2 @@Get:
4720     @@@TrueCase:
4721     This resource is already defined.
4722     @@@FalseCase:
4723     This resource is not defined.
4724     @@@PerlDef:
4725     $r = $self->{<Q::isDefined>};
4726    
4727     @Attr:
4728     @@Name: isReferred
4729     @@Description:
4730     @@@lang:en
4731     @@@@:
4732     Whether this resource is referred or not.
4733 wakaba 1.7 @@Type: ManakaiDISElement
4734 wakaba 1.2 @@Get:
4735 wakaba 1.7 @@@enDesc:
4736 wakaba 1.9 An element that referres this resource.
4737 wakaba 1.2 @@@nullCase:
4738     This resource is not referred.
4739     @@@PerlDef:
4740     $r = $self->{<Q::isReferred>};
4741     @@Set:
4742 wakaba 1.7 @@@enDesc:
4743 wakaba 1.9 An element that referres this resource.
4744 wakaba 1.2 @@@PerlDef:
4745 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
4746 wakaba 1.2
4747     @Attr:
4748 wakaba 1.22 @@Name: ownerModule
4749     @@ManakaiDOM:isRedefining:1
4750 wakaba 1.2 @@Description:
4751     @@@lang:en
4752     @@@@:
4753     The <QUOTE::dis> module in which this resource is defined.
4754     @@Type: ManakaiDISModuleDefinition
4755     @@Get:
4756     @@@Description:
4757     @@@@lang:en
4758     @@@@@:
4759     The module object.
4760 wakaba 1.3 @@@nullCase:
4761 wakaba 1.2 @@@@Description:
4762     @@@@@lang:en
4763     @@@@@@:
4764     This resource is not associated to any module.
4765     @@@PerlDef:
4766     $r = $self->{db}
4767     -><M::ManakaiDISDatabase.getModule>
4768     ($self->{<Q::definingModule>})
4769     if defined $self->{<Q::definingModule>};
4770    
4771 wakaba 1.6 @Method:
4772     @@Name: mergeAsAlias
4773     @@enDesc:
4774     Merges another resource definition as an alias of this resource.
4775     @@Param:
4776     @@@Name: aliasResource
4777     @@@Type: ManakaiDISResourceDefinition
4778     @@@enDesc:
4779     A resource to merge.
4780     \
4781     {NOTE:: After merging all references to <P::aliasResource>
4782     should be discarded.
4783     \
4784     }
4785 wakaba 1.11 @@NodeParam:
4786 wakaba 1.6 @@Return:
4787 wakaba 1.11 @@@RaiseException:
4788     @@@@@:MERGE_ITSELF_ERR
4789     @@@@@@enDesc:
4790     An attempt is made to merge this resource itself.
4791     @@@PerlDef:
4792     if ($self eq $aliasResource) {
4793     __EXCEPTION{MERGE_ITSELF_ERR::
4794     DIS:uri => {$self->{uri}},
4795     DIS:sourceNode => {$node},
4796     }__;
4797     }
4798 wakaba 1.6 for my $uri ($aliasResource->{uri},
4799     grep {$aliasResource->{aliasURI}->{$_}}
4800     keys %{$aliasResource->{aliasURI}}) {
4801     $self->{aliasURI}->{$uri} = true;
4802     $self->{db}->{resDef}->{$uri} = $self;
4803     $self->{subOf}->{$uri} = true;
4804     $self->{supOf}->{$uri} = true;
4805     }
4806     for my $uri (grep {$aliasResource->{subOf}->{$_}}
4807     keys %{$aliasResource->{subOf}}) {
4808     $self->{subOf}->{$uri} = true;
4809     }
4810     for my $uri (grep {$aliasResource->{supOf}->{$_}}
4811     keys %{$aliasResource->{supOf}}) {
4812     $self->{supOf}->{$uri} = true;
4813     }
4814     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
4815     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
4816     __DEEP{
4817     for my $from (@from) {
4818     for my $to (@to) {
4819     $self->{db}-><M::ManakaiDISDatabase.getResource>
4820     ($from)->{subOf}->{$to} = true;
4821     $self->{db}-><M::ManakaiDISDatabase.getResource>
4822     ($to)->{supOf}->{$from} = true;
4823     }
4824     }
4825     }__;
4826 wakaba 1.7
4827     @Method:
4828     @@Name: isTypeURI
4829     @@enDesc:
4830     Tests whether this resource is of a type or not.
4831     @@Param:
4832     @@@Name: typeURI
4833     @@@Type: ResourceURI
4834     @@@enDesc:
4835     A type URI reference to test.
4836     @@Return:
4837     @@@Type:
4838 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4839 wakaba 1.7 @@@TrueCase:
4840     @@@@enDesc:
4841     This is a <P::typeURI> resource.
4842     @@@FalseCase:
4843     @@@@enDesc:
4844     This is not a <P::typeURI> resource.
4845     @@@PerlDef:
4846 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
4847     $r = $self->{<Q::rdf:type>}->{$typeURI};
4848     } else {
4849     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
4850     keys %{$self->{<Q::rdf:type>}}) {
4851     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
4852     ($t_type_uri);
4853     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4854     ($typeURI)) {
4855     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
4856     last;
4857     }
4858 wakaba 1.7 }
4859     }
4860 wakaba 1.8
4861     @Attr:
4862     @@Name: plName
4863     @@enDesc:
4864     The Perl name of this resource.
4865     @@Get:
4866     @@@Type:
4867 wakaba 1.18 DISLang:String::ManakaiDOM:all
4868 wakaba 1.8 @@@enDesc:
4869     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
4870     \
4871     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
4872     <CHAR::COLON> prefix).
4873     \
4874     - <Q::DISLang:Attribute>::: Method name.
4875     \
4876     - <Q::DISLang:Method>::: Method name.
4877     @@@nullCase:
4878     @@@@enDesc:
4879     Either the type of this resource is not listed above
4880     or this Perl constructure is anonymous.
4881     @@@RaiseException:
4882     @@@@@: NO_LOCAL_NAME_ERR
4883     @@@@enDesc:
4884     The type of this resource is either
4885     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
4886     the local name of this resource is not defined.
4887     @@@RaiseException:
4888     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
4889     @@@@enDesc:
4890     The Perl method name constructed from the source
4891     result in a reserved name.
4892     @@@PerlDef:
4893     __DEEP{
4894     if (exists $self->{<Q::dis2pm:name>}) {
4895     $r = $self->{<Q::dis2pm:name>};
4896     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4897 wakaba 1.27 (<Q::DISLang:AnyMethod>)) {
4898 wakaba 1.8 if (defined $self->{localName}) {
4899     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
4900     ($self->{localName});
4901     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4902     (<Q::ManakaiDOM:isForInternal>, false)) {
4903     $r = '_' . $r;
4904     }
4905     if ({
4906     import => 1,
4907     unimport => 1,
4908     isa => 1,
4909     can => 1,
4910     new => 1,
4911     as_string => 1,
4912     stringify => 1,
4913     clone => 1,
4914     }->{$r} or $r =~ /^___/) {
4915     __UNDEEP{
4916     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4917     DIS:uri => {$self->{uri}},
4918     DIS:soruceNode => {$self->{src}},
4919     DIS:generatedName => {$r},
4920     }__;
4921     }__;
4922 wakaba 1.11 }
4923     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
4924 wakaba 1.8 .plMethodOperator>) {
4925     $r = {
4926     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
4927 wakaba 1.29 <Q::DISPerl:AsStringMethod> => 'stringify',
4928 wakaba 1.16 <Q::DISPerl:NewMethod> => 'new',
4929     <Q::DISPerl:CloneMethod> => 'clone',
4930 wakaba 1.8 }->{$op_uri};
4931     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
4932     } else {
4933     $r = null;
4934     }
4935 wakaba 1.27 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4936     (<Q::ManakaiDOM:Const>)) {
4937     unless (defined $self->{localName}) {
4938     __UNDEEP{
4939     __EXCEPTION{NO_LOCAL_NAME_ERR::
4940     DIS:uri => {$self->{uri}},
4941     DIS:sourceNode => {$self->{src}},
4942     }__;
4943     }__;
4944     }
4945     $r = uc $self->{localName};
4946     if ($r =~ /^_/ or $r =~ /_$/) {
4947     __UNDEEP{
4948     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4949     DIS:uri => {$self->{uri}},
4950     DIS:localName => {$self->{localName}},
4951     DIS:soruceNode => {$self->{src}},
4952     DIS:generatedName => {$r},
4953     }__;
4954     }__;
4955     }
4956     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4957     (<Q::ManakaiDOM:ConstGroup>)) {
4958     $r = $self->{localName};
4959     unless (defined $r) {
4960     __UNDEEP{
4961     __EXCEPTION{NO_LOCAL_NAME_ERR::
4962     DIS:uri => {$self->{uri}},
4963     DIS:sourceNode => {$self->{src}},
4964     }__;
4965     }__;
4966     }
4967 wakaba 1.8 } else {
4968     $r = null;
4969     }
4970     $self->{<Q::dis2pm:name>} = $r;
4971     }__;
4972    
4973     @Attr:
4974     @@Name: plFullyQualifiedName
4975     @@enDesc:
4976     The fully-qualified Perl name of this resource.
4977     @@Type:
4978     DISLang:String::ManakaiDOM:all
4979     @@Get:
4980     @@@enDesc:
4981     Fully-qualified name.
4982     \
4983     - <Q::ManakaiDOM:Class>::: Class package name.
4984     \
4985     - <Q::ManakaiDOM:IF>::: Interface package name.
4986     \
4987     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
4988     type symbol such as <CODE::$>).
4989     @@@nullCase:
4990     @@@@enDesc:
4991     Otherwise.
4992     @@@NoPerlModuleNameException:
4993     @@@RaiseException:
4994     @@@@@: NO_LOCAL_NAME_ERR
4995     @@@@enDesc:
4996     The local name of this resource is not defined.
4997     @@@PerlDef:
4998     __DEEP{
4999 wakaba 1.27 if (exists $self->{<Q::PerlCode.plFullyQualifiedName>}) {
5000     $r = $self->{<Q::PerlCode:plFullyQualifiedName>};
5001 wakaba 1.8 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5002     (<Q::ManakaiDOM:Class>) or
5003     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5004     (<Q::ManakaiDOM:IF>) or
5005     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5006     (<Q::DISPerl:ScalarVariable>)) {
5007 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5008 wakaba 1.8 (<Q::dis:AppName>, for_arg => $self->{for},
5009     forp_arg => $self->{forp},
5010     media_type => <Q::lang:Perl>);
5011     if ($an_node) {
5012     ## NOTE: "lang:Perl" is fully-qualified name by definition
5013 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
5014 wakaba 1.8 } else {
5015 wakaba 1.10 unless (defined $self->{localName}) {
5016     __UNDEEP{
5017     __EXCEPTION{NO_LOCAL_NAME_ERR::
5018     DIS:sourceNode => {$self->{src}},
5019     }__;
5020     }__;
5021     }
5022 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5023     (<Q::ManakaiDOM:IF>)) {
5024 wakaba 1.22 $r = $self-><AG::ManakaiDISResourceDefinition.ownerModule>
5025 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
5026 wakaba 1.8 . '::' . $self->{localName};
5027     } else {
5028 wakaba 1.22 $r = $self-><AG::ManakaiDISResourceDefinition.ownerModule>
5029 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
5030 wakaba 1.8 . '::' . $self->{localName};
5031     }
5032     }
5033 wakaba 1.27 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5034     (<Q::ManakaiDOM:Const>)) {
5035     $r = $self-><AG::ManakaiDISResourceDefinition.ownerModule>
5036     -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
5037     . '::' . $self-><AG::ManakaiDISResourceDefinition.plName>;
5038 wakaba 1.8 } else {
5039     $r = null;
5040     }
5041 wakaba 1.27 $self->{<Q::PerlCode:plFullyQualifiedName>} = $r;
5042 wakaba 1.8 }__;
5043    
5044     @Attr:
5045 wakaba 1.15 @@Name: plVariableName
5046     @@enDesc:
5047     The Perl variable name with prefix.
5048     @@Type:
5049     lang:Perl::ManakaiDOM:all
5050     @@Get:
5051     @@@nullCase:
5052     @@@@enDesc:
5053     This resource does not define any Perl variable.
5054     @@@PerlDef:
5055 wakaba 1.23 my $pnm_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5056     (<Q::dis:AppName>,
5057     for_arg => $self->{for},
5058     forp_arg => $self->{forp},
5059     media_type => <Q::lang:Perl>,
5060     default_media_type => <Q::lang:Perl>);
5061     $r = $pnm_node ? $pnm_node-><M::SWCFGNode.value> : $self->{localName};
5062 wakaba 1.15 if (defined $r) {
5063     __DEEP{
5064 wakaba 1.18 if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
5065     (<Q::DISPerl:isNamedParameter>, false)) {
5066     $r = '$opt{' .
5067 wakaba 1.21 <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
5068     ($r) .
5069 wakaba 1.18 '}';
5070 wakaba 1.22 } else {
5071     my $dt = $self-><AG::ManakaiDISResourceDefinition
5072     .disActualDataTypeResource>;
5073     if ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
5074 wakaba 1.18 (<Q::Perl:Array>)) {
5075 wakaba 1.22 $r = '@' . $r;
5076     } elsif ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
5077 wakaba 1.18 (<Q::Perl:Hash>)) {
5078 wakaba 1.22 $r = '%' . $r;
5079     } else {
5080     $r = '$' . $r;
5081     }
5082 wakaba 1.18 }
5083     }__;
5084     }
5085    
5086     @Attr:
5087     @@Name: plPrototype
5088     @@enDesc:
5089     The Perl parameter prototype character.
5090     @@Type:
5091     lang:Perl::ManakaiDOM:all
5092     @@Get:
5093     @@@PerlDef:
5094     __DEEP{
5095 wakaba 1.22 my $dt = $self-><AG::ManakaiDISResourceDefinition
5096     .disActualDataTypeResource>;
5097     if ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
5098 wakaba 1.15 (<Q::Perl:Array>)) {
5099     $r = '@' . $r;
5100 wakaba 1.22 } elsif ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
5101 wakaba 1.15 (<Q::Perl:Hash>)) {
5102     $r = '%' . $r;
5103     } else {
5104     $r = '$' . $r;
5105     }
5106     }__;
5107    
5108     @Attr:
5109 wakaba 1.8 @@Name: plMethodOperator
5110     @@enDesc:
5111     The operator to overload by this method.
5112     @@Type:
5113     DISLang:String::ManakaiDOM:all
5114     @@Get:
5115     @@@enDesc:
5116     The operator, either Perl <CODE::use operator> operator name
5117     of manakai operator URI reference.
5118     @@@nullCase:
5119     @@@@enDesc:
5120     Either this resource does not define a Perl method or
5121     this method does not overload any operator.
5122     @@@UndeclaredPrefixException:
5123     @@@RaiseException:
5124     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
5125     @@@@enDesc:
5126     Media type of the <Q::dis:Operator> node is not supported.
5127     @@@PerlDef:
5128     __DEEP{
5129     if (exists $self->{<Q::dis:Operator>}) {
5130     $r = $self->{<Q::dis:Operator>};
5131     } else {
5132     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5133     (<Q::dis:Operator>, for_arg => $self->{for},
5134     forp_arg => $self->{forp});
5135     if ($op_node) {
5136     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
5137 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
5138     for_arg => $self->{forp})) {
5139 wakaba 1.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
5140 wakaba 1.8 } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
5141 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
5142     for_arg => $self->{forp})) {
5143 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
5144     } else {
5145 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
5146     (for_arg => $self->{for},
5147     forp_arg => $self->{forp});
5148 wakaba 1.8 __UNDEEP{
5149     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
5150     DIS:uri => {$ct_uri},
5151 wakaba 1.10 DIS:sourceNode => {$op_node},
5152 wakaba 1.8 }__;
5153     }__;
5154     }
5155     } else {
5156     $r = null;
5157     }
5158     $self->{<Q::dis:Operator>} = $r;
5159     }
5160     }__;
5161    
5162     @Attr:
5163     @@Name: disDataTypeResource
5164     @@enDesc:
5165     <Q::dis:Type> attribute value of this resource.
5166     @@Type: ManakaiDISResourceDefinition
5167     @@Get:
5168     @@@RaiseException:
5169     @@@@@:NO_DIS_TYPE_ERR
5170     @@@@enDesc:
5171     <Q::dis:Type> attribute is not specified.
5172     @@@PerlDef:
5173     __DEEP{
5174     if (defined $self->{<Q::dis:Type>}) {
5175 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
5176     ($self->{<Q::dis:Type>});
5177 wakaba 1.8 } else {
5178     $self->{<Q::dis2pm:TypeNode>}
5179     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5180     (<Q::dis:Type>, for_arg => $self->{for},
5181     forp_arg => $self->{forp});
5182     if ($self->{<Q::dis2pm:TypeNode>}) {
5183     $r = $self->{<Q::dis:Type>}
5184     = $self->{<Q::dis2pm:TypeNode>}
5185 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
5186 wakaba 1.33 (null, $self->{for}, for_arg => $self->{for},
5187     forp_arg => $self->{forp});
5188 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
5189     $r-><AS::ManakaiDISResourceDefinition.isReferred>
5190     ($self->{<Q::dis2pm:TypeNode>});
5191 wakaba 1.8 } else {
5192     my $pr = $self-><M::ManakaiDISPropertyAccessor
5193     .getPropertyResource>
5194     (<Q::DIS:dynamicParentResource>);
5195     if ($pr) {
5196     $r = $pr-><AG::ManakaiDISResourceDefinition
5197     .disDataTypeResource>;
5198     $self->{<Q::dis2pm:TypeNode>}
5199     = $pr->{<Q::dis2pm:TypeNode>};
5200 wakaba 1.18 $self->{<Q::dis:Type>}
5201     = $r-><AG::ManakaiDISResourceDefinition.uri>;
5202 wakaba 1.8 } else { ## No parent
5203     __UNDEEP{
5204     __EXCEPTION{NO_DIS_TYPE_ERR::
5205     DIS:sourceNode => {$self->{src}},
5206     }__;
5207     }__;
5208     }
5209     }
5210     }
5211     }__;
5212    
5213     @Attr:
5214     @@Name: disDataTypeNode
5215     @@enDesc:
5216     <Q::dis:Type> node for this resource.
5217     @@Get:
5218     @@@Type: ManakaiDISElement
5219     @@@RaiseException:
5220     @@@@@:NO_DIS_TYPE_ERR
5221     @@@@enDesc:
5222     <Q::dis:Type> attribute is not specified.
5223     @@@PerlDef:
5224     __DEEP{
5225 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disDataTypeResource>;
5226 wakaba 1.8 }__;
5227     $r = $self->{<Q::dis2pm:TypeNode>};
5228    
5229     @Attr:
5230     @@Name: disActualDataTypeResource
5231     @@enDesc:
5232     <Q::dis:actualType> attribute value of this resource.
5233     @@Type: ManakaiDISResourceDefinition
5234     @@Get:
5235     @@@RaiseException:
5236     @@@@@:NO_DIS_TYPE_ERR
5237     @@@@enDesc:
5238     <Q::dis:actualType> attribute is not specified,
5239     and <Q::dis:Type> attribute, neigher.
5240     @@@PerlDef:
5241     __DEEP{
5242     if (defined $self->{<Q::dis:actualType>}) {
5243 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
5244     ($self->{<Q::dis:actualType>});
5245 wakaba 1.8 } else {
5246     $self->{<Q::dis2pm:actualTypeNode>}
5247     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5248     (<Q::dis:actualType>, for_arg => $self->{for},
5249     forp_arg => $self->{forp});
5250     if ($self->{<Q::dis2pm:actualTypeNode>}) {
5251     $r = $self->{<Q::dis:actualType>}
5252     = $self->{<Q::dis2pm:actualTypeNode>}
5253 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
5254 wakaba 1.33 (null, $self->{for}, for_arg => $self->{for},
5255     forp_arg => $self->{forp});
5256 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
5257     $r-><AS::ManakaiDISResourceDefinition.isReferred>
5258     ($self->{<Q::dis2pm:actualTypeNode>});
5259 wakaba 1.8 } elsif (defined $self->{<Q::dis:Type>}) {
5260     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
5261     $self->{<Q::dis2pm:actualTypeNode>}
5262     = $self->{<Q::dis2pm:TypeNode>};
5263 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
5264 wakaba 1.8 } else {
5265     $self->{<Q::dis2pm:actualTypeNode>}
5266     = $self->{<Q::dis2pm:TypeNode>}
5267     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5268     (<Q::dis:Type>, for_arg => $self->{for},
5269     forp_arg => $self->{forp});
5270     if ($self->{<Q::dis2pm:TypeNode>}) {
5271     $r = $self->{<Q::dis:actualType>}
5272     = $self->{<Q::dis:Type>}
5273     = $self->{<Q::dis2pm:TypeNode>}
5274 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
5275 wakaba 1.33 (null, $self->{for}, for_arg => $self->{for},
5276     forp_arg => $self->{forp});
5277 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
5278     $r-><AS::ManakaiDISResourceDefinition.isReferred>
5279     ($self->{<Q::dis2pm:actualTypeNode>});
5280 wakaba 1.8 } else {
5281     my $pr = $self-><M::ManakaiDISPropertyAccessor
5282     .getPropertyResource>
5283     (<Q::DIS:dynamicParentResource>);
5284     if ($pr) {
5285 wakaba 1.18 $r = $pr-><AG::ManakaiDISResourceDefinition
5286 wakaba 1.8 .disActualDataTypeResource>;
5287     $self->{<Q::dis2pm:actualTypeNode>}
5288     = $pr->{<Q::dis2pm:actualTypeNode>};
5289 wakaba 1.18 $self->{<Q::dis:actualType>}
5290     = $r-><AG::ManakaiDISResourceDefinition.uri>;
5291 wakaba 1.8 } else { ## No parent
5292     __UNDEEP{
5293     __EXCEPTION{NO_DIS_TYPE_ERR::
5294     DIS:sourceNode => {$self->{src}},
5295     }__;
5296     }__;
5297     }
5298     }
5299     }
5300     }
5301     }__;
5302    
5303     @Attr:
5304     @@Name: disActualDataTypeNode
5305     @@enDesc:
5306     <Q::dis:actualType> node for this resource.
5307     @@Get:
5308     @@@Type: ManakaiDISElement
5309     @@@RaiseException:
5310     @@@@@:NO_DIS_TYPE_ERR
5311     @@@@enDesc:
5312     <Q::dis:actualType> attribute is not specified,
5313     and <Q::dis:Type> attribute, neigher.
5314     @@@PerlDef:
5315     __DEEP{
5316 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeResource>;
5317 wakaba 1.8 }__;
5318     $r = $self->{<Q::dis2pm:actualTypeNode>};
5319 wakaba 1.9
5320     @IntMethod:
5321     @@Operator:
5322     @@@@: <=>
5323     @@@ContentType:
5324     lang:Perl
5325     @@enDesc:
5326     Which is greater (i.e. the spaceship operator).
5327     A resource is less than another if it is loaded by
5328     <M::ManakaiDISDatabase.loadResource> before another is loaded.
5329     Order for non-loaded resource definitions are not defined.
5330     \
5331     {NOTE:: In the current implementation, non-loaded resources
5332     are less than any loaded resource and the order in
5333     non-loaded resources is unknown.
5334     \
5335     }
5336     @@Param:
5337     @@@Name: anotherResource
5338     @@@Type: ManakaiDISResourceDefinition
5339     @@@enDesc: Another resource to compare.
5340     @@Return:
5341     @@@Type:
5342 wakaba 1.18 DOMMain:unsigned-long::ManakaiDOM:all
5343 wakaba 1.9 @@@PerlDef:
5344     if (UNIVERSAL::isa ($anotherResource,
5345     <ClassName::ManakaiDISResourceDefinition>)) {
5346     $r = $self->{seq} <=> $anotherResource->{seq};
5347     } else {
5348     $r = overload::Overloaded ($self) <=> $anotherResource;
5349     }
5350 wakaba 1.12
5351     @Attr:
5352     @@Name: plCodeFragment
5353     @@enDesc:
5354     Perl code definition fragment of this resource.
5355     @@Type: MPLCodeFragment
5356     @@Get:
5357     @@@enDesc:
5358     Perl code.
5359     @@@nullCase:
5360     @@@@enDesc:
5361     This node does not have Perl code definition.
5362     @@@RaiseException:
5363     @@@@@:NO_METHOD_RETURN_ERR
5364     @@@@enDesc:
5365     This resource is a <Q::DISLang:Method> but it does not
5366     have <Q::DISLang:MethodReturn> child-resource.
5367     @@@RaiseException:
5368     @@@@@:NO_ATTR_GET_ERR
5369     @@@@enDesc:
5370     This resource is a <Q::DISLang:Attribute> but it does not
5371     have <Q::DISLang:AttributeGet> child-resource.
5372     @@@RaiseException:
5373     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
5374     @@@@enDesc:
5375     The media type of <Q::dis:Def> element is not supported.
5376 wakaba 1.18 @@@RaiseException:
5377     @@@@@: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
5378     @@@@enDesc:
5379     A non-named method paarameter is defined after
5380     a named method parameter appeared.
5381 wakaba 1.19 @@@disPerlException:
5382     @@@InlineElementException:
5383     @@@BlockElementException:
5384 wakaba 1.20 @@@RaiseException:
5385     @@@@@:PERL_SUBROUTINE_ALREADY_DEFINED_ERR
5386     @@@@enDesc:
5387     A resource defines a Perl subroutine whose name is
5388     same as the name of another subroutine.
5389     @@@RaiseException:
5390     @@@@@:PERL_OPERATOR_ALREADY_OVERLOADED_ERR
5391     @@@@enDesc:
5392     A resource is defined to overload an operator
5393     that is also defined to be overloaded by another resource.
5394     @@@RaiseException:
5395     @@@@@:PERL_UNUSED_SUBROUTINE_ERR
5396     @@@@enDesc:
5397     A resource defines a Perl subroutine which is not
5398     used anywhere.
5399 wakaba 1.12 @@@PerlDef:
5400     __DEEP{
5401     if (exists $self->{<Q::plCodeFragment>}) {
5402     $r = $self->{<Q::plCodeFragment>};
5403     } elsif (not $self->{src}) {
5404     $r = $self->{<Q::plCodeFragment>} = null;
5405     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5406     (<Q::DISLang:MethodReturn>) or
5407     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5408     (<Q::DISLang:AttributeGet>) or
5409     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5410 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
5411     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5412     (<Q::dis2pm:BlockCode>) or
5413     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5414 wakaba 1.18 (<Q::dis2pm:InlineCode>) or
5415     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5416     (<Q::DISLang:InputProcessor>)) {
5417 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
5418 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5419     (<Q::dis:Def>, for_arg => $self->{for},
5420     forp_arg => $self->{forp});
5421 wakaba 1.19 my $is_inline = $self-><M::ManakaiDISResourceDefinition.isTypeURI>
5422     (<Q::dis2pm:InlineCode>) ? true : false;
5423     unless ($def) {
5424     $r = null;
5425     } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
5426 wakaba 1.29 (<Q::lang:Perl>, null,
5427     for_arg => $self->{for},
5428     forp_arg => $self->{forp})) {
5429 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
5430     ::swcfg21:ForLatest.value>;
5431 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5432 wakaba 1.19 = $is_inline
5433     ? $self-><M::ManakaiDISResourceDefinition
5434     .plPreprocessPerlStatement>
5435     ($source_code,
5436     node => $def,
5437     contains_statements => false)
5438     : $self-><M::ManakaiDISResourceDefinition
5439 wakaba 1.30 .plPreprocessPerlCode>
5440     ($source_code,
5441     node => $def,
5442     method_resource =>
5443     $self-><M::ManakaiDISResourceDefinition
5444     .isTypeURI> (<Q::DISLang:MethodReturn>)
5445     ? $self-><M::ManakaiDISPropertyAccessor
5446     .getPropertyResource>
5447     (<Q::dis2pm:parentResource>)
5448     : null);
5449 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
5450 wakaba 1.29 (<Q::lang:dis>, null,
5451     for_arg => $self->{for},
5452     forp_arg => $self->{forp})) {
5453 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5454 wakaba 1.19 = $def-><M::ManakaiDISElement.plCodeFragment>
5455     ($self, for_arg => $self->{for},
5456     forp_arg => $self->{forp},
5457     contains_statements => not $is_inline);
5458 wakaba 1.12 } else {
5459     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
5460     (for_arg => $self->{for},
5461     forp_arg => $self->{forp});
5462     __UNDEEP{
5463     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
5464     DIS:uri => {$mt},
5465     DIS:sourceNode => {$def},
5466     }__;
5467     }__;
5468     } # media type
5469     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5470     (<Q::DISLang:Method>)) {
5471 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
5472 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
5473     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
5474     unless ($ret) {
5475     __UNDEEP{
5476     __EXCEPTION{NO_METHOD_RETURN_ERR::
5477     DIS:errResource => {$self},
5478     DIS:sourceNode => {$self->{src}},
5479 wakaba 1.22 DIS:uri => {$self->{uri}},
5480     DIS:localName => {$self->{localName}},
5481 wakaba 1.12 }__;
5482     }__;
5483     }
5484 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5485 wakaba 1.18 .plImplementation>;
5486 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5487 wakaba 1.18 = $plimpl-><M::MPLImpl.createPerlSub>
5488 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
5489    
5490 wakaba 1.18 ## Method parameters
5491     my $params = $self-><M::ManakaiDISPropertyAccessor
5492     .getPropertyResourceList>
5493     (<Q::DIS:childResource>);
5494     my @param_variables;
5495     my @named_param_variables;
5496     my $prototype = '$';
5497     my $is_optional_param = false;
5498     my $is_named_param = false;
5499     for my $param (@$params) {
5500     next unless $param-><M::ManakaiDISResourceDefinition.isTypeURI>
5501     (<Q::DISLang:MethodParameter>);
5502     unless ($is_named_param) {
5503     if ($param-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
5504     (<Q::DISPerl:isNamedParameter>, false)) {
5505     $is_named_param = true;
5506     $is_optional_param = true;
5507     push @param_variables, ['%opt'];
5508     $prototype .= '%';
5509     } else { ## Non-named parameter
5510     push @param_variables, [
5511     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
5512     ];
5513     if ($param-><AG::ManakaiDISResourceDefinition.plIsNullable>) {
5514     $prototype .= ';' unless $is_optional_param;
5515     $is_optional_param = true;
5516     }
5517     $prototype .= $param-><AG::ManakaiDISResourceDefinition
5518     .plPrototype>;
5519     my $param_processor
5520     = $param-><M::ManakaiDISResourceDefinition
5521     .plGetMethodInputNormalizer>;
5522     if ($param_processor) {
5523     $param_variables[-1]->[1]
5524     = $param_processor-><AG::ManakaiDISResourceDefinition
5525     .plCodeFragment>->clone;
5526     $param_variables[-1]->[1]
5527     -><M::MPLCodeFragment.replaceVariable>
5528     ('$INPUT' => $param_variables[-1]->[0]);
5529     }
5530     }
5531     } else { ## Named parameter
5532     unless ($param-><M::ManakaiDISPropertyAccessor
5533     .getPropertyBoolean>
5534     (<Q::DISPerl:isNamedParameter>, false)) {
5535     __UNDEEP{__EXCEPTION{NON_NAMED_PARAMETER_AFTER_NAMED_ERR::
5536     DIS:sourceNode => {$param->{src}},
5537     DIS:uri => {$param->{uri}},
5538     DIS:localName => {$param->{localName}},
5539     }__}__;
5540     }
5541     }
5542     if ($is_named_param) {
5543     push @named_param_variables, [
5544     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
5545     null,
5546     '$' . $param-><AG::ManakaiDISResourceDefinition.localName>,
5547     ];
5548     my $param_processor
5549     = $param-><M::ManakaiDISResourceDefinition
5550     .plGetMethodInputNormalizer>;
5551     if ($param_processor) {
5552     $named_param_variables[-1]->[1]
5553     = $param_processor-><AG::ManakaiDISResourceDefinition
5554     .plCodeFragment>->clone;
5555     $named_param_variables[-1]->[1]
5556     -><M::MPLCodeFragment.replaceVariable>
5557     ('$INPUT' => $param_variables[-1]->[0]);
5558     }
5559     }
5560     } # %$params
5561    
5562     $r-><AS::MPLSub.prototype> ($prototype);
5563 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
5564 wakaba 1.18 ($plimpl-><M::MPLImpl.createPerlStatement>
5565     ('my (' . join (', ', '$self',
5566     map {$_->[0]} @param_variables) . ') = @_'));
5567     for my $p (@param_variables, @named_param_variables) {
5568     if ($p->[1]) { ## Input processor
5569     $r-><M::MPLSS.appendCodeFragment> ($p->[1]);
5570     }
5571     }
5572    
5573     ## TODO: in/out
5574    
5575     ## Return value
5576     my $data_type;
5577     try {
5578     $data_type = $ret-><AG::ManakaiDISResourceDefinition
5579     .disActualDataTypeResource>;
5580     } catch <Class::ManakaiDISException> with {
5581     my $err = shift;
5582     if ($err->{<Q::MDOMX:subtype>} ne <Q::NO_DIS_TYPE_ERR>) {
5583     $err->throw;
5584     }
5585     };
5586    
5587     if ($data_type) {
5588     my $def = $ret->{src}-><M::ManakaiDISElement
5589     .plValueCodeFragment>
5590 wakaba 1.23 (<Q::dis:DefaultValue>, $self,
5591 wakaba 1.18 for_arg => $self->{for},
5592     forp_arg => $self->{forp},
5593     use_default_value => true,
5594     data_type_uri => $data_type
5595     -><AG::ManakaiDISResourceDefinition.uri>);
5596     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
5597     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
5598     ('$', null, 'r');
5599     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5600     .variableScope> ('my');
5601     if ($def) {
5602     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
5603     } else {
5604     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
5605     }
5606     $r-><M::MPLSS.appendCodeFragment> ($rs);
5607     }
5608    
5609     my $code = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5610 wakaba 1.19 if ($code) {
5611     for my $np (@named_param_variables) {
5612     $code-><M::MPLCodeFragment.replaceVariable>
5613     ($np->[2] => $np->[0]);
5614     }
5615     $r-><M::MPLSS.appendCodeFragment> ($code);
5616    
5617     $ret->{<Q::DIS:plDefined>} = true;
5618     $self->{<Q::DIS:plDefined>} = true;
5619 wakaba 1.21 } else { ## Method code not defined
5620 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5621     (<Q::DOMException:CoreException>,
5622     for_arg => <Q::ManakaiDOM:Perl>);
5623     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5624 wakaba 1.30 (<Q::DOMException:NOT_SUPPORTED_ERR>,
5625 wakaba 1.19 for_arg => <Q::ManakaiDOM:Perl>);
5626     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5627     (<Q::MDOMX:MDOM_IMPL_METHOD_NOT_IMPLEMENTED>,
5628     for_arg => <Q::ManakaiDOM:Perl>);
5629     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5630     ($ret->{src}) for $cls, $const, $subtype;
5631     my $context_param = $ret-><M::ManakaiDISResourceDefinition
5632     .plGetContextParameter>;
5633     $self-><M::ManakaiDISResourceDefinition
5634     .plAppendThrow>
5635     ($r, $cls, $const, $subtype,
5636     {%$context_param});
5637     $ret->{<Q::DIS:plDefined>} = false;
5638     $self->{<Q::DIS:plDefined>} = false;
5639 wakaba 1.18 }
5640 wakaba 1.12
5641 wakaba 1.18 if ($data_type) {
5642     $r-><M::MPLSS.appendCodeFragment>
5643     ($plimpl-><M::MPLImpl.createPerlVariable>
5644     ('$', null, 'r'));
5645     }
5646 wakaba 1.12 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5647     (<Q::DISLang:Attribute>)) {
5648 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
5649 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
5650     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
5651     unless ($get) {
5652     __UNDEEP{
5653     __EXCEPTION{NO_ATTR_GET_ERR::
5654     DIS:errResource => {$self},
5655     DIS:sourceNode => {$self->{src}},
5656     }__;
5657     }__;
5658     }
5659 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5660 wakaba 1.20 .plImplementation>;
5661 wakaba 1.19 my $data_type = $get-><AG::ManakaiDISResourceDefinition
5662     .disActualDataTypeResource>;
5663     my $get_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5664 wakaba 1.21 $get_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5665 wakaba 1.19 my $code = $get-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5666     if ($code) {
5667     ## Default value
5668     my $def = $get->{src}-><M::ManakaiDISElement
5669     .plValueCodeFragment>
5670 wakaba 1.23 (<Q::dis:DefaultValue>, $self,
5671 wakaba 1.19 for_arg => $self->{for},
5672     forp_arg => $self->{forp},
5673     use_default_value => true,
5674     data_type_uri => $data_type
5675     -><AG::ManakaiDISResourceDefinition.uri>);
5676     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
5677     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
5678     ('$', null, 'r');
5679     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5680     .variableScope> ('my');
5681     if ($def) {
5682     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
5683     } else {
5684     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
5685     }
5686     $get_code-><M::PLBlockCon.appendCodeFragment> ($rs);
5687    
5688     ## Main code
5689     $get_code-><M::PLBlockCon.appendCodeFragment> ($code);
5690    
5691     ## Return value
5692     $get_code-><M::PLBlockCon.appendStatement> (q<$r>);
5693    
5694     $get->{<Q::DIS:plDefined>} = true;
5695     } else { ## Getter code not defined
5696     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5697     (<Q::DOMException:CoreException>,
5698     for_arg => <Q::ManakaiDOM:Perl>);
5699     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5700 wakaba 1.30 (<Q::DOMException:NOT_SUPPORTED_ERR>,
5701 wakaba 1.19 for_arg => <Q::ManakaiDOM:Perl>);
5702     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5703     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
5704     for_arg => <Q::ManakaiDOM:Perl>);
5705     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5706     ($get->{src}) for $cls, $const, $subtype;
5707     my $context_param = $get-><M::ManakaiDISResourceDefinition
5708     .plGetContextParameter>;
5709     $self-><M::ManakaiDISResourceDefinition
5710     .plAppendThrow>
5711     ($get_code, $cls, $const, $subtype,
5712     {%$context_param});
5713     $get->{<Q::DIS:plDefined>} = false;
5714     $self->{<Q::DIS:plDefined>} = false;
5715     }
5716    
5717     my $set = $self-><M::ManakaiDISResourceDefinition
5718     .getChildResourceByType> (<Q::DISLang:AttributeSet>);
5719     my $set_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5720     if ($set) {
5721     my $data_type = $set-><AG::ManakaiDISResourceDefinition
5722     .disActualDataTypeResource>;
5723     my $code = $set-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5724     if ($code) {
5725     ## Input
5726     $set_code-><M::PLBlockCon.appendStatement>
5727     (q<my ($self, $given) = @_>);
5728     my $param_processor
5729     = $set-><M::ManakaiDISResourceDefinition
5730     .plGetMethodInputNormalizer>;
5731     if ($param_processor) {
5732     my $pcode = $param_processor-><AG::ManakaiDISResourceDefinition
5733     .plCodeFragment>->clone;
5734     $pcode-><M::MPLCodeFragment.replaceVariable>
5735     ('$INPUT' => '$given');
5736     $set_code-><M::PLBlockCon.appendCodeFragment> ($pcode);
5737     }
5738    
5739     ## Main code
5740     $set_code-><M::PLBlockCon.appendCodeFragment> ($code);
5741    
5742     $set->{<Q::DIS:plDefined>} = true;
5743     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
5744     } else { ## Setter code not defined
5745 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5746 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5747     (<Q::DOMException:CoreException>,
5748     for_arg => <Q::ManakaiDOM:Perl>);
5749     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5750 wakaba 1.30 (<Q::DOMException:NOT_SUPPORTED_ERR>,
5751 wakaba 1.19 for_arg => <Q::ManakaiDOM:Perl>);
5752     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5753     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
5754     for_arg => <Q::ManakaiDOM:Perl>);
5755     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5756     ($set->{src}) for $cls, $const, $subtype;
5757     my $context_param = $get-><M::ManakaiDISResourceDefinition
5758     .plGetContextParameter>;
5759     $self-><M::ManakaiDISResourceDefinition
5760     .plAppendThrow>
5761     ($set_code, $cls, $const, $subtype,
5762     {%$context_param});
5763     }
5764     $set->{<Q::DIS:plDefined>} = false;
5765     $self->{<Q::DIS:plDefined>} = false;
5766     } else { ## No attribute setter
5767 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5768 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5769     (<Q::DOMException:CoreException>,
5770     for_arg => <Q::ManakaiDOM:Perl>);
5771     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5772     (<Q::DOMException:NO_MODIFICATION_ALLOWED_ERR>,
5773     for_arg => <Q::ManakaiDOM:Perl>);
5774     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5775     (<Q::DOMException:READ_ONLY_ATTRIBUTE_ERR>,
5776     for_arg => <Q::ManakaiDOM:Perl>);
5777     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5778     ($self->{src}) for $cls, $const, $subtype;
5779     my $context_param = $get-><M::ManakaiDISResourceDefinition
5780     .plGetContextParameter>;
5781     $self-><M::ManakaiDISResourceDefinition
5782     .plAppendThrow>
5783     ($set_code, $cls, $const, $subtype,
5784     {%$context_param});
5785     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
5786     }
5787    
5788 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5789 wakaba 1.19 = $plimpl-><M::MPLImpl.createPerlSub>
5790 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
5791 wakaba 1.19 $r-><AS::MPLSub.prototype> (q<$;$>);
5792 wakaba 1.12
5793 wakaba 1.19 ## TODO: Don't output "if" if non-debug build
5794 wakaba 1.12
5795 wakaba 1.19 $r-><M::PLBlockCon.appendNewIf>
5796     ($plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
5797     (q<@_ == 1>),
5798     $get_code,
5799     $set_code);
5800 wakaba 1.25
5801     ## -- Constants
5802 wakaba 1.20 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5803 wakaba 1.21 (<Q::ManakaiDOM:Const>)) {
5804     my $data_type = $self-><AG::ManakaiDISResourceDefinition
5805     .disActualDataTypeResource>;
5806     my $value = $self->{src}
5807     -><M::ManakaiDISElement.plValueCodeFragment>
5808 wakaba 1.23 (<Q::dis:Value>, $self,
5809 wakaba 1.21 for_arg => $self->{for},
5810     forp_arg => $self->{forp},
5811     data_type_uri => $data_type
5812     -><AG::ManakaiDISResourceDefinition.uri>);
5813 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5814 wakaba 1.21 .plImplementation>;
5815     $r = $plimpl-><M::MPLImpl.createPerlSub>
5816     ($self-><AG::ManakaiDISResourceDefinition.plName>);
5817     $r-><M::PLBlockCon.appendCodeFragment> ($value);
5818     $r-><AS::MPLSub.prototype> ('');
5819 wakaba 1.25
5820     ## -- Classes
5821 wakaba 1.21 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5822 wakaba 1.20 (<Q::ManakaiDOM:Class>)) {
5823 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5824 wakaba 1.20 .plImplementation>;
5825     $r = $plimpl-><M::MPLImpl.createPerlPackage>
5826     ($self-><AG::ManakaiDISResourceDefinition
5827     .plFullyQualifiedName>);
5828 wakaba 1.25 ## - Inheritance
5829 wakaba 1.20 for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5830     .getPropertyResourceList>
5831     (<Q::dis:ISA>,
5832     default_media_type => <Q::dis:TFQNames>)}) {
5833     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5834     .plFullyQualifiedName>;
5835     if (defined $spack_name) {
5836     $r-><M::PLPack.addISAPackage> ($spack_name);
5837     }
5838 wakaba 1.22 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
5839     ($scls => $r);
5840 wakaba 1.20 }
5841 wakaba 1.25
5842 wakaba 1.29 for my $el (@{$self->{src}-><M::ManakaiDISElement
5843     .disChildElements>
5844     (for_arg => $self->{for},
5845     forp_arg => $self->{forp})}) {
5846     if ($el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest.expandedURI>
5847     eq <Q::dis:AppISA> and
5848     $el-><M::ManakaiDISElement.mediaTypeMatch>
5849     (<Q::lang:Perl>, <Q::lang:Perl>,
5850     for_arg => $self->{for},
5851     forp_arg => $self->{forp})) {
5852     my $spack_name = $el-><M::SWCFGNode.value>;
5853     $r-><M::PLPack.addISAPackage> ($spack_name);
5854     $r-><M::MPLCodeFragment.addRequirePerlModuleName>
5855     ($spack_name);
5856     }
5857     }
5858    
5859 wakaba 1.25 ## - Implementing interfaces
5860 wakaba 1.20 for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5861     .getPropertyResourceList>
5862     (<Q::dis:Implement>, recursive_isa => true,
5863     default_media_type => <Q::dis:TFQNames>)}) {
5864     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5865     .plFullyQualifiedName>;
5866     if (defined $spack_name) {
5867     $r-><M::PLPack.addImplementPackage> ($spack_name);
5868     }
5869     }
5870    
5871 wakaba 1.25 ## - Class members
5872 wakaba 1.20 my @cr = @{$self-><M::ManakaiDISPropertyAccessor
5873     .getPropertyResourceList>
5874     (<Q::DIS:childResource>)};
5875 wakaba 1.21 my @const;
5876 wakaba 1.20 for my $cr (@cr) {
5877 wakaba 1.25 ## - Subroutines
5878 wakaba 1.20 if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5879     (<Q::DISLang:Method>) or
5880     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5881     (<Q::DISLang:Attribute>)) {
5882     my $is_attr = $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5883     (<Q::DISLang:Attribute>) ? true : false;
5884     my $pname = $cr-><AG::ManakaiDISResourceDefinition.plName>;
5885     my $op = $cr-><AG::ManakaiDISResourceDefinition
5886     .plMethodOperator>;
5887     my $psub = $cr-><AG::ManakaiDISResourceDefinition
5888     .plCodeFragment>;
5889     if (defined $pname) {
5890     if ($r-><M::PLPack.getSub> ($pname)) {
5891     __UNDEEP{__EXCEPTION{PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5892     PerlCode:localName => {$pname},
5893     DIS:uri => {$cr->{uri}},
5894     DIS:sourceNode => {$cr->{src}},
5895     }__}__;
5896     }
5897     $r-><M::PLPack.setSub> ($pname => $psub);
5898    
5899 wakaba 1.29 if (defined $op and
5900     defined $cr-><AG::ManakaiDISResourceDefinition
5901     .localName>) {
5902 wakaba 1.20 if ($op =~ /^[A-Z]+$/) {
5903     if ($r-><M::PLPack.getSubAliasName> ($op)) {
5904     __UNDEEP{__EXCEPTION{
5905     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5906     PerlCode:localName => {$op},
5907     DIS:uri => {$cr->{uri}},
5908     DIS:sourceNode => {$cr->{src}},
5909     }__}__;
5910     }
5911     $r-><M::PLPack.setSubAliasName> ($op => $pname);
5912     } else {
5913     if ($r-><M::PLPack.getOverloadMethodName> ($op)) {
5914     __UNDEEP{__EXCEPTION{
5915     PERL_OPERATOR_ALREADY_OVERLOADED_ERR::
5916     PerlCode:operator => {$op},
5917     DIS:uri => {$cr->{uri}},
5918     DIS:sourceNode => {$cr->{src}},
5919     }__}__;
5920     }
5921     $r-><M::PLPack.setOverloadMethodName> ($op => $pname);
5922     }
5923     }
5924     } elsif (defined $op) {
5925     $r-><M::PLPack.setOverloadSub> ($op => $psub);
5926     } else {
5927     __UNDEEP{__EXCEPTION{PERL_UNUSED_SUBROUTINE_ERR::
5928     DIS:uri => {$cr->{uri}},
5929     DIS:sourceNode => {$cr->{src}},
5930     }__}__;
5931     }
5932 wakaba 1.25 ## - Constant groups
5933 wakaba 1.21 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5934     (<Q::ManakaiDOM:ConstGroup>)) {
5935     for my $gcr (@{$cr-><M::ManakaiDISPropertyAccessor
5936     .getPropertyResourceList>
5937     (<Q::DIS:childResource>)}) {
5938     if ($gcr-><M::ManakaiDISResourceDefinition.isTypeURI>
5939     (<Q::ManakaiDOM:Const>)) {
5940     my $sub = $gcr-><AG::ManakaiDISResourceDefinition
5941     .plCodeFragment>;
5942     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5943     __UNDEEP{__EXCEPTION{
5944     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5945     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5946     DIS:uri => {$gcr->{uri}},
5947     DIS:sourceNode => {$gcr->{src}},
5948     }__}__;
5949     }
5950     $r-><M::PLPack.setSub>
5951     ($sub-><AG::MPLSub.localName> => $sub);
5952     push @const, $gcr;
5953     }
5954     }
5955 wakaba 1.25 ## - Constants
5956 wakaba 1.21 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5957     (<Q::ManakaiDOM:Const>)) {
5958     my $sub = $cr-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5959     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5960     __UNDEEP{__EXCEPTION{
5961     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5962     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5963     DIS:uri => {$cr->{uri}},
5964     DIS:sourceNode => {$cr->{src}},
5965     }__}__;
5966     }
5967     $r-><M::PLPack.setSub> ($sub-><AG::MPLSub.localName> => $sub);
5968     push @const, $cr;
5969 wakaba 1.25 ## Package-scope variables
5970 wakaba 1.23 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5971     (<Q::DISPerl:ScalarVariable>)) {
5972     my $varn = $cr-><AG::ManakaiDISResourceDefinition
5973     .plVariableName>;
5974     my $var = $plimpl-><M::MPLImpl.createPerlVariable>
5975     (null, null, $varn);
5976     my $data_type = $cr-><AG::ManakaiDISResourceDefinition
5977     .disActualDataTypeResource>;
5978     my $value = $cr->{src}
5979     -><M::ManakaiDISElement.plValueCodeFragment>
5980     (<Q::dis:DefaultValue>, $cr,
5981     for_arg => $cr->{for},
5982     forp_arg => $cr->{forp},
5983     use_default_value => true,
5984     data_type_uri => $data_type
5985     -><AG::ManakaiDISResourceDefinition.uri>);
5986     if ($cr-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
5987     (<Q::DISPerl:defaultValueHasSelfReference>)) {
5988     $r-><M::PLBlockCon.appendStatement>
5989     -><M::PLBlockCon.appendCodeFragment> (my $v = $var->clone);
5990     $v-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5991     .variableScope> ('our');
5992     } else {
5993     $var-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5994     .variableScope> ('our');
5995     }
5996     $r-><M::PLBlockCon.appendStatement>
5997     -><M::PLAnyCon.appendNewAssignment> ($var => $value);
5998     } # Type of child resources
5999 wakaba 1.20 }
6000 wakaba 1.21
6001 wakaba 1.25 ## - Exceptions
6002 wakaba 1.21 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6003     (<Q::DOMException:AnyExceptionClass>)) {
6004     my $err_def = $plimpl-><M::MPLImpl.createPerlSub> ('___error_def');
6005     $err_def-><AS::MPLSub.prototype> ('');
6006     $err_def-><M::PLBlockCon.appendCode>
6007     ($plimpl-><M::MPLImpl.perlList>
6008     ([{
6009     map {
6010     $_-><AG::ManakaiDISResourceDefinition.plName> => {
6011     <Q::DOMCore:code> => 0 + $_
6012     -><AG::ManakaiDISResourceDefinition.plCodeFragment>,
6013     description => $_
6014     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
6015     # ($_->{ExpandedURI q< DOMCore:severity>}
6016     # ? (ExpandedURI q< DOMCore:severity>
6017     # => $_->{ExpandedURI q< DOMCore:severity>},
6018     # ExpandedURI q< DOMCore:type>
6019     # => $_->{ExpandedURI q< DOMCore:type>})
6020     # : ()),
6021     <Q::MDOMX:subtype> => {
6022     map {
6023     $_-><AG::ManakaiDISResourceDefinition.nameURI>
6024     => {
6025     description => $_
6026     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
6027     # ($_->{ExpandedURI q< DOMCore:severity>}
6028     # ? (ExpandedURI q< DOMCore:severity>
6029     # => $_->{ExpandedURI q< DOMCore:severity>},
6030     # ExpandedURI q< DOMCore:type>
6031     # => $_->{ExpandedURI q< DOMCore:type>})
6032     # : ()),
6033     },
6034     } grep {
6035     $_-><M::ManakaiDISResourceDefinition.isTypeURI>
6036     (<Q::ManakaiDOM:ExceptionOrWarningSubType>)
6037     } @{$_-><M::ManakaiDISPropertyAccessor
6038     .getPropertyResourceList>
6039     (<Q::DIS:childResource>)}
6040     },
6041     },
6042     } @const
6043     }]));
6044     $r-><M::PLPack.setSub> (___error_def => $err_def);
6045     }
6046 wakaba 1.25
6047     ## -- Global variables
6048 wakaba 1.23 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6049     (<Q::DISPerl:ScalarVariable>)) {
6050     my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
6051     .plImplementation>;
6052     my $varn = $self-><AG::ManakaiDISResourceDefinition.plVariableName>;
6053     my $var = $plimpl-><M::MPLImpl.createPerlVariable>
6054     (null, null, $varn);
6055     my $data_type = $self-><AG::ManakaiDISResourceDefinition
6056     .disActualDataTypeResource>;
6057     my $value = $self->{src}
6058     -><M::ManakaiDISElement.plValueCodeFragment>
6059     (<Q::dis:DefaultValue>, $self,
6060     for_arg => $self->{for},
6061     forp_arg => $self->{forp},
6062     use_default_value => true,
6063     data_type_uri => $data_type
6064     -><AG::ManakaiDISResourceDefinition.uri>);
6065     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
6066     $r-><M::PLAnyCon.appendNewAssignment> ($var => $value);
6067 wakaba 1.13 } else { ## Not supported
6068 wakaba 1.19 $r = $self->{<Q::plCodeFragment>} = null;
6069 wakaba 1.12 } # rdf:type
6070     }__;
6071    
6072     @Method:
6073     @@Name: getChildResourceByType
6074     @@enDesc:
6075     Gets a static child resource selected by its type.
6076     @@Param:
6077     @@@Name:typeURI
6078     @@@Type:ResourceURI
6079     @@@enDesc:
6080     A URI reference identifying a resource type.
6081     @@Return:
6082     @@@Type: ManakaiDISResourceDefinition
6083     @@@enDesc:
6084     The first (by document order) child resource whose
6085     type matches with <P::resType>.
6086     @@@nullCase:
6087     @@@@enDesc:
6088     There is no resource whose type is <P::resType>.
6089     @@@PerlDef:
6090     __DEEP{
6091 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
6092 wakaba 1.12 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
6093 wakaba 1.26 ($cr_uri);
6094 wakaba 1.12 if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
6095     $r = $cr;
6096     last;
6097     }
6098     }
6099     }__;
6100 wakaba 1.13
6101     @Method:
6102     @@Name: getChildResourceByNameAndType
6103     @@enDesc:
6104     Gets a static child resource selected by its local name and type.
6105     @@Param:
6106     @@@Name: localName
6107     @@@Type:
6108     DISCore:LocalName::ManakaiDOM:all
6109     @@@enDesc:
6110     A local name.
6111     @@Param:
6112     @@@Name:typeURI
6113     @@@Type:ResourceURI
6114     @@@enDesc:
6115     A URI reference identifying a resource type.
6116     @@Return:
6117     @@@Type: ManakaiDISResourceDefinition
6118     @@@enDesc:
6119     The first (by document order) child resource whose
6120     type matches for <P::localName> and <P::resType>.
6121     @@@nullCase:
6122     @@@@enDesc:
6123     There is no resource whose name is <P::localName> and
6124     whose type is <P::resType>.
6125     @@@PerlDef:
6126     __DEEP{
6127 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
6128 wakaba 1.13 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
6129 wakaba 1.26 ($cr_uri);
6130 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
6131 wakaba 1.13 if (defined $ln and $ln eq $localName and
6132     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
6133     $r = $cr;
6134     last;
6135     }
6136     }
6137     }__;
6138    
6139     @Method:
6140     @@Name: getConstResourceByName
6141     @@enDesc:
6142     Gets a constant value resource by its local name.
6143     @@Param:
6144     @@@Name:localName
6145     @@@Type:
6146     DISLang:String::ManakaiDOM:all
6147     @@@enDesc:
6148     Constant name.
6149     @@Return:
6150     @@@Type: ManakaiDISResourceDefinition
6151     @@@enDesc:
6152     The constant resource identified by <P::localName>.
6153     @@@nullCase:
6154     @@@@enDesc:
6155     There is no such constant resource.
6156     @@@PerlDef:
6157     __DEEP{
6158     my @constGroup;
6159 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
6160 wakaba 1.13 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
6161 wakaba 1.26 ($cr_uri);
6162 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
6163 wakaba 1.13 if ($ln and $ln eq $localName and
6164     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
6165     (<Q::ManakaiDOM:Const>)) {
6166     $r = $cr;
6167     last;
6168     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
6169     (<Q::ManakaiDOM:ConstGroup>)) {
6170     push @constGroup, $cr;
6171     }
6172     }
6173     unless ($r) {
6174     for my $cg (@constGroup) {
6175     $r = $cg-><M::ManakaiDISResourceDefinition
6176     .getChildResourceByNameAndType>
6177     ($localName, <Q::ManakaiDOM:Const>);
6178     last if $r;
6179     }
6180     }
6181     }__;
6182    
6183 wakaba 1.23 @ResourceDef:
6184     @@Name: RegQNameChar
6185     @@enDesc:
6186     A regular expression character class for <Q::dis:TypeQName>
6187     character.
6188     @@rdf:type:
6189     DISPerl:ScalarVariable
6190     @@DefaultValue:
6191     @@@@: qr/[^\s<>"'\\\[\]\{\},=\$\@%]/
6192     @@@ContentType:
6193     lang:Perl
6194     @@Type:
6195     DOMMain:any::ManakaiDOM:all
6196    
6197     @ResourceDef:
6198     @@Name: RegBlockContent
6199     @@enDesc:
6200     A regular expression for a block.
6201     @@rdf:type:
6202     DISPerl:ScalarVariable
6203     @@Type:
6204     DOMMain:any::ManakaiDOM:all
6205     @@DefaultValue:
6206     @@@@:
6207     qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{$RegBlockContent})\})*)/
6208     @@@ContentType:
6209     lang:Perl
6210     @@DISPerl:defaultValueHasSelfReference:1
6211    
6212 wakaba 1.13 @Method:
6213     @@Name: plPreprocessPerlCode
6214     @@enDesc:
6215     Preprocesses a Perl block-level code fragment.
6216     @@Param:
6217     @@@Name:codeArg
6218     @@@Type:
6219     lang:Perl::ManakaiDOM:all
6220     @@@enDesc:
6221     A Perl block-level code (statements and/or blocks).
6222 wakaba 1.15 @@NodeParam:
6223     @@NamedParam:
6224     @@@Name:methodResource
6225     @@@Type:ManakaiDISResourceDefinition
6226     @@@enDesc:
6227     The resource definition of the Perl method to which
6228     the <P::codeArg> belongs.
6229     @@@nullCase:
6230     @@@@enDesc:
6231     The <P::codeArg> does not belong to any method.
6232 wakaba 1.17 @@NamedParam:
6233     @@@Name:sourceFile
6234     @@@Type:
6235     DISLang:String::ManakaiDOM:all
6236     @@@enDesc:
6237     The source file name of the <P::codeArg>.
6238     @@@nullCase:
6239     @@@@enDesc:
6240     No source file information available.
6241     @@NamedParam:
6242     @@@Name:sourceLine
6243     @@@Type:
6244     DOMMain:unsigned-long::ManakaiDOM:all
6245     @@@enDesc:
6246     The line number in the <P::sourceFile> from which
6247     the <P::codeArg> begins.
6248     @@@nullCase:
6249     @@@@enDesc:
6250     No source file information available.
6251 wakaba 1.13 @@Return:
6252     @@@Type:
6253     lang:Perl::ManakaiDOM:all
6254     @@@enDesc:
6255     Preprocessed Perl code.
6256 wakaba 1.15 @@@BlockElementException:
6257     @@@InlineElementException:
6258 wakaba 1.13 @@@PerlDef:
6259 wakaba 1.15 unless ($self->{src}) {
6260     __EXCEPTION{NO_SOURCE_NODE_ERR::
6261     DIS:uri => {$self->{uri}},
6262     }__;
6263     }
6264     __DEEP{
6265     our $RegQNameChar;
6266     our $RegBlockContent;
6267 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor.plImplementation>;
6268 wakaba 1.15 $r = $plimpl-><M::MPLImpl.createPerlBlock>;
6269 wakaba 1.17 if (defined $sourceLine) {
6270     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
6271     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
6272     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
6273     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
6274     } elsif ($node) {
6275     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
6276     (key => [qw/Name QName Type type/]);
6277     $r-><AS::PLBlockCon.currentSourceFile> ($np);
6278     $r-><AS::PLBlockCon.currentSourceLine> (1);
6279     $r-><AS::PLBlockCon.sourceFile> ($np);
6280     $r-><AS::PLBlockCon.sourceLine> (1);
6281     }
6282 wakaba 1.15
6283 wakaba 1.16 for my $source_code (split /\b(_ _(?:(?!_ _)$RegQNameChar)+
6284 wakaba 1.15 (?:\{$RegBlockContent\})?
6285 wakaba 1.16 _ _)\b/x, $codeArg) {
6286 wakaba 1.15 ## Block-level element
6287 wakaba 1.16 if ($source_code =~ /_\_\z/ and
6288     $source_code =~ s/^_\_((?:(?!_\_)$RegQNameChar)+)//) {
6289 wakaba 1.15 my $et = $self->{src}
6290     -><M::ManakaiDISElement.qnameToURI>
6291     ($1,
6292     node => $node,
6293     default_namespace_uri => <Q::disPerl:>);
6294     if ($source_code =~ s/^\{//) {
6295     $source_code =~ s/\}__\z//;
6296     } else {
6297     $source_code = '';
6298     }
6299    
6300     # ## ISSUE: __FILE__ & __LINE__ will break if multiline substition happens.
6301    
6302     if ($et eq <Q::disPerl:DEEP> or $et eq <Q::disPerl:UNDEEP>) {
6303     my $block = $r-><M::PLBlockCon.appendBlock>;
6304     $block-><M::PLBlockCon.appendStatement>
6305     ('local $Error::Depth = $Error::Depth '.
6306     ($et eq <Q::disPerl:DEEP> ? '+' : '-').
6307     ' 1');
6308     $block-><M::PLBlockCon.appendCodeFragment>
6309 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
6310     .plPreprocessPerlCode>
6311     ($source_code, node => $node,
6312     method_resource => $methodResource,
6313     source_file => $r-><AG::PLBlockCon
6314     .currentSourceFile>,
6315     source_line => $r-><AG::PLBlockCon
6316     .currentSourceLine>));
6317     $r-><M::PLBlockCon.skipLines> ($source_code);
6318 wakaba 1.15 } elsif ({
6319     <Q::disPerl:EXCEPTION> => 1,
6320     <Q::disPerl:WARNING> => 1,
6321     }->{$et}) {
6322 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
6323 wakaba 1.29 if ($source_code =~ s/^((?:(?!::).)+)(?:::\s*)?//s) {
6324 wakaba 1.15 my ($cls, $const, $subtype)
6325     = @{$self->{db}-><M::ManakaiDISDatabase.xcrefToResource>
6326 wakaba 1.16 ($1, $self->{src},
6327     node => $node,
6328     for_arg => $self->{for})};
6329 wakaba 1.15 my $param = $self-><M::ManakaiDISResourceDefinition
6330     .plParsePreprocessParameter>
6331     ($source_code, node => $node);
6332     my $context_param
6333     = $self-><M::ManakaiDISResourceDefinition
6334     .plGetContextParameter>;
6335    
6336     $self-><M::ManakaiDISResourceDefinition
6337     .plAppendThrow>
6338     ($r, $cls, $const, $subtype,
6339     {%$param, %$context_param});
6340     } else {
6341     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR::
6342     DIS:sourceNode => {$node},
6343     DIS:sourceCode => {$source_code},
6344     DIS:elementType => {$et},
6345     }__}__;
6346     }
6347     } elsif ($et eq <Q::disPerl:CODE>) {
6348 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
6349 wakaba 1.15 my $code_name;
6350     $source_code =~ s/^\s+//;
6351     if ($source_code =~ s/^((?>(?!::).)+)//s) {
6352     $code_name = $1;
6353     } else {
6354     __UNDEEP{
6355     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
6356     DIS:sourceCode => {$source_code},
6357     DIS:sourceNode => {$node},
6358     DIS:elementType => {$et},
6359     }__;
6360     }__;
6361     }
6362     $source_code =~ s/^::\s*//;
6363     my $param = $self-><M::ManakaiDISResourceDefinition
6364     .plParsePreprocessParameter>
6365     ($source_code, node => $node);
6366     my $code_uri = $self->{src}-><M::ManakaiDISElement
6367     .tfqnamesToURI>
6368     ($code_name, null, $self->{for},
6369     node => $node);
6370     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
6371     ($code_uri);
6372     $code-><AS::ManakaiDISResourceDefinition.isReferred>
6373     ($node || $self->{src});
6374     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
6375     (<Q::dis2pm:BlockCode>)) {
6376     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6377     DIS:uri => {$code_uri},
6378     DIS:sourceNode => {$node},
6379     DIS:sourceCode => {$source_code},
6380     DIS:expectedType => {<Q::dis2pm:BlockCode>},
6381     }__;}__;
6382     }
6383     my $pc = $code-><AG::ManakaiDISResourceDefinition
6384     .plCodeFragment>->clone;
6385     unless (defined $pc) {
6386     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
6387     DIS:sourceNode => {$node},
6388     DIS:sourceCode => {$source_code},
6389     DIS:uri => {$code_uri},
6390     }__}__;
6391     }
6392     for my $var (grep {/^\$/} keys %$param) {
6393     my $value;
6394     if ($param->{$var}->{type} eq 'variable') {
6395     $value = $plimpl-><M::MPLImpl.createPerlVariable>
6396     ('$', null, $param->{$var}->{value});
6397     } elsif ($param->{$var}->{type} eq 'code') {
6398 wakaba 1.22 $value = $self-><M::ManakaiDISResourceDefinition
6399     .plPreprocessPerlStatement>
6400     ($param->{$var}->{value},
6401     contains_statements => false);
6402 wakaba 1.15 } else {
6403     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
6404     ($param->{$var}->{value});
6405     }
6406     $pc-><M::MPLCodeFragment.replaceVariable>
6407     ($var => $value);
6408     }
6409 wakaba 1.16 $r-><M::PLBlockCon.appendCodeFragment> ($pc);
6410 wakaba 1.15 } elsif ($et eq <Q::ManakaiDOM:InputNormalize>) {
6411 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
6412 wakaba 1.15 unless ($methodResource) {
6413     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_METHOD_ERR::
6414     DIS:sourceNode => {$node},
6415     DIS:sourceCode => {$source_code},
6416     DIS:elementType => {$et},
6417     }__}__;
6418     }
6419     my $param = $methodResource
6420     -><M::ManakaiDISResourceDefinition
6421     .getChildResourceByNameAndType>
6422     ($source_code, <Q::DISLang:MethodParameter>);
6423     unless ($param) {
6424     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6425     DIS:sourceNode => {$node},
6426     DIS:sourceCode => {$source_code},
6427     DIS:elementType => {$et},
6428     DIS:localName => {$source_code},
6429     DIS:expectedType => {<Q::DISLang:MethodParameter>},
6430     }__}__;
6431     }
6432     my $norm = $param-><M::ManakaiDISResourceDefinition
6433     .plGetMethodInputNormalizer>;
6434     if ($norm) {
6435     my $norm_code = $norm-><AG::ManakaiDISResourceDefinition
6436     .plCodeFragment>->clone;
6437     $norm_code-><M::MPLCodeFragment.replaceVariable>
6438     ('$INPUT' => $param-><AG::ManakaiDISResourceDefinition
6439     .plVariableName>);
6440     $r-><M::PLBlockCon.appendCodeFragment> ($norm_code);
6441     }
6442     } elsif ($et eq <Q::disPerl:FOR>) {
6443 wakaba 1.17 if ($source_code =~ s/^(((?>(?!::).)*)::\s*)//) {
6444     $r-><M::PLBlockCon.skipLines> ($1);
6445 wakaba 1.31 V: for my $forq (split /\s*\|\s*/, $2) {
6446     my $notfor = ($forq =~ s/^!\s*// ? true : false);
6447 wakaba 1.15 my $for_uri = $self->{src}
6448     -><M::ManakaiDISElement.qnameToURI>
6449 wakaba 1.31 ($forq, node => $node);
6450     my $formatch = $self-><M::ManakaiDISResourceDefinition
6451     .isForURI> ($for_uri);
6452     if (($formatch and not $notfor) or
6453     (not $formatch and $notfor)) {
6454 wakaba 1.15 $r-><M::PLBlockCon.appendCodeFragment>
6455 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
6456     .plPreprocessPerlCode>
6457     ($source_code, node => $node,
6458     method_resource => $methodResource,
6459     source_file => $r-><AG::PLBlockCon.
6460     currentSourceFile>,
6461     source_line => $r-><AG::PLBlockCon.
6462     currentSourceLine>));
6463 wakaba 1.15 last V;
6464     }
6465     } # V
6466 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
6467 wakaba 1.15 } else {
6468     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_FOR_ERR::
6469     DIS:sourceNode => {$node},
6470     DIS:sourceCode => {$source_code},
6471     DIS:elementType => {$et},
6472     }__}__;
6473     }
6474     } elsif ($et eq <Q::disPerl:ASSERT>) {
6475 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
6476 wakaba 1.15 my $assert_type;
6477     if ($source_code =~ s/^\s*($RegQNameChar+)\s*::\s*//o) {
6478     $assert_type = $self->{src}
6479     -><M::ManakaiDISElement.qnameToURI>
6480     ($1, node => $node);
6481     } else {
6482     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ASSERT_TYPE_ERR::
6483     DIS:sourceNode => {$node},
6484     DIS:sourceCode => {$source_code},
6485     DIS:elementType => {$et},
6486     }__}__;
6487     }
6488     # if output assertion then
6489     =pod
6490     my $assert_block = $r-><M::PLBlockCon.appendBlock>;
6491    
6492     my $param = $self-><M::ManakaiDISResourceDefinition
6493     .plParsePreprocessParameter>
6494     ($source_code, node => $node);
6495     my $context_param
6496     = $self-><M::ManakaiDISResourceDefinition
6497     .plGetContextParameter>;
6498    
6499     if ($assert_type eq <Q::DISPerl:isPositive>) {
6500    
6501     $pre = perl_statement
6502     perl_assign
6503     'my $asActual' =>
6504     '('.perl_code ($param->{actual}, %opt).')';
6505     $cond = '$asActual > 0';
6506     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = 'a positive value';
6507     $xparam->{ExpandedURI q<DOMMain:actualValue>}
6508     = perl_code_literal q<$asActual>;
6509     } elsif ($atype eq ExpandedURI q<DISPerl:invariant>) {
6510     $cond = '0';
6511     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = $param->{msg};
6512     $xparam->{ExpandedURI q<DOMMain:actualValue>} = '(invariant)';
6513     } else {
6514     valid_err (q[Assertion type <].$atype.q[> is not supported],
6515     node => $opt{node});
6516     }
6517    
6518     $r = $pre . perl_if
6519     $cond,
6520     undef,
6521    
6522    
6523     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
6524     (<Q::DOMException:CoreException>);
6525     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
6526     (<Q::MDOMX:MDOM_DEBUG_BUG>);
6527     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
6528     (<Q::DOMMain:ASSERTION_ERR>);
6529 wakaba 1.16 $_-><AS::ManakaiDISResourceDefinition.isReferred>
6530 wakaba 1.15 ($node || $self->{src}) for $cls, $const, $subtype;
6531     $self-><M::ManakaiDISResourceDefinition
6532     .plAppendThrow>
6533     ($assert_block, $cls, $const, $subtype,
6534     {%$param, %$context_param,
6535     <Q::DOMMain:assertionType> => {
6536     type => 'quoted', value => $assert_type,
6537     },
6538     <Q::DOMMain:traceText> => {
6539     type => 'code',
6540     value => q<(sprintf 'at %s line %s%s%s',
6541     __FILE__, __LINE__, "\n\t",
6542     Carp::longmess ())>,
6543     }});
6544    
6545     =cut
6546    
6547     } elsif ({
6548     <Q::disPerl:FILE> => 1,
6549     <Q::disPerl:LINE> => 1,
6550     <Q::disPerl:PACKAGE> => 1,
6551     }->{$et}) {
6552     $r-><M::PLAnyCon.appendAtom>
6553     ('__'.{
6554     <Q::disPerl:FILE> => 'FILE',
6555     <Q::disPerl:LINE> => 'LINE',
6556     <Q::disPerl:PACKAGE> => 'PACKAGE',
6557     }->{$et}.'__');
6558     if (length $source_code) {
6559     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR::
6560     DIS:sourceNode => {$node},
6561     DIS:sourceCode => {$source_code},
6562     DIS:elementType => {$et},
6563     }__}__;
6564     }
6565     } else {
6566     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
6567     DIS:sourceNode => {$node},
6568     DIS:sourceCode => {$source_code},
6569     DIS:elementType => {$et},
6570     }__}__;
6571     }
6572     } else { ## Other than block-level element
6573     $r-><M::PLBlockCon.appendCodeFragment>
6574     ($self-><M::ManakaiDISResourceDefinition
6575 wakaba 1.16 .plPreprocessPerlStatement>
6576 wakaba 1.17 ($source_code, contains_statements => true,
6577     source_file => $r-><AG::PLBlockCon
6578     .currentSourceFile>,
6579     source_line => $r-><AG::PLBlockCon
6580     .currentSourceLine>));
6581     $r-><M::PLBlockCon.skipLines> ($source_code);
6582 wakaba 1.15 }
6583     } # for
6584     }__; # DEEP
6585    
6586    
6587     ## Checks \p character classes
6588     # while ($s =~ /\\p{([^{}]+)}/gs) {
6589     # my $name = $1;
6590     # $State->{ExpandedURI q<dis2pm:Package>}
6591     # ->{$State->{ExpandedURI q<dis2pm:currentPackage>}}
6592     # ->{ExpandedURI q<dis2pm:requiredCharClass>}
6593     # ->{$name} ||= $opt{node} || 1;
6594     # }
6595    
6596 wakaba 1.13
6597     @Method:
6598     @@Name: plPreprocessPerlStatement
6599     @@enDesc:
6600     Preprocesses a Perl inline code fragment
6601     (code fragment smaller than statement).
6602     @@Param:
6603     @@@Name:codeArg
6604     @@@Type:
6605     lang:Perl::ManakaiDOM:all
6606     @@@enDesc:
6607     A Perl code fragment.
6608     @@NodeParam:
6609 wakaba 1.16 @@NamedParam:
6610     @@@Name:containsStatements
6611     @@@Type:
6612     DOMMain:boolean::ManakaiDOM:all
6613     @@@enDesc:
6614     Whether one or more statements might be contained
6615     in <P::codeArg> or not.
6616 wakaba 1.17 @@NamedParam:
6617     @@@Name:sourceFile
6618     @@@Type:
6619     DISLang:String::ManakaiDOM:all
6620     @@@enDesc:
6621     The source file name of the <P::codeArg>.
6622     @@@nullCase:
6623     @@@@enDesc:
6624     No source file information available.
6625     @@NamedParam:
6626     @@@Name:sourceLine
6627     @@@Type:
6628     DOMMain:unsigned-long::ManakaiDOM:all
6629     @@@enDesc:
6630     The line number in the <P::sourceFile> from which
6631     the <P::codeArg> begins.
6632     @@@nullCase:
6633     @@@@enDesc:
6634     No source file information available.
6635 wakaba 1.13 @@Return:
6636 wakaba 1.16 @@@Type:MPLCodeFragment
6637 wakaba 1.13 @@@enDesc:
6638     Preprocessed Perl code.
6639 wakaba 1.16 @@@InCase:
6640     @@@@Type:
6641     PerlCode:ManakaiPerlBlock::ManakaiDOM:Perl
6642     @@@@enDesc:
6643 wakaba 1.19 If <P::containsStatements> is <DOM::false>.
6644 wakaba 1.16 @@@InCase:
6645     @@@@Type:
6646     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
6647     @@@@enDesc:
6648 wakaba 1.19 If <P::containsStatements> is <DOM::true>.
6649 wakaba 1.13 @@@InlineElementException:
6650     @@@PerlDef:
6651     unless ($self->{src}) {
6652     __EXCEPTION{NO_SOURCE_NODE_ERR::
6653     DIS:uri => {$self->{uri}},
6654     }__;
6655     }
6656     __DEEP{
6657     our $RegQNameChar;
6658 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor.plImplementation>;
6659 wakaba 1.16 if ($containsStatements) {
6660     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
6661 wakaba 1.17 if (defined $sourceLine) {
6662     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
6663     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
6664     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
6665     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
6666     } elsif ($node) {
6667     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
6668     (key => [qw/Name QName Type type/]);
6669     $r-><AS::PLBlockCon.sourceFile> ($np);
6670     $r-><AS::PLBlockCon.sourceLine> (1);
6671     $r-><AS::PLBlockCon.currentSourceFile> ($np);
6672     $r-><AS::PLBlockCon.currentSourceLine> (1);
6673     }
6674 wakaba 1.16 } else {
6675     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
6676     }
6677     for my $source_code (split /(?<![\^\?qwr])(\x3C$RegQNameChar[^<>]+>
6678     )/ox, $codeArg) {
6679 wakaba 1.13 if ($source_code =~ s/^\x3C//) {
6680     $source_code =~ s/>$//;
6681     if ($source_code =~ /=$/) {
6682     ## TODO: Warning
6683     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
6684     # q{should "=" be used place of "=>"?};
6685     }
6686     if ($source_code =~ s/^(.+?):://) {
6687     my $et = $self->{src}
6688     -><M::ManakaiDISElement.qnameToURI>
6689     ($1,
6690     node => $node,
6691     default_namespace_uri => <Q::disPerl:>);
6692     if ($et eq <Q::disPerl:Q>) { ## QName constant
6693     $r-><M::PLAnyCon.appendStringLiteral>
6694     ($self->{src}
6695     -><M::ManakaiDISElement.qnameToURI>
6696     ($source_code, node => $node));
6697     } elsif ({
6698     <Q::disPerl:M> => 1,
6699     <Q::disPerl:ClassM> => 1,
6700     <Q::disPerl:AG> => 1,
6701     <Q::disPerl:AS> => 1,
6702     }->{$et}) { ## Method call
6703     my ($class_qname, $method_qname)
6704     = split /\s*\.\s*/, $source_code, 2;
6705     my $class_uri
6706     = $self->{src}
6707     -><M::ManakaiDISElement.tfqnamesToURI>
6708     ($class_qname,
6709     $self-><AG::ManakaiDISResourceDefinition
6710 wakaba 1.33 .ownerClassNodeURI>,
6711 wakaba 1.13 $self->{for},
6712     node => $node);
6713     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6714     ($class_uri);
6715 wakaba 1.16 unless ($class-><AG::ManakaiDISResourceDefinition
6716     .isDefined>) {
6717     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6718     DIS:sourceNode => {$node},
6719     DIS:sourceCode => {$source_code},
6720     DIS:uri => {$class_uri},
6721     DIS:elementType => {$et},
6722     DIS:expectedType => {<Q::DISLang:AnyClass>},
6723     }__}__;
6724     }
6725 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6726 wakaba 1.13 ($node || $self->{src});
6727     if ($et eq <Q::disPerl::ClassM> and
6728     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
6729     (<Q::ManakaiDOM:IF>)) {
6730     __UNDEEP{
6731     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
6732     DIS:uri => {$class_uri},
6733     DIS:elementType => {$et},
6734     DIS:sourceNode => {$node || $self->{src}},
6735     DIS:sourceCode => {$source_code},
6736 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
6737 wakaba 1.13 }__;
6738     }__;
6739     }
6740     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
6741     (<Q::ManakaiDOM:IF>)) {
6742 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
6743     ($class => $r);
6744 wakaba 1.13 }
6745 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
6746 wakaba 1.13 .getChildResourceByNameAndType>
6747     ($method_qname,
6748     {
6749     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
6750     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
6751     }->{$et} || <Q::DISLang:Method>);
6752     if (not $method or
6753     not $method-><AG::ManakaiDISResourceDefinition
6754     .isDefined>) {
6755     __UNDEEP{
6756     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6757     DIS:localName => {$method_qname},
6758 wakaba 1.33 DIS:parentURI => {$class_uri},
6759 wakaba 1.13 DIS:elementType => {$et},
6760     DIS:sourceNode => {$node || $self->{src}},
6761     DIS:sourceCode => {$source_code},
6762 wakaba 1.14 DIS:expectedType => {{
6763     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
6764     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
6765     }->{$et} || <Q::DISLang:Method>},
6766 wakaba 1.13 }__;
6767     }__;
6768     }
6769     my $class_name = '';
6770     if ($et eq <Q::disPerl:ClassM>) {
6771     $class_name = $class-><AG::ManakaiDISResourceDefinition
6772     .plFullyQualifiedName> . '->';
6773     }
6774     my $method_name = $method-><AG::ManakaiDISResourceDefinition
6775     .plName>;
6776     $r-><M::PLAnyCon.appendBare>
6777     ($class_name . $method_name);
6778     } elsif ({
6779     <Q::disPerl:Class> => 1,
6780     <Q::disPerl:ClassName> => 1,
6781     <Q::disPerl:IF> => 1,
6782     <Q::disPerl:IFName> => 1,
6783     }->{$et}) { ## Perl package name
6784     my $class_uri
6785     = $self->{src}
6786     -><M::ManakaiDISElement.tfqnamesToURI>
6787     ($source_code,
6788     $self-><AG::ManakaiDISResourceDefinition
6789 wakaba 1.33 .ownerClassNodeURI>,
6790 wakaba 1.13 $self->{for},
6791     node => $node);
6792     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6793     ($class_uri);
6794 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6795 wakaba 1.13 ($node || $self->{src});
6796 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
6797 wakaba 1.13 .plFullyQualifiedName>;
6798 wakaba 1.14 unless ($pack) {
6799     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
6800     DIS:sourceNode => {$node || $self->{src}},
6801     DIS:sourceCode => {$source_code},
6802     DIS:uri => {$class_uri},
6803     DIS:elementType => {$et},
6804     }__}__;
6805     }
6806 wakaba 1.13 if ({
6807     <Q::disPerl:ClassName> => 1,
6808     <Q::disPerl:IFName> => 1,
6809     }->{$et}) {
6810     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
6811     } else {
6812     $r-><M::PLAnyCon.appendBare> ($pack);
6813     }
6814 wakaba 1.35 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
6815     ($class => $r)
6816     if {
6817     <Q::disPerl:Class> => true,
6818     <Q::disPerl:ClassName> => true,
6819     }->{$et};
6820 wakaba 1.13 } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
6821     my $code_name;
6822     $source_code =~ s/^\s+//;
6823     if ($source_code =~ s/^((?>(?!::).)+)//s) {
6824     $code_name = $1;
6825     } else {
6826     __UNDEEP{
6827     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
6828     DIS:sourceCode => {$source_code},
6829     DIS:sourceNode => {$node || $self->{src}},
6830     }__;
6831     }__;
6832     }
6833     $source_code =~ s/^::\s*//;
6834     my $param = $self-><M::ManakaiDISResourceDefinition
6835     .plParsePreprocessParameter>
6836     ($source_code, node => $node);
6837     my $code_uri = $self->{src}-><M::ManakaiDISElement
6838     .tfqnamesToURI>
6839     ($code_name, null, $self->{for},
6840     node => $node);
6841     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
6842     ($code_uri);
6843 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
6844 wakaba 1.13 ($node || $self->{src});
6845     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
6846     (<Q::dis2pm:InlineCode>)) {
6847     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6848     DIS:uri => {$code_uri},
6849     DIS:sourceNode => {$node || $self->{src}},
6850     DIS:sourceCode => {$source_code},
6851     DIS:expectedType => {<Q::dis2pm:InlineCode>},
6852     }__;}__;
6853     }
6854     my $pc = $code-><AG::ManakaiDISResourceDefinition
6855     .plCodeFragment>->clone;
6856     unless (defined $pc) {
6857     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
6858     DIS:sourceNode => {$node || $self->{src}},
6859     DIS:sourceCode => {$source_code},
6860     DIS:uri => {$code_uri},
6861     }__}__;
6862     }
6863     for my $var (grep {/^\$/} keys %$param) {
6864     my $value;
6865     if ($param->{$var}->{type} eq 'variable') {
6866     $value = $plimpl-><M::MPLImpl.createPerlVariable>
6867     ('$', null, $param->{$var}->{value});
6868     } elsif ($param->{$var}->{type} eq 'code') {
6869 wakaba 1.22 $value = $self-><M::ManakaiDISResourceDefinition
6870     .plPreprocessPerlStatement>
6871     ($param->{$var}->{value},
6872     contains_statements => false);
6873 wakaba 1.13 } else {
6874     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
6875     ($param->{$var}->{value});
6876     }
6877     $pc-><M::MPLCodeFragment.replaceVariable>
6878     ($var => $value);
6879     }
6880 wakaba 1.16 $r-><M::PLInCon.appendCodeFragment> ($pc);
6881 wakaba 1.13 } elsif ($et eq <Q::disPerl:C>) {
6882     my ($class_qname, $const_name) = split /\./, $source_code, 2;
6883     my $class_uri
6884     = $self->{src}
6885     -><M::ManakaiDISElement.tfqnamesToURI>
6886     ($class_qname,
6887     $self-><AG::ManakaiDISResourceDefinition
6888 wakaba 1.33 .ownerClassNodeURI>,
6889 wakaba 1.13 $self->{for},
6890     node => $node);
6891     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6892     ($class_uri);
6893 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6894 wakaba 1.13 ($node || $self->{src});
6895     my $const = $class-><M::ManakaiDISResourceDefinition
6896     .getConstResourceByName> ($const_name);
6897     unless (defined $const) {
6898     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6899     DIS:sourceNode => {$node || $self->{src}},
6900     DIS:sourceCode => {$source_code},
6901     DIS:localName => {$const_name},
6902 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
6903 wakaba 1.13 }__}__;
6904     }
6905 wakaba 1.30 $const-><AS::ManakaiDISResourceDefinition.isReferred> ($node);
6906    
6907     my $data_type = $const-><AG::ManakaiDISResourceDefinition
6908     .disActualDataTypeResource>;
6909     my $val = $const->{src}-><M::ManakaiDISElement
6910     .plValueCodeFragment>
6911     (<Q::dis:Value>, $const,
6912     for_arg => $const->{for},
6913     forp_arg => $const->{forp},
6914     data_type_uri => $data_type
6915     -><AG::ManakaiDISResourceDefinition.uri>);
6916     unless (defined $val) {
6917     __UNDEEP{__EXCEPTION{NO_CONST_VALUE_ERR::
6918     DIS:uri => {$const->{uri}},
6919     DIS:localName => {$const->{localName}},
6920     DIS:sourceNode => {$const->{src}},
6921     DIS:elementType => {$et},
6922     }__}__;
6923 wakaba 1.13 }
6924 wakaba 1.30 $r-><M::PLInCon.appendCodeFragment> ($val);
6925 wakaba 1.13 } else {
6926     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
6927     DIS:elementType => {$et},
6928     DIS:sourceNode => {$node || $self->{src}},
6929 wakaba 1.16 DIS:sourceCode => {$source_code},
6930 wakaba 1.13 }__}__;
6931     }
6932     } else {
6933     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
6934     DIS:sourceNode => {$node || $self->{src}},
6935     DIS:sourceCode => {$source_code},
6936 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
6937 wakaba 1.13 }__}__;
6938     }
6939     } else {
6940 wakaba 1.33 for my $source_code (split /(\b
6941     (?: t r u e \b|
6942     f a l s e \b|
6943     n u l l \b|
6944     t r y \s* \x7B ) |
6945     \ \\ p \x7B [^\x7B\x7D\\]+ \x7D)/x,
6946     $source_code) {
6947 wakaba 1.16 if ({
6948     'tr'.'ue' => true,
6949     'fal'.'se' => true,
6950     'nu'.'ll' => true,
6951     }->{$source_code}) {
6952     $r-><M::PLAnyCon.appendAtom> ({
6953     'tr'.'ue' => 1,
6954     'fal'.'se' => 0,
6955     'nu'.'ll' => 'undef',
6956     }->{$source_code});
6957 wakaba 1.18 } elsif ($source_code =~ /^t r y \s* \x7B$/x) {
6958     $r-><M::PLInCon.appendCode> ('tr'.
6959     'y '."\x7B".'local $Error::Depth = $Error::Depth + 3;');
6960 wakaba 1.20 $r-><M::MPLCodeFragment.addUsePerlModuleName>
6961     ('Message::Util::Error');
6962 wakaba 1.33 } elsif ($source_code =~ /^\\ p \x7B ([^\x7B\x7D\\]+) \x7D$/x) {
6963     my $cls = $1;
6964     $cls =~ s/^\s+//s;
6965     $cls =~ s/\s+$//s;
6966     ## TODO: Formal character class support required
6967     if ($cls =~ /^inxml\s*[:|]\s*(\w+)/) {
6968     $r-><M::PLAnyCon.appendAtom> ('\\'.'p{InXML'.$1.'}');
6969     $r-><M::MPLCodeFragment.addUseCharClassName>
6970     ('Char::Class::XML', 'InXML'.$1);
6971     } else {
6972     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6973     DIS:sourceNode => {$node},
6974     DIS:sourceCode => {$source_code},
6975     }__}__;
6976     }
6977 wakaba 1.16 } else {
6978 wakaba 1.29 if ($source_code =~ s/^(\s*[\w:]+\s*)//) {
6979     ## NOTE: "$cond ?\n1\n:0" would be a syntax error
6980     $r-><M::PLAnyCon.appendAtom> ($1);
6981     }
6982 wakaba 1.16 $r-><M::PLInCon.appendCode> ($source_code);
6983     }
6984     }
6985     } # Inline instruction or not
6986 wakaba 1.13 } # for
6987     }__; # DEEP
6988    
6989     @Attr:
6990 wakaba 1.33 @@Name: ownerClassNodeURI
6991 wakaba 1.13 @@enDesc:
6992 wakaba 1.33 The node URI reference of the class resource this resource
6993 wakaba 1.13 belongs to.
6994     @@Type: ResourceURI
6995     @@Get:
6996     @@@enDesc:
6997     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
6998     If this resource is a class, then the URI reference
6999     of this resource is returned.
7000     @@@nullCase:
7001     @@@@enDesc:
7002     This resource does not belong to any class.
7003     @@@PerlDef:
7004     if (exists $self->{<Q::DIS:ownerClass>}) {
7005     $r = $self->{<Q::DIS:ownerClass>};
7006     } else {
7007     my $res = $self;
7008     __DEEP{
7009 wakaba 1.33 RES: {
7010 wakaba 1.13 if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
7011     (<Q::ManakaiDOM:Class>)) {
7012 wakaba 1.33 $r = $res-><AG::ManakaiDISResourceDefinition.sourceNodeID>;
7013 wakaba 1.13 } else {
7014     $res = $res-><M::ManakaiDISPropertyAccessor
7015     .getPropertyResource> (<Q::dis2pm:parentResource>);
7016 wakaba 1.33 redo RES if $res;
7017 wakaba 1.13 }
7018     }
7019     }__;
7020     $self->{<Q::DIS:ownerClass>} = $r;
7021     }
7022    
7023     @IntMethod:
7024     @@Name: plParsePreprocessParameter
7025     @@enDesc:
7026     Parses a parameter specification in preprocessing instruction
7027     and return it as a hash reference.
7028     \
7029     {NOTE:: The callee have to ensure that this resource has its
7030     <CODE::src> before the call to this method.
7031     \
7032     }
7033     @@Param:
7034     @@@Name: paramSpec
7035     @@@Type:
7036     DISLang:String::ManakaiDOM:all
7037     @@@enDesc:
7038     A parameter specification to parse.
7039     @@NodeParam:
7040     @@Return:
7041     @@@Type:
7042     Perl:hash::ManakaiDOM:all
7043     @@@enDesc:
7044     Hash containing parameters. Each hash value is also
7045     a hash reference, containing two keys <CODE::type>
7046     (its value is either <CODE::bare>, <CODE::quoted>,
7047     <CODE::code> or <CODE::variable>) and
7048     <CODE::value>.
7049     @@@RaiseException:
7050     @@@@@:BROKEN_PARAM_SPEC_ERR
7051     @@@@enDesc:
7052     The <P::paramSpec> is not well-formed.
7053     @@@PerlDef:
7054     our $RegQNameChar;
7055     our $RegBlockContent;
7056     $r = {};
7057     while ($paramSpec =~ s/^
7058     ## Parameter name
7059     (\$? $RegQNameChar+)\s*
7060    
7061     (?: =>? \s*
7062     ## ">" is now optional for inline element (">" is delimiter)
7063    
7064     ## Parameter value
7065     (
7066 wakaba 1.15 ## Variable or Bare string
7067     \ \$? $RegQNameChar+
7068 wakaba 1.13 |
7069     ## Quoted string
7070     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
7071     |
7072     ## Code
7073 wakaba 1.15 \ \{$RegBlockContent\}
7074 wakaba 1.13
7075     )
7076    
7077     \s*)?
7078    
7079     (?:,\s*|$)//ox) {
7080    
7081     my ($n, $v) = ($1, $2);
7082     if (defined $v) {
7083     if ($v =~ /^'/) {
7084     $v = {type => 'quoted',
7085     value => substr ($v, 1, length ($v) - 2)};
7086     } elsif ($v =~ /^\{/) {
7087     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
7088     } elsif ($v =~ /^\$/) {
7089 wakaba 1.21 $v = {type => 'variable', value => substr $v, 1};
7090 wakaba 1.13 } else {
7091     $v = {type => 'bare', value => $v};
7092     }
7093     } else {
7094     $v = {type => 'boolean', value => true};
7095     }
7096    
7097     if ($n =~ /^\$/) {
7098     $r->{$n} = $v;
7099     } else {
7100     __DEEP{
7101     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
7102     ($n, node => $node || $self->{src})} = $v;
7103     }__;
7104     }
7105     } # while
7106    
7107     if (length $paramSpec) {
7108     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
7109     DIS:sourceCode => {$paramSpec},
7110     DIS:sourceNode => {$node || $self->{src}},
7111     }__;
7112     }
7113    
7114 wakaba 1.15 @IntMethod:
7115     @@Name: plGetContextParameter
7116     @@enDesc:
7117     Returns contextual parameters which describes the <QUOTE::location>
7118     of this resource.
7119     @@Return:
7120     @@@Type:
7121     Perl:hash::ManakaiDOM:all
7122     @@@enDesc:
7123     Hash of parameters as <M::.plParsePreprocessParameter> returns.
7124     @@@PerlDef:
7125     $r = {};
7126     __DEEP{
7127     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
7128     (<Q::DISLang:MethodReturn>)) {
7129     my $method = $self-><M::ManakaiDISPropertyAccessor
7130     .getPropertyResource> (<Q::dis2pm:parentResource>);
7131     $r->{<Q::MDOMX:method>}
7132     = {type => 'quoted',
7133     value => $method-><AG::ManakaiDISResourceDefinition.plName>};
7134     my $class = $method-><M::ManakaiDISPropertyAccessor
7135     .getPropertyResource> (<Q::dis2pm:parentResource>);
7136     $r->{<Q::MDOMX:class>}
7137     = {type => 'quoted',
7138     value => $class-><AG::ManakaiDISResourceDefinition
7139     .plFullyQualifiedName>};
7140     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
7141     (<Q::DISLang:AttributeGet>)) {
7142     my $attr = $self-><M::ManakaiDISPropertyAccessor
7143     .getPropertyResource> (<Q::dis2pm:parentResource>);
7144     $r->{<Q::MDOMX:attr>}
7145     = {type => 'quoted',
7146     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
7147     my $class = $attr-><M::ManakaiDISPropertyAccessor
7148     .getPropertyResource> (<Q::dis2pm:parentResource>);
7149     $r->{<Q::MDOMX:class>}
7150     = {type => 'quoted',
7151     value => $class-><AG::ManakaiDISResourceDefinition
7152     .plFullyQualifiedName>};
7153     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'get'};
7154     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
7155     (<Q::DISLang:AttributeSet>)) {
7156     my $attr = $self-><M::ManakaiDISPropertyAccessor
7157     .getPropertyResource> (<Q::dis2pm:parentResource>);
7158     $r->{<Q::MDOMX:attr>}
7159     = {type => 'quoted',
7160     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
7161     my $class = $attr-><M::ManakaiDISPropertyAccessor
7162     .getPropertyResource> (<Q::dis2pm:parentResource>);
7163     $r->{<Q::MDOMX:class>}
7164     = {type => 'quoted',
7165     value => $class-><AG::ManakaiDISResourceDefinition
7166     .plFullyQualifiedName>};
7167     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'set'};
7168     } else {
7169     $r->{<Q::MDOMX:resourceURI>} = {type => 'quoted',
7170     value => $self->{uri}};
7171     }
7172     }__;
7173    
7174     @Method:
7175     @@Name: plGetMethodInputNormalizer
7176     @@enDesc:
7177     Returns an input processor. This method assumes that
7178 wakaba 1.19 this resource is a method parameter (<Q::DISLang:MethodParameter>)
7179     or an attribute setter (<Q::DISLang:AttributeSet>).
7180 wakaba 1.15 @@Return:
7181     @@@Type:ManakaiDISResourceDefinition
7182     @@@enDesc:
7183     A <Q::DISLang:InputProcessor> corresponding to
7184     the parameter defined by this resource.
7185     \
7186     {NOTE:: <Q::ManakaiDOM:inputNormalize> property is
7187     obsolete in favor of <Q::DISLang:InputProcessor>;
7188     this method does not support the former.
7189     \
7190     }
7191     @@@nullCase:
7192     @@@@enDesc:
7193     No input processor found.
7194     @@@PerlDef:
7195     my $type;
7196 wakaba 1.30 my $type_node;
7197 wakaba 1.15 try {
7198     $type = $self-><AG::ManakaiDISResourceDefinition
7199     .disActualDataTypeResource>;
7200 wakaba 1.30 $type_node = $self-><AG::ManakaiDISResourceDefinition
7201     .disActualDataTypeNode>;
7202 wakaba 1.15 } catch <Class::ManakaiDISException> with {
7203     my $err = shift;
7204     unless ($err->{<Q::MDOMX:subtype>} eq <Q::DIS:NO_DIS_TYPE_ERR>) {
7205     $err->throw;
7206     }
7207     };
7208     if ($type) {
7209     __DEEP{
7210 wakaba 1.30 my $noinput = $type_node-><M::ManakaiDISElement.disGetAttribute>
7211     (<Q::ManakaiDOM:noInputNormalize>,
7212     for_arg => $self->{for},
7213     forp_arg => $self->{forp});
7214     ## NOTE: Is this correct?
7215     ## Should be "for" for the resource
7216     ## for which the "actualType" element
7217     ## is specified?
7218     unless ($noinput and $noinput-><M::SWCFGNode.value>) {
7219     $r = $type-><M::ManakaiDISResourceDefinition
7220     .getChildResourceByType>
7221 wakaba 1.15 (<Q::DISLang:InputProcessor>);
7222 wakaba 1.30 }
7223 wakaba 1.15 }__;
7224     }
7225    
7226     @IntMethod:
7227     @@Name: plAppendThrow
7228     @@enDesc:
7229     Appends a <Perl::report> method call statement for exception reporting.
7230     @@Param:
7231     @@@Name: parentNode
7232     @@@enDesc:
7233     The parent Perl code node to which a new statement is appended.
7234     @@@Type: PLBlockCon
7235     @@Param:
7236     @@@Name: xclass
7237     @@@Type: ManakaiDISResourceDefinition
7238     @@@enDesc:
7239     An exception class.
7240     @@Param:
7241     @@@Name: xcode
7242     @@@Type: ManakaiDISResourceDefinition
7243     @@@enDesc:
7244     An exception code constant.
7245     @@Param:
7246     @@@Name: xsubtype
7247     @@@Type: ManakaiDISResourceDefinition
7248     @@@enDesc:
7249     An exception subtype.
7250     @@@nullCase:
7251     @@@@enDesc:
7252     No subtype.
7253     @@Param:
7254     @@@Name: xparam
7255     @@@Type:
7256     Perl:hash::ManakaiDOM:all
7257     @@@enDesc:
7258     A hash containing parameters passed to the <Perl:report> method.
7259     A hash key is to be a parameter name. Hash values
7260     should also be hashes. A hash value hash has two values:
7261     <CODE::type> and <CODE::value>. A <CODE::value>
7262     value is a parameter value. If <CODE::type> is
7263     <CODE::code>, then <CODE::value> is assumed as a Perl code fragment.
7264     Otherwise, <CODE::value> is quoted to be interpreted as a string as is.
7265     @@Return:
7266 wakaba 1.16 @@@RaiseException:
7267     @@@@@: RESOURCE_NOT_DEFINED_ERR
7268     @@@@enDesc:
7269     Either <P::xclass>, <P::xcode> or <P::xsubtype>
7270     is not defined.
7271 wakaba 1.15 @@@PerlDef:
7272     my $statement = $parentNode-><M::PLBlockCon.appendStatement>
7273     ('report '.
7274     $xclass-><AG::ManakaiDISResourceDefinition.plFullyQualifiedName>.
7275     ' -object => $self');
7276 wakaba 1.16 my $xclass_module = $xclass-><AG::ManakaiDISResourceDefinition
7277 wakaba 1.22 .ownerModule>;
7278 wakaba 1.16 unless ($xclass-><AG::ManakaiDISResourceDefinition.isDefined> or
7279     not $xclass_module) {
7280     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
7281     DIS:sourceNode => {$self->{src}},
7282     DIS:uri => {$xclass->{uri}},
7283     DIS:localName => {$xclass->{localName}},
7284     DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
7285     }__;
7286     }
7287 wakaba 1.29 $xclass-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
7288 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
7289     ($xclass_module => $statement);
7290 wakaba 1.15 $xparam->{-type} = {type => 'quoted',
7291     value => $xcode-><AG::ManakaiDISResourceDefinition
7292     .plName>};
7293     $xparam->{<Q::MDOMX:subtype>} = {type => 'quoted',
7294     value => $xsubtype->{nameURI}}
7295     if $xsubtype;
7296     for my $name (keys %$xparam) {
7297     my $pname = $name;
7298     $pname =~ s/(['\\])/\\$1/g;
7299     $pname = qq<'$pname'>;
7300     $statement-><M::PLInCon.appendCode>
7301     (', ' . $pname . ' => ');
7302     if ($xparam->{$name}->{type} eq 'code') {
7303     if (ref $xparam->{$name}->{value}) {
7304     $statement-><M::PLInCon.appendCodeFragment>
7305     ($xparam->{$name}->{value});
7306     } else {
7307 wakaba 1.16 $statement-><M::PLInCon.appendCodeFragment>
7308 wakaba 1.15 ($self-><M::ManakaiDISResourceDefinition
7309     .plPreprocessPerlStatement>
7310     ($xparam->{$name}->{value}));
7311     }
7312     } else { ## String as is
7313     $statement-><M::PLAnyCon.appendStringLiteral>
7314     ($xparam->{$name}->{value});
7315     }
7316     }
7317    
7318 wakaba 1.18 @Attr:
7319     @@Name: plIsNullable
7320     @@enDesc:
7321     Whether this resource is <QUOTE::nullable> or not.
7322     <QUOTE::Nullability> is defined for method parameters,
7323     method returns, attribute getters and attribute setters.
7324     @@Type:
7325     DOMMain:boolean::ManakaiDOM:all
7326     @@Get:
7327     @@@RaiseException:
7328     @@@@@:NO_DIS_TYPE_ERR
7329     @@@@enDesc:
7330     There is a <Q::ManakaiDOM:InCase> child resource
7331     that does not have <Q::dis:Type> attribute.
7332     @@@PerlDef:
7333     __DEEP{
7334     for my $incase (@{$self-><M::ManakaiDISPropertyAccessor
7335     .getPropertyResourceList>
7336     (<Q::DIS:childResource>)}) {
7337     next unless $incase-><M::ManakaiDISResourceDefinition.isTypeURI>
7338     (<Q::ManakaiDOM:InCase>);
7339     if ($incase-><AG::ManakaiDISResourceDefinition.disIsNullValue> or
7340     $incase-><AG::ManakaiDISResourceDefinition
7341     .disActualDataTypeResource>
7342     -><M::ManakaiDISResourceDefinition
7343     .isSubsetOfURI> (<Q::DOMMain:boolean>)) {
7344     $r = true;
7345     last;
7346     }
7347     }
7348     }__;
7349    
7350     @Attr:
7351     @@Name: disIsNullValue
7352     @@enDesc:
7353     Whether this resource have <DOM::null> value or not.
7354     A resource have <DOM::null> value iff it has
7355     <Q::dis:Value> attribute node that in turn has
7356     <Q::dis:is-null> attribute whose value set to <DOM::true>.
7357     @@Type:
7358     DOMMain:boolean::ManakaiDOM:all
7359     @@Get:
7360     @@@PerlDef:
7361     if ($self->{src}) {
7362     __DEEP{
7363     my $val = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7364     (<Q::dis:Value>,
7365     for_arg => $self->{for},
7366     forp_arg => $self->{forp});
7367     if ($val) {
7368     my $isnull = $val-><M::ManakaiDISElement.disGetAttribute>
7369     (<Q::dis:is-null>,
7370     for_arg => $self->{for},
7371     forp_arg => $self->{forp});
7372     if ($isnull and $isnull-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
7373     .value>) {
7374     $r = true;
7375     }
7376     }
7377     }__;
7378     }
7379 wakaba 1.19
7380     @Attr:
7381     @@Name:plIsDefined
7382     @@enDesc:
7383     Whether a Perl implementation for this resource is available or not.
7384     @@Type:
7385     DOMMain:boolean::ManakaiDOM:all
7386     @@Get:
7387     @@@TrueCase:
7388     @@@@enDesc:
7389     This resource has its Perl definition and it is implemented.
7390     @@@FalseCase:
7391     @@@@enDesc:
7392     Either this resource does not have any Perl definition
7393     or it does have but it is not implemented yet.
7394     @@@PerlDef:
7395     if (exists $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>}) {
7396     $r = $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>};
7397     } else {
7398     __DEEP{
7399     my $typeuri = {
7400     <Q::ManakaiDOM:Class> => [
7401     <Q::DISLang:Method>, <Q::DISLang:Attribute>,
7402     ],
7403     <Q::DISLang:Method> => [
7404     <Q::DISLang:MethodReturn>,
7405     ],
7406     <Q::DISLang:Attribute> => [
7407     <Q::DISLang:AttributeGet>, <Q::DISLang::AttributeSet>,
7408     ],
7409     };
7410     OUTMOST:
7411     for my $mytype (keys %$typeuri) {
7412     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI> ($mytype)) {
7413     for my $ctype ($typeuri->{$mytype}) {
7414     for my $cres (@{$self-><M::ManakaiDISPropertyAccessor
7415     .getPropertyResourceList>
7416     (<Q::DIS:childResource>)}) {
7417     if ($cres-><M::ManakaiDISResourceDefinition.isTypeURI>
7418     ($ctype)) {
7419     unless ($cres-><AG::ManakaiDISResourceDefinition
7420     .plIsDefined>) {
7421     $r = false; last OUTMOST;
7422     }
7423     }
7424     }
7425     next OUTMOST;
7426     }
7427     }
7428     } # OUTMOST
7429     }__;
7430     $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>} = $r;
7431     }
7432 wakaba 1.20
7433     @IntMethod:
7434     @@Name: plAddRequireResource
7435     @@enDesc:
7436     Adds a resource to the list of resources that should
7437     be <Perl::require>d from a Perl code fragment.
7438     @@Param:
7439     @@@Name: resourceArg
7440     @@@Type: ManakaiDISResourceDefinition
7441     @@@enDesc:
7442     A resource that is <Perl::require>d by <P::codeArg>.
7443     @@Param:
7444     @@@Name: codeArg
7445     @@@Type: MPLCodeFragment
7446     @@@enDesc:
7447     A code fragment. <P::resourceArg> is added to the
7448     list of <Perl::require>d resources of this code fragment.
7449     @@Return:
7450     @@@PerlDef:
7451     __DEEP{
7452     $codeArg-><M::MPLCodeFragment.disAddRequireURI>
7453     ($resourceArg-><AG::ManakaiDISResourceDefinition.uri>);
7454     }__;
7455 wakaba 1.21
7456 wakaba 1.22 @Attr:
7457     @@ManakaiDOM:isForInternal:1
7458 wakaba 1.21 @@Name: plMufDescriptionText
7459     @@enDesc:
7460     {TODO:: Formal documentation-access API required.
7461     \
7462     }
7463 wakaba 1.22 @@Get:
7464 wakaba 1.21 @@@Type:
7465     DISLang:String::ManakaiDOM:all
7466     @@@PerlDef:
7467     __DEEP{
7468     my $muf = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7469     (<Q::dis:Def>, for_arg => $self->{for},
7470     forp_arg => $self->{forp},
7471     media_type => <Q::lang:muf>);
7472     if ($muf) {
7473     $r = $muf-><M::SWCFGNode.value>;
7474 wakaba 1.29 $r =~ s{< Q ::([^<>]+)>}{$self->{src}-><M::ManakaiDISElement.
7475     qnameToURI> ($1, node => $muf)}gex;
7476 wakaba 1.21 $r =~ s/\s+/ /g;
7477     $r =~ s/^ //;
7478     $r =~ s/ $//;
7479     } else {
7480     my $desc = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7481     (<Q::dis:Description>, for_arg => $self->{for},
7482     forp_arg => $self->{forp},
7483     media_type => <Q::lang:disdoc>,
7484     default_media_type => <Q::lang:disdoc>);
7485     if ($desc) {
7486     $r = $desc-><M::SWCFGNode.value>;
7487     $r =~ s/\s+/ /g;
7488     $r =~ s/^ //;
7489     $r =~ s/ $//;
7490     $r =~ s/%/%percent;/g;
7491     }
7492     }
7493     }__;
7494     @@@ImplNote:
7495     @@@@lang:en
7496     @@@@@: Currently only common-used patterns are supported.
7497 wakaba 1.24
7498     @Method:
7499     @@Name: isFeatureProvided
7500     @@enDesc:
7501     Whether a feature is provided by this resource or not.
7502     Note that the feature is actually available (implemented)
7503     or not is other thing (use <M::ManakaiDISPerlModuleDefinition
7504     .plIsFeatureImplemented> instead).
7505     @@Param:
7506     @@@Name: featureResourceURI
7507     @@@Type: ResourceURI
7508     @@@enDesc:
7509     The URI reference of the resource definition for the feature to test.
7510     @@Return:
7511     @@@Type:
7512     DOMMain:boolean::ManakaiDOM:all
7513     @@@enDesc:
7514     Whether the feature is provided or not.
7515     @@@PerlDef:
7516     __DEEP{
7517     my @f = @{$self-><M::ManakaiDISPropertyAccessor
7518     .getPropertyResourceList>
7519     (<Q::DOMMain:implementFeature>,
7520 wakaba 1.26 isa_recursive => true,
7521 wakaba 1.24 default_media_type => <Q::dis:TypeQName>)};
7522     if (@f) {
7523     for my $f (@f) {
7524     if ($f-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
7525     ($featureResourceURI)) {
7526     $r = true;
7527     last;
7528     }
7529     }
7530     } else {
7531     my $parent = $self-><M::ManakaiDISPropertyAccessor
7532     .getPropertyResource>
7533     (<Q::dis2pm:parentResource>);
7534     $r = $parent-><M::ManakaiDISResourceDefinition.isFeatureProvided>
7535     ($featureResourceURI)
7536     if $parent;
7537     }
7538     }__;
7539    
7540     @Attr:
7541     @@Name: featureNameList
7542     @@enDesc:
7543     The list of the names of the feature defined by this resource.
7544     @@Type:
7545     Perl:ARRAY::ManakaiDOM:all
7546     @@Get:
7547     @@@RaiseException:
7548     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
7549     @@@@enDesc:
7550     There is an <Q::dis:AppName> attribute whose media
7551     type is not supported.
7552     @@@RaiseException:
7553     @@@@@: NO_SOURCE_NODE_ERR
7554     @@@@enDesc:
7555     This resource definition does not have associated node
7556     in the source tree.
7557     @@@PerlDef:
7558     unless ($self->{src}) {
7559     __EXCEPTION{NO_SOURCE_NODE_ERR::
7560     DIS:uri => {$self->{uri}},
7561     }__;
7562     }
7563     __DEEP{
7564     for my $ce (@{$self->{src}-><M::ManakaiDISElement.disChildElements>
7565     (for_arg => $self->{for},
7566     forp_arg => $self->{forp})}) {
7567     if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest.expandedURI>
7568     eq <Q::dis:AppName>) {
7569     if ($ce-><M::ManakaiDISElement.mediaTypeMatch>
7570     (<Q::dis:TypeQName>,
7571     for_arg => $self->{for},
7572     forp_arg => $self->{forp},
7573     default_media_type => <Q::dis:String>)) {
7574     push @$r, lc $ce-><AG::ManakaiDISElement.qnameValueURI>;
7575     } elsif ($ce-><M::ManakaiDISElement.mediaTypeMatch>
7576     (<Q::dis:String>,
7577     for_arg => $self->{for},
7578     forp_arg => $self->{forp},
7579     default_media_type => <Q::dis:String>)) {
7580     push @$r, lc $ce-><M::SWCFGNode.value>;
7581     } else {
7582     my $mt = $ce-><M::ManakaiDISElement.mediaTypeURI>
7583     (for_arg => $self->{for},
7584     forp_arg => $self->{forp});
7585     __UNDEEP{
7586     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
7587     DIS:uri => {$mt},
7588     DIS:sourceNode => {$ce},
7589     }__;
7590     }__;
7591     }
7592     }
7593     }
7594     unless (@$r) {
7595 wakaba 1.28 my $pr = $self-><M::ManakaiDISPropertyAccessor
7596     .getPropertyResource> (<Q::dis2pm:parentResource>);
7597     if ($pr) {
7598     if ($pr-><M::ManakaiDISResourceDefinition.isTypeURI>
7599     (<Q::DOMMain:DOMFeature>) and
7600     not $pr-><AG::ManakaiDISResourceDefinition.isAnonymous>) {
7601     push @$r, @{$pr-><AG::ManakaiDISResourceDefinition
7602     .featureNameList>};
7603     }
7604     }
7605     }
7606     unless (@$r) {
7607 wakaba 1.24 if ($self-><AG::ManakaiDISResourceDefinition.isAnonymous>) {
7608     my $ln = $self-><AG::ManakaiDISResourceDefinition.localName>;
7609 wakaba 1.28 push @$r, lc $ln if defined $ln;
7610 wakaba 1.24 } else {
7611 wakaba 1.28 push @$r, lc $self-><AG::ManakaiDISResourceDefinition.nameURI>;
7612 wakaba 1.24 }
7613     }
7614     }__;
7615 wakaba 1.32
7616     @Attr:
7617     @@Name: mvLocalName
7618     @@enDesc:
7619     The local name of the markup vocabulary element defined by this
7620     resource.
7621     @@Type:
7622     DISLang:String::ManakaiDOM:all
7623     @@Get:
7624     @@@nullCase:
7625     @@@@enDesc:
7626     Either this resource does not define a markup vocabulary element
7627     or it does define an element but it does not have a local name.
7628     @@@PerlDef:
7629     __DEEP{
7630     if (exists $self->{<Q::mvLocalName>}) {
7631     $r = $self->{<Q::mvLocalName>};
7632     } elsif ($self->{src}) {
7633     my $node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7634     (<Q::dis:AppName>,
7635     for_arg => $self->{for},
7636     forp_arg => $self->{forp},
7637     media_type => <Q::dis:TypeQName>,
7638     default_media_type => <Q::dis:TypeQName>);
7639     if ($node) {
7640     $r = $self->{<Q::mvLocalName>}
7641     = $node-><AG::ManakaiDISElement.qnameValueLocalName>;
7642     } else {
7643     $r = $self->{<Q::mvLocalName>} = null;
7644     }
7645     } else {
7646     $r = $self->{<Q::mvLocalName>} = null;
7647     }
7648     }__;
7649    
7650     @Attr:
7651     @@Name: mvNamespaceURI
7652     @@enDesc:
7653     The namespace URI of the markup vocabulary element defined by this
7654     resource.
7655     @@Type: AnyURI
7656     @@Get:
7657     @@@nullCase:
7658     @@@@enDesc:
7659     Either this resource does not define a markup vocabulary element
7660     or it does define an element but it does not have a namespace URI.
7661     @@@PerlDef:
7662     __DEEP{
7663     if (exists $self->{<Q::mvNamespaceURI>}) {
7664     $r = $self->{<Q::mvNamespaceURI>};
7665     } elsif ($self->{src}) {
7666     my $node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7667     (<Q::dis:AppName>,
7668     for_arg => $self->{for},
7669     forp_arg => $self->{forp},
7670     media_type => <Q::dis:TypeQName>,
7671     default_media_type => <Q::dis:TypeQName>);
7672     if ($node) {
7673     $r = $self->{<Q::mvNamespaceURI>}
7674     = $node-><AG::ManakaiDISElement.qnameValueNamespaceURI>;
7675     } else {
7676     $r = $self->{<Q::mvNamespaceURI>} = null;
7677     }
7678     } else {
7679     $r = $self->{<Q::mvNamespaceURI>} = null;
7680     }
7681     }__;
7682    
7683     @Attr:
7684     @@Name: mvOwnerElementResource
7685     @@enDesc:
7686     An <QUOTE::owner element> resource of the markup vocabulary
7687     element defined by this resource.
7688     @@Type: ManakaiDISResourceDefinition
7689     @@Get:
7690     @@@nullCase:
7691     @@@@enDesc:
7692     Either this resource does not define a markup vocabulary element
7693     or it does define an element but it does not have an owner.
7694     @@@PerlDef:
7695     __DEEP{
7696     if (exists $self->{<Q::DIS:mvOwnerElementURI>}) {
7697     $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
7698     ($self->{<Q::DIS:mvOwnerElementURI>})
7699     if defined $self->{<Q::DIS:mvOwnerElementURI>};
7700     } elsif (defined $self->{<Q::dis2pm:parentResource>}) {
7701     $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
7702     ($self->{<Q::dis2pm:parentResource>});
7703     undef $r unless $r-><M::ManakaiDISResourceDefinition
7704     .isTypeURI> (<Q::s:AnyOwnerElement>);
7705     $self->{<Q::DIS:mvOwnerElementURI>} = $r->{uri} if $r;
7706     }
7707     }__;
7708 wakaba 1.2 ##DISResourceDefinition
7709 wakaba 1.27
7710     PropDef:
7711 wakaba 1.32 @QName: mvLocalName
7712     @enDesc:
7713     <A::ManakaiDISResourceDefinition.mvLocalName>.
7714    
7715     PropDef:
7716     @QName: mvNamespaceURI
7717     @enDesc:
7718     <A::ManakaiDISResourceDefinition.mvNamespaceURI>.
7719    
7720     PropDef:
7721     @QName: mvOwnerElementURI
7722     @enDesc:
7723     <A::ManakaiDISResourceDefinition.mvOwnerElementResource>
7724     (<QUOTE::dis> resource URI reference).
7725    
7726     PropDef:
7727 wakaba 1.27 @QName: plFullyQualifiedName
7728     @enDesc:
7729     Fully qualified name.
7730 wakaba 1.2
7731 wakaba 1.19 PropDef:
7732     @QName:plDefined
7733     @enDesc:
7734     Whether a Perl definition for this resource is implemented or not.
7735    
7736 wakaba 1.13 ElementTypeBinding:
7737 wakaba 1.15 @Name: BlockElementException
7738     @ElementType:
7739     ManakaiDOM:raises
7740     @ShadowContent:
7741     @@@: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
7742     @@Description:
7743     @@@lang:en
7744     @@@@:
7745     An exception type specification is required but not specified.
7746     @ShadowSibling:
7747     @@ManakaiDOM:raises:
7748     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
7749     @@@Description:
7750     @@@@lang:en
7751     @@@@@:
7752     A code qualified name is required but not specified.
7753     @@ManakaiDOM:raises:
7754     @@@@: RESOURCE_NOT_DEFINED_ERR
7755     @@@Description:
7756     @@@@lang:en
7757     @@@@@:
7758     A referred resource is not defined or has different type.
7759     @@ManakaiDOM:raises:
7760     @@@@: PERL_CODE_NOT_DEFINED_ERR
7761     @@@Description:
7762     @@@@lang:en
7763     @@@@@:
7764     A referred resource does not have its Perl definition.
7765     @@ManakaiDOM:raises:
7766     @@@@: PERL_PREPROCESS_NO_METHOD_ERR
7767     @@@Description:
7768     @@@@lang:en
7769     @@@@@:
7770     A preprocessing instruction which is allowed only in
7771     methods is embeded in a context which is not in any method.
7772     @@ManakaiDOM:raises:
7773     @@@@: PERL_PREPROCESS_NO_FOR_ERR
7774     @@@Description:
7775     @@@@lang:en
7776     @@@@@:
7777     A <QUOTE::for> qualified name is required but not specified.
7778     @@ManakaiDOM:raises:
7779     @@@@: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
7780     @@@Description:
7781     @@@@lang:en
7782     @@@@@:
7783     An assertion type qualified name is required but not specified.
7784     @@ManakaiDOM:raises:
7785     @@@@: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
7786     @@@Description:
7787     @@@@lang:en
7788     @@@@@:
7789     A preprocessing instruction block is specified
7790     but not allowed for this element type.
7791    
7792     ElementTypeBinding:
7793 wakaba 1.13 @Name: InlineElementException
7794     @ElementType:
7795     ManakaiDOM:raises
7796     @ShadowContent:
7797     @@@: NO_SOURCE_NODE_ERR
7798     @@Description:
7799     @@@lang:en
7800     @@@@:
7801     This resource definition does not have associated node
7802     in the source tree.
7803     @ShadowSibling:
7804     @@ManakaiDOM:raises:
7805     @@@@: INTERFACE_CLASS_METHOD_ERR
7806     @@@Description:
7807     @@@@lang:en
7808     @@@@@:
7809     An attempt is made to call a class (static) method
7810     via an interface, not class.
7811     @@ManakaiDOM:raises:
7812     @@@@: RESOURCE_NOT_DEFINED_ERR
7813     @@@Description:
7814     @@@@lang:en
7815     @@@@@:
7816     A package, method or attribute is not defined or not
7817     a resoure of that type.
7818     @@ManakaiDOM:raises:
7819     @@@@: NO_LOCAL_NAME_ERR
7820     @@@Description:
7821     @@@@lang:en
7822     @@@@@:
7823     A referred resource does not have its local name so
7824     that it is impossible to refer it by name.
7825     @@ManakaiDOM:raises:
7826     @@@@: RESERVED_PERL_METHOD_NAME_ERR
7827     @@@Description:
7828     @@@@lang:en
7829     @@@@@:
7830     A referred method has its name reserved for special-purpose.
7831     @@ManakaiDOM:raises:
7832     @@@@: BROKEN_PARAM_SPEC_ERR
7833     @@@Description:
7834     @@@@lang:en
7835     @@@@@:
7836     A parameter specification is not well-formed.
7837     @@ManakaiDOM:raises:
7838     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
7839 wakaba 1.14 @@@Description:
7840     @@@@lang:en
7841     @@@@@:
7842     A preprocessing instruction does not contain
7843     Perl code fragment name.
7844 wakaba 1.13 @@ManakaiDOM:raises:
7845     @@@@: PERL_CODE_NOT_DEFINED_ERR
7846 wakaba 1.14 @@@Description:
7847     @@@@lang:en
7848     @@@@@:
7849     The referred resource does not have its Perl definition.
7850 wakaba 1.13 @@ManakaiDOM:raises:
7851     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
7852 wakaba 1.14 @@@Description:
7853     @@@@lang:en
7854     @@@@@:
7855     A preprocessing instruction does not contain its element type name.
7856 wakaba 1.13 @@ManakaiDOM:raises:
7857     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
7858 wakaba 1.14 @@@Description:
7859     @@@@lang:en
7860     @@@@@:
7861     An unknown element type is encounted.
7862     @@ManakaiDOM:raises:
7863     @@@@: NO_PERL_PACKAGE_NAME_ERR
7864     @@@Description:
7865     @@@@lang:en
7866     @@@@@:
7867     No Perl package name is defined for a class or interface.
7868 wakaba 1.13
7869     PropDef:
7870     @QName: ownerClass
7871     @enDesc:
7872     The class to which this resource belongs.
7873     @Type: ResourceURI
7874     @rdfs:range:
7875     rdf:Resource
7876     @rdfs:domain:
7877     ManakaiDOM:Class
7878    
7879 wakaba 1.12 ResourceDef:
7880     @QName: DOMMinImpl
7881     @rdf:type:
7882     ManakaiDOM:IF
7883     @AliasFor:
7884     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
7885    
7886     ResourceDef:
7887 wakaba 1.20 @QName: PLPack
7888     @rdf:type:
7889     ManakaiDOM:Class
7890     @AliasFor:
7891     PerlCode:ManakaiPerlPackageScope::ManakaiDOM:Perl
7892    
7893     ResourceDef:
7894 wakaba 1.12 @QName: SWCFGNode
7895     @rdf:type:
7896     ManakaiDOM:IF
7897     @AliasFor:
7898     swcfg21:SWCFGNode::swcfg21:ForLatest
7899    
7900     ResourceDef:
7901     @QName: SWCFGDoc
7902     @rdf:type:
7903     ManakaiDOM:IF
7904     @AliasFor:
7905     swcfg21:SWCFGDocument::swcfg21:ForLatest
7906    
7907     ResourceDef:
7908     @QName: MPLImpl
7909     @rdf:type:
7910     ManakaiDOM:Class
7911     @AliasFor:
7912     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
7913    
7914     ResourceDef:
7915     @QName: MPLCodeFragment
7916     @rdf:type:
7917     ManakaiDOM:Class
7918     @AliasFor:
7919     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
7920    
7921     ResourceDef:
7922 wakaba 1.13 @QName: PLInCon
7923     @rdf:type:
7924     ManakaiDOM:Class
7925     @AliasFor:
7926     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
7927    
7928     ResourceDef:
7929 wakaba 1.15 @QName: PLBlockCon
7930     @rdf:type:
7931     ManakaiDOM:Class
7932     @AliasFor:
7933     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
7934    
7935     ResourceDef:
7936 wakaba 1.13 @QName: PLAnyCon
7937     @rdf:type:
7938     ManakaiDOM:Class
7939     @AliasFor:
7940     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
7941    
7942     ResourceDef:
7943     @QName: MPLSS
7944     @rdf:type:
7945     ManakaiDOM:Class
7946     @AliasFor:
7947     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
7948    
7949     ResourceDef:
7950 wakaba 1.12 @QName: MPLSub
7951     @rdf:type:
7952     ManakaiDOM:Class
7953     @AliasFor:
7954     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
7955    
7956     ResourceDef:
7957     @QName: MPLUnparsedCode
7958     @rdf:type:
7959     ManakaiDOM:Class
7960     @AliasFor:
7961     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
7962    
7963     PropDef:
7964     @QName: plCodeFragment
7965     @enDesc:
7966     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
7967    
7968     XParamDef:
7969     @QName: errResource
7970     @enDesc:
7971     A resource on which an error has occurred.
7972    
7973 wakaba 1.8 XParamDef:
7974     @QName: generatedName
7975     @enDesc:
7976     A generated name.
7977    
7978 wakaba 1.2 ClsDef:
7979     @ClsQName: ManakaiDISPropertyAccessor
7980 wakaba 1.3 @enDesc:
7981 wakaba 1.2 Accessor methods for resource or module properties.
7982    
7983 wakaba 1.22 @Attr:
7984     @@Name:plImplementation
7985     @@enDesc:
7986     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
7987     @@Type: MPLImpl
7988     @@Get:
7989     @@@enDesc:
7990     The Perl code implementation object.
7991     @@@nullCase:
7992     This resource has no source tree associated.
7993     @@@RaiseException:
7994     @@@@@:NO_PERL_CODE_IMPL_ERR
7995     @@@@enDesc:
7996     There is no implementation that implements
7997     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
7998     @@@PerlDef:
7999     if ($self->{src}) {
8000     __DEEP{
8001     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
8002     $self->{src})-><AG::SWCFGDoc.implementation>
8003     -><M::DOMMinImpl.getFeature>
8004     (<Q::Util:PerlCode> => '1.0');
8005     }__;
8006     unless (defined $r) {
8007     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
8008    
8009     }__;
8010     }
8011     }
8012    
8013     @Attr:
8014     @@Name: ownerModule
8015     @@enDesc:
8016     The <QUOTE::dis> module in which this object is defined.
8017     For a <QUOTE::dis> module object, the module itself is the
8018     <QUOTE::owner>.
8019     @@Get:
8020     @@@Type: ManakaiDISModuleDefinition
8021     @@@PerlDef: $r = $self;
8022    
8023     @Attr:
8024     @@Name: sourceElement
8025     @@enDesc:
8026     The source <QUOTE::dis> element node from which this
8027     definition is read.
8028     @@Get:
8029     @@@Type: ManakaiDISElement
8030     @@@InCase:
8031     @@@@Type: ManakaiDISModuleElement
8032     @@@@enDesc: If this resource is a module.
8033     @@@PerlDef: $r = $self->{src};
8034     @@@nullCase:
8035     @@@@enDesc:
8036     The definition is not yet read.
8037    
8038 wakaba 1.2 @Method:
8039 wakaba 1.8 @@Name: getPropertyBoolean
8040     @@enDesc:
8041     Gets boolean property value.
8042     @@PropNameParam:
8043     @@Param:
8044     @@@Name:default
8045     @@@Type:
8046     DOMMain:boolean::ManakaiDOM:all
8047     @@@enDesc:
8048     The default value that is returned if no explicit property
8049     value specification found for this resource.
8050     @@Return:
8051     @@@Type:
8052     DOMMain:boolean::ManakaiDOM:all
8053     @@@enDesc:
8054     The property value.
8055     @@@PerlDef:
8056     if (exists $self->{$propName}) {
8057     $r = defined $self->{$propName} ? $self->{$propName} : $default;
8058     } elsif ($self->{src}) {
8059 wakaba 1.18 my $attr_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
8060 wakaba 1.8 ($propName, for_arg => $self->{for},
8061     forp_arg => $self->{forp});
8062 wakaba 1.18 $r = $self->{$propName} = ($attr_node
8063     ? ($attr_node-><M::SWCFGNode.value>
8064     ? true : false)
8065     : null);
8066 wakaba 1.8 $r = $default unless defined $r;
8067     } else {
8068     $r = $default;
8069     }
8070    
8071     @Method:
8072 wakaba 1.2 @@Name: getPropertyText
8073     @@enDesc:
8074     Gets property value text.
8075     @@PropNameParam:
8076     @@Param:
8077     @@@Name:default
8078     @@@Type:
8079 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
8080 wakaba 1.2 @@@enDesc:
8081     The default value that is returned if no explicit property
8082     value specification found for this resource.
8083     @@@nullCase:
8084     @@@@enDesc:
8085     No default value supplied; <DOM::null> is returned if
8086     no value specified.
8087     @@Return:
8088     @@@Type:
8089 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
8090 wakaba 1.2 @@@enDesc:
8091     The property value string.
8092     @@@nullCase:
8093     @@@@enDesc:
8094     No value nor default value has specified.
8095     @@@PerlDef:
8096     if (exists $self->{$propName}) {
8097     $r = defined $self->{$propName} ? $self->{$propName} : $default;
8098     } elsif ($self->{src}) {
8099     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
8100     ($propName, for_arg => $self->{for},
8101     forp_arg => $self->{forp});
8102 wakaba 1.8 if ($r) {
8103     $r = $self->{$propName}
8104 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
8105 wakaba 1.8 $r = $default unless defined $r;
8106     } else {
8107     $r = $default;
8108     $self->{$propName} = null;
8109     }
8110 wakaba 1.2 } else {
8111     $r = $default;
8112     }
8113    
8114     @Method:
8115     @@Name: getPropertyResource
8116     @@enDesc:
8117     Gets property value resource.
8118     @@PropNameParam:
8119 wakaba 1.10 @@NamedParam:
8120     @@@Name: defaultMediaType
8121     @@@Type: ResourceURI
8122     @@@enDesc:
8123     The URI reference of the default media type which is used
8124     when the property value is retrieved from the source tree
8125     and the source tree element does not have its <Q::dis:ContentType>
8126     attribute specified.
8127     @@@nullCase:
8128     @@@@enDesc:
8129     Defaulted to <Q::dis:TypeQName>.
8130 wakaba 1.2 @@Return:
8131     @@@Type: ManakaiDISResourceDefinition
8132     @@@enDesc:
8133     The property value resource.
8134     @@@nullCase:
8135     @@@@enDesc:
8136     No value has specified.
8137 wakaba 1.8 @@@UndeclaredPrefixException:
8138 wakaba 1.12 @@@RaiseException:
8139     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
8140     @@@@enDesc:
8141     The media type of the attribute node in the source tree
8142     corresponding to this resource is not supported.
8143 wakaba 1.2 @@@PerlDef:
8144     if (defined $self->{$propName}) {
8145 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
8146     ($self->{$propName});
8147 wakaba 1.8 } elsif ($self->{src}) {
8148     __DEEP{
8149     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
8150     ($propName, for_arg => $self->{for},
8151     forp_arg => $self->{forp});
8152     if ($r) {
8153 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
8154     unless defined $defaultMediaType;
8155     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
8156 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
8157     for_arg => $self->{for},
8158     forp_arg => $self->{forp})) {
8159 wakaba 1.10 $self->{$propName}
8160     = $r-><AG::ManakaiDISElement.qnameValueURI>;
8161     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
8162 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
8163     for_arg => $self->{for},
8164     forp_arg => $self->{forp})) {
8165 wakaba 1.10 $self->{$propName}
8166     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
8167 wakaba 1.32 ($self->{<Q::DIS:sourceNodeID>},
8168 wakaba 1.33 $self->{for},
8169     for_arg => $self->{for},
8170     forp_arg => $self->{forp});
8171 wakaba 1.10 } else {
8172     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
8173     (for_arg => $self->{for},
8174     forp_arg => $self->{forp});
8175     __UNDEEP{
8176     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
8177     DIS:uri => {$mt},
8178     DIS:sourceNode => {$r},
8179     }__;
8180     }__;
8181     }
8182 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
8183     ($self->{$propName});
8184 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
8185 wakaba 1.8 }
8186     }__;
8187 wakaba 1.2 }
8188    
8189     @Method:
8190 wakaba 1.10 @@Name: getPropertyResourceList
8191     @@enDesc:
8192     Gets property value resource list.
8193     @@PropNameParam:
8194     @@NamedParam:
8195 wakaba 1.24 @@@Name: recursive
8196     @@@Type:
8197     DOMMain:boolean::ManakaiDOM:all
8198     @@@enDesc:
8199     Whether property resource values of this resource
8200     should also be included to the returned list or not.
8201     @@NamedParam:
8202 wakaba 1.10 @@@Name: recursiveISA
8203     @@@Type:
8204 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8205 wakaba 1.10 @@@enDesc:
8206 wakaba 1.26 Whether the <Q::dis:ISA> ancestors of the resources
8207     that are property values should also be included in the returned list
8208     or not.
8209     @@@TrueCase:
8210     @@@@enDesc:
8211     If a property value is a resource <VAR::R> and
8212     the resource <VAR::R> <Q::dis:ISA>'s (or inherits) <VAR::S>, then
8213     the resource <VAR::S> is also a value in the list.
8214     @@@FalseCase:
8215     @@@@enDesc:
8216     Only the resources directly specified as property values is returned.
8217     @@NamedParam:
8218     @@@Name: isaRecursive
8219     @@@Type:
8220     DOMMain:boolean::ManakaiDOM:all
8221     @@@enDesc:
8222     Whether property resource values of <Q::dis:ISA> resources
8223     of this resource should also be included to the returned list or not.
8224     @@@TrueCase:
8225     @@@@enDesc:
8226     If this resource <Q::dis:ISA>'s (or inherits) another resource
8227     <VAR::S> and the <VAR::S> resource has a <P::propName>
8228     property value of <VAR::R>, then the resource <VAR::R>
8229     is also a value in the list.
8230     @@@FalseCase:
8231     @@@@enDesc:
8232     Only the resource directly specified is the returned.
8233 wakaba 1.10 @@NamedParam:
8234     @@@Name: defaultMediaType
8235     @@@Type: ResourceURI
8236     @@@enDesc:
8237     The URI reference of the default media type which is used
8238     when the property value is retrieved from the source tree
8239     and the source tree element does not have its <Q::dis:ContentType>
8240     attribute specified.
8241     @@@nullCase:
8242     @@@@enDesc:
8243     Defaulted to <Q::dis:TypeQName>.
8244     @@Return:
8245     @@@Type: ResourceList
8246     @@@enDesc:
8247     An array reference of the property value resources.
8248     \
8249     {NOTE:: This list is <QUOTE::dead>.
8250     \
8251     }
8252     @@@UndeclaredPrefixException:
8253 wakaba 1.12 @@@RaiseException:
8254     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
8255     @@@@enDesc:
8256     The media type of the attribute node in the source tree
8257     corresponding to this resource is not supported.
8258 wakaba 1.10 @@@PerlDef:
8259     $r = [];
8260     if (defined $self->{$propName}) {
8261 wakaba 1.26 for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
8262 wakaba 1.10 ? $self->{$propName} : []}) {
8263     push @$r,
8264 wakaba 1.26 $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
8265 wakaba 1.10 }
8266     } elsif ($self->{src}) {
8267     __DEEP{
8268     $self->{$propName} = [];
8269     $defaultMediaType = <Q::dis:TypeQName>
8270     unless defined $defaultMediaType;
8271     for my $res_name_node
8272     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
8273     ($propName, for_arg => $self->{for},
8274     forp_arg => $self->{forp})}) {
8275     my $res_uri;
8276     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
8277 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
8278     for_arg => $self->{for},
8279     forp_arg => $self->{forp})) {
8280 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
8281     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
8282 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
8283     for_arg => $self->{for},
8284     forp_arg => $self->{forp})) {
8285 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
8286 wakaba 1.32 ($self->{<Q::DIS:sourceNodeID>},
8287 wakaba 1.33 $self->{for},
8288     for_arg => $self->{for},
8289     forp_arg => $self->{forp});
8290     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
8291     (<Q::DISCore:TFPQNames>, $defaultMediaType,
8292     for_arg => $self->{for},
8293     forp_arg => $self->{forp})) {
8294     $res_uri=$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
8295     ($self->{<Q::DIS:sourceNodeID>},
8296     $self->{for},
8297     for_arg => $self->{for},
8298     forp_arg => $self->{forp});
8299 wakaba 1.10 } else {
8300     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
8301     (for_arg => $self->{for},
8302     forp_arg => $self->{forp});
8303     __UNDEEP{
8304     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
8305     DIS:uri => {$mt},
8306     DIS:sourceNode => {$res_name_node},
8307     }__;
8308     }__;
8309     }
8310 wakaba 1.26 push @{$self->{$propName}}, $res_uri;
8311 wakaba 1.10 my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
8312     ($res_uri);
8313     push @$r, $res;
8314 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
8315 wakaba 1.10 ($res_name_node);
8316 wakaba 1.32 if ($isaRecursive) {
8317     my $stop_rec = $res_name_node-><M::ManakaiDISElement
8318     .disGetAttribute>
8319     (<Q::DISCore:stopISARecursive>,
8320     for_arg => $self->{for},
8321     forp_arg => $self->{forp});
8322     $isaRecursive = false
8323     if $stop_rec and $stop_rec-><M::SWCFGNode.value>;
8324     }
8325 wakaba 1.10 }
8326     }__;
8327     }
8328 wakaba 1.24 if ($recursive) {
8329     __DEEP{
8330     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
8331     my @p_res = @$r;
8332     for my $p_res (@p_res) {
8333     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
8334     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
8335     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
8336     .getPropertyResourceList>
8337     ($propName, recursive => true,
8338     recursive_isa => $recursiveISA,
8339     ___recursive_isa_done => $opt{___recursive_isa_done},
8340     default_media_type => $defaultMediaType)};
8341     }
8342     }__;
8343     }
8344 wakaba 1.10 if ($recursiveISA) {
8345     __DEEP{
8346     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
8347     my @p_res = @$r;
8348     for my $p_res (@p_res) {
8349     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
8350     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
8351     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
8352     .getPropertyResourceList>
8353 wakaba 1.33 (<Q::dis:ISA>,
8354     recursive => true,
8355 wakaba 1.10 ___recursive_isa_done => $opt{___recursive_isa_done},
8356     default_media_type => $defaultMediaType)};
8357     }
8358     }__;
8359     }
8360 wakaba 1.26 if ($isaRecursive) {
8361 wakaba 1.25 __DEEP{
8362     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
8363 wakaba 1.26 my @p_res = @{$self-><M::ManakaiDISPropertyAccessor
8364     .getPropertyResourceList>
8365     (<Q::dis:ISA>, recursive_isa => false,
8366     recursive => true,
8367     default_media_type => <Q::dis:TFQNames>)};
8368 wakaba 1.25 for my $p_res (@p_res) {
8369     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
8370 wakaba 1.26 .getPropertyResourceList>
8371     ($propName, recursive_isa => false,
8372     recursive => false,
8373     default_media_type => $defaultMediaType)};
8374 wakaba 1.25 }
8375     }__;
8376     }
8377    
8378     @Method:
8379 wakaba 1.2 @@Name: addPropertyResourceList
8380     @@enDesc:
8381     Adds a resource to a resource-list property value.
8382     \
8383     {ISSUE:: Should an exception be thrown if the property is
8384     not of list?
8385     \
8386     }
8387 wakaba 1.10 \
8388     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
8389     an item clears the list --- i.e. the property values
8390     in the source tree will be ignored. Call
8391     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
8392     before adding to avoid this behavior.
8393     \
8394     }
8395 wakaba 1.2 @@PropNameParam:
8396     @@Param:
8397     @@@Name: res
8398     @@@Type: ManakaiDISResourceDefinition
8399     @@@enDesc:
8400     A resource to add.
8401     @@Return:
8402     @@@PerlDef:
8403     if (ref $self->{$propName} eq 'ARRAY') {
8404 wakaba 1.26 push @{$self->{$propName}}, $res->{uri};
8405 wakaba 1.2 } elsif (not defined $self->{$propName}) {
8406 wakaba 1.26 $self->{$propName} = [$res->{uri}];
8407 wakaba 1.25 } else {
8408     __ASSERT{DISPerl:invariant::
8409     msg => {q[ref $self->{<].qq[$propName>} = "@{[ref
8410     $self->{$propName}]}"]},
8411     }__;
8412 wakaba 1.2 }
8413    
8414 wakaba 1.3 ElementTypeBinding:
8415     @Name: PropNameParam
8416     @ElementType:
8417     dis:ResourceDef
8418     @ShadowContent:
8419     @@rdf:type:
8420     DISLang:MethodParameter
8421     @@Name: propName
8422     @@Type: ResourceURI
8423     @@Description:
8424     @@@lang:en
8425     @@@@:
8426     The name of the property.
8427    
8428 wakaba 1.2 ##DISPropertyAccessor
8429    
8430     PropDef:
8431     @QName:isAnon
8432     @Description:
8433     @@lang:en
8434     @@@:
8435     Whether the subject resource is anonymous or not.
8436     @Type:
8437 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8438 wakaba 1.2
8439     PropDef:
8440     @QName:isDefined
8441     @Description:
8442     @@lang:en
8443     @@@:
8444     Whether the subject resource is defined or not.
8445    
8446     PropDef:
8447 wakaba 1.3 @QName:isReferred
8448 wakaba 1.2 @Description:
8449     @@lang:en
8450     @@@:
8451     Whether the subject resource is referred or not.
8452     @Type:
8453     DOMMain:any
8454    
8455     PropDef:
8456     @QName:definingModule
8457     @Description:
8458     @@lang:en
8459     @@@:
8460     The <QUOTE::dis> module in which the subject resource is defined.
8461 wakaba 1.22 \
8462     {NOTE:: The local name should have been <QUOTE::ownerModule> or some.
8463     \
8464     }
8465 wakaba 1.2 @rdfs:domain:
8466     DISCore:Module
8467 wakaba 1.1
8468     ## -- Datatypes
8469    
8470     URITypeDef:
8471 wakaba 1.3 @QName: AnyURI
8472     @Description:
8473     @@lang:en
8474     @@@:
8475     Any URI references.
8476    
8477     URITypeDef:
8478     @QName: FileURI
8479     @enDesc:
8480     URI references identifying file.
8481    
8482     URITypeDef:
8483 wakaba 1.1 @QName: ForURI
8484     @Description:
8485     @@lang:en
8486     @@@:
8487     <QUOTE::For> URI references.
8488    
8489     DataTypeDef:
8490     @QName: ForURIList
8491     @Description:
8492     @@lang:en
8493     @@@:
8494     References to the array containing <QUOTE::for> URI references.
8495    
8496     URITypeDef:
8497 wakaba 1.3 @QName: ResourceURI
8498     @Description:
8499     @@lang:en
8500     @@@:
8501     A URI reference for a <QUOTE::dis> resource.
8502    
8503     URITypeDef:
8504 wakaba 1.1 @QName: MediaTypeURI
8505     @Description:
8506     @@lang:en
8507     @@@:
8508     Media type URI references.
8509 wakaba 1.3 @rdfs:subClassOf: ResourceURI
8510    
8511     URITypeDef:
8512     @QName: ModuleURI
8513     @enDesc:
8514     URI references for <QUOET::dis> modules.
8515     @rdfs:subClassOf: ResourceURI
8516    
8517     URITypeDef:
8518     @QName: NameURI
8519     @enDesc:
8520     URI references identifying a resource.
8521     @rdfs:subClassOf: ResourceURI
8522 wakaba 1.10
8523     DataTypeDef:
8524     @QName: ResourceList
8525     @enDesc:
8526     References to array containing resource definition objects.
8527     @rdfs:subClassOf:
8528     Perl:ARRAY::ManakaiDOM:all
8529 wakaba 1.3
8530     ElementTypeBinding:
8531     @Name: DataTypeDef
8532     @ElementType:
8533     dis:ResourceDef
8534     @ShadowContent:
8535     @@rdf:type:
8536     ManakaiDOM:DataType
8537    
8538     ElementTypeBinding:
8539     @Name: URITypeDef
8540     @ElementType:
8541     dis:ResourceDef
8542     @ShadowContent:
8543     @@rdf:type:
8544     ManakaiDOM:DataType
8545     @@rdfs:subClassOf: AnyURI
8546 wakaba 1.1
8547     ## -- Exceptions
8548    
8549     XParamDef:
8550 wakaba 1.5 @QName: anotherSourceNode
8551     @enDesc:
8552     Another source node in which an error has occurred. In cases
8553     of <QUOTE::already defined> errors, it is the node that
8554     defines the resource first.
8555     @Type: ManakaiDISNode
8556 wakaba 1.3
8557 wakaba 1.12 ResourceDef:
8558     @QName: UNDECLARED_NS_PREFIX_ERR
8559     @For: ForLatest
8560     @AliasFor:
8561     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
8562    
8563 wakaba 1.3 ExceptionDef:
8564     @ClsQName: ManakaiDISException
8565     @enDesc:
8566     Exceptions for the <QUOTE::dis> operations.
8567 wakaba 1.4 @ClsISA:
8568     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
8569 wakaba 1.3 @XConstGroupDef:
8570     @@ClsQName: ManakaiDISExceptionCode
8571     @@enDesc:
8572     Exception codes for <Class::ManakaiDISException>.
8573     @@XConstDef:
8574 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
8575     @@@Value:3
8576     @@@enDesc:
8577     An attempt is made to break the hierarchy.
8578     @@@XSubTypeDef:
8579     @@@@QName: MERGE_ITSELF_ERR
8580     @@@@enDesc:
8581     An attempt is made to merge the resource to itself.
8582     @@@@XSourceNodeParam:
8583     @@@@XParam:
8584     @@@@@QName:uri
8585     @@@@@enDesc:
8586     The URI reference of the resource to merge.
8587     @@@@enMufDef:
8588     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
8589     );> to itself
8590     @@XConstDef:
8591 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
8592     @@@Value:9
8593     @@@enDesc:
8594     An attempt is made to do something the implementation does not support.
8595     @@@XSubTypeDef:
8596     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
8597     @@@@enDesc:
8598     The implementation does not support the media type.
8599     @@@@XParam:
8600     @@@@@QName: uri
8601     @@@@@enDesc:
8602     The URI reference of the media type that is not supported.
8603     @@@@XSourceNodeParam:
8604 wakaba 1.30 @@@@XParam:
8605     @@@@@QName:elementType
8606     @@@@@enDesc:
8607     The URI reference of the element type of the element
8608     in which the media type is referenced.
8609 wakaba 1.12 @@@@enMufDef:
8610 wakaba 1.30 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": }
8611     );%p (name => {<Q::DIS:elementType>}, prefix => { (Element type: <},
8612     suffix => {>) }
8613     );Media type <%p (name => {<Q::DIS:uri>});> is not supported
8614 wakaba 1.3 @@@XSubTypeDef:
8615 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
8616     @@@@enDesc:
8617     An unsupported type of element is encounted.
8618     @@@@XSourceNodeParam:
8619     @@@@XParam:
8620     @@@@@QName:elementType
8621     @@@@@enDesc:
8622     The element type URI reference of the element.
8623 wakaba 1.16 @@@@enMufDef:
8624     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
8625 wakaba 1.13 @@@XSubTypeDef:
8626 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
8627 wakaba 1.3 @@@@enDesc:
8628 wakaba 1.12 There is no implementation that supports the
8629     <Feature::Util:PerlCode> feature, version
8630     <FeatureVer::1.0>.
8631 wakaba 1.3 @@XConstDef:
8632     @@@Name: INVALID_STATE_ERR
8633     @@@Value:11
8634     @@@enDesc:
8635     An attempt is made to use an object that is not (or no longer) usable.
8636     @@@XSubTypeDef:
8637     @@@@QName: NO_ASSOCIATED_DB_ERR
8638     @@@@enDesc:
8639     No <QUOTE::dis> database has been associated with this document.
8640 wakaba 1.4 @@XConstDef:
8641     @@@Name: INVALID_SOURCE_ERR
8642     @@@Value: 200
8643     @@@enDesc:
8644     The source input is well-formed but invalid.
8645     @@@XSubTypeDef:
8646     @@@@QName: NO_MODULE_QNAME_ERR
8647     @@@@enDesc:
8648     The <Q::dis:Module> element must have its <Q::dis:QName>
8649     attribute.
8650 wakaba 1.8 @@@@XSourceNodeParam:
8651     @@@XSubTypeDef:
8652     @@@@QName: NO_LOCAL_NAME_ERR
8653     @@@@enDesc:
8654     The resource does not have a local name.
8655     @@@@XSourceNodeParam:
8656 wakaba 1.4 @@@XSubTypeDef:
8657     @@@@QName: UNABLE_TO_GET_MODULE_ERR
8658     @@@@enDesc:
8659     The implementation is unable to get the module source.
8660     @@@@Def:
8661     @@@@@ContentType:
8662     lang:muf
8663     @@@@@lang:en
8664     @@@@@@:
8665     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
8666     @@@@XParam:
8667     @@@@@QName: uri
8668     @@@@@enDesc:
8669     The URI reference of the module.
8670     @@@@XParam:
8671     @@@@@QName: namespaceURI
8672     @@@@@enDesc:
8673     The namespace URI of the module name.
8674     @@@@XParam:
8675     @@@@@QName: localName
8676     @@@@@enDesc:
8677     The local name of the module name.
8678     @@@@XParam:
8679     @@@@@QName: for
8680     @@@@@enDesc:
8681     The <QUOTE::for> of the module.
8682 wakaba 1.5 @@@XSubTypeDef:
8683     @@@@QName: NO_FOR_QNAME_ERR
8684     @@@@enDesc:
8685     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
8686     @@@@XSourceNodeParam:
8687     @@@XSubTypeDef:
8688     @@@@QName: FOR_ALREADY_DEFINED_ERR
8689     @@@@enDesc:
8690     The <QUOTE::for> named as the same URI reference has
8691     already defined.
8692     @@@@XSourceNodeParam:
8693     @@@@XParam:
8694     @@@@@QName: anotherSourceNode
8695     @@@@@enDesc:
8696     The node that defines the <QUOTE::for> URI reference before.
8697 wakaba 1.7 @@@@XParam:
8698     @@@@@Name: uri
8699     @@@@@enDesc:
8700     The URI reference of the <QUOTE::for> attempted to define.
8701     @@@@enMufDef:
8702     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
8703 wakaba 1.5 @@@XSubTypeDef:
8704     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
8705     @@@@enDesc:
8706     The <QUOTE::dis> resource named as the same URI reference has
8707     already defined.
8708     @@@@XSourceNodeParam:
8709     @@@@XParam:
8710     @@@@@QName: anotherSourceNode
8711     @@@@@enDesc:
8712     The node that defines the <QUOTE::for> URI reference before.
8713 wakaba 1.7 @@@@XParam:
8714     @@@@@Name: uri
8715     @@@@@enDesc:
8716     The URI reference of the resource attempted to define.
8717     @@@@enMufDef:
8718     Resource <%p (name => {<Q::DIS:uri>});> is already defined
8719 wakaba 1.5 @@@XSubTypeDef:
8720     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
8721     @@@@enDesc:
8722     An element has occured where it is not allowed.
8723     @@@@enMufDef:
8724     Module <%p (name => {<Q::DIS:uri>});>:
8725     Element of type <%p (name => {<Q::DIS:elementType>});>
8726     is not allowed here
8727     @@@@XSourceNodeParam:
8728     @@@@XParam:
8729     @@@@@QName: elementType
8730     @@@@@enDesc:
8731     The expanded element type name of the element.
8732     @@@@XParam:
8733     @@@@@QName: uri
8734     @@@@@enDesc:
8735     The URI reference of the module.
8736 wakaba 1.7 @@@XSubTypeDef:
8737     @@@@QName: NO_REQUIRED_ATTR_ERR
8738     @@@@enDesc:
8739     A required attribute is not specified.
8740     @@@@XSourceNodeParam:
8741     @@@@XParam:
8742     @@@@@QName: elementType
8743     @@@@@enDesc:
8744     The expanded URI reference of the attribute name.
8745     @@@@enMufDef:
8746     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
8747 wakaba 1.8 @@@XSubTypeDef:
8748     @@@@QName: FOR_NOT_DEFINED_ERR
8749     @@@@enDesc:
8750     A <QUOTE::for> is referred but not defined.
8751     @@@@XSourceNodeParam:
8752     @@@@XParam:
8753     @@@@@QName: uri
8754     @@@@@enDesc:
8755     The URI reference of the <QUOTE::for> that is not defined.
8756     @@@@enMufDef:
8757     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
8758     @@@XSubTypeDef:
8759     @@@@QName: RESOURCE_NOT_DEFINED_ERR
8760     @@@@enDesc:
8761 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
8762     or the resource referred does not have the type expected.
8763 wakaba 1.8 @@@@XSourceNodeParam:
8764     @@@@XParam:
8765     @@@@@QName: uri
8766     @@@@@enDesc:
8767     The URI reference of the resource that is not defined.
8768 wakaba 1.13 @@@@XParam:
8769     @@@@@QName: elementType
8770     @@@@@enDesc:
8771     <QUOTE::dis> element type (either tree element type
8772     or preprocessing element type) of the element
8773     in which a reference to the undefined resource is contained.
8774     @@@@XParam:
8775 wakaba 1.30 @@@@@QName:parentURI
8776     @@@@@enDesc:
8777     The URI reference of the resource from whose child resources
8778     a resource is tried to find.
8779     @@@@XParam:
8780 wakaba 1.13 @@@@@QName: localName
8781     @@@@@enDesc:
8782     The local name of the undefined resource.
8783     @@@@XParam:
8784     @@@@QName: sourceCode
8785     @@@@enDesc:
8786     Source code fragment that referres this resource.
8787     @@@@XParam:
8788     @@@@@QName:expectedType
8789     @@@@@enDesc:
8790     Expected resource type.
8791 wakaba 1.8 @@@@enMufDef:
8792 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
8793 wakaba 1.30 %p (name => {<Q::DIS:parentURI>}, prefix => {(In <}, suffix => {>) });
8794 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
8795     suffix => {>});%p (name => {<Q::DIS:localName>},
8796     prefix => { "}, suffix => {"}); is not defined or wrong type%p
8797     (name => {<Q::DIS:expectedType>}, prefix => { (<},
8798     suffix => {> is expected)});
8799     @@@XSubTypeDef:
8800     @@@@QName: NO_SOURCE_NODE_ERR
8801     @@@@enDesc:
8802     A resource does not have associated node in the source tree.
8803     @@@@XSourceNodeParam:
8804     @@@@XParam:
8805     @@@@@QName:uri
8806     @@@@@enDesc:
8807     The URI reference of the resource.
8808 wakaba 1.8 @@@XSubTypeDef:
8809     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
8810     @@@@enDesc:
8811     A reserved Perl method name is used.
8812     @@@@XParam:
8813     @@@@@QName:uri
8814     @@@@@enDesc:
8815     The URI reference of the method resource.
8816     @@@@XSourceNodeParam:
8817     @@@@XParam:
8818     @@@@@QName: generatedName
8819     @@@@@enDesc:
8820     A reserved method name.
8821     @@@XSubTypeDef:
8822     @@@@QName: NO_DIS_TYPE_ERR
8823     @@@@enDesc:
8824     <Q::dis:Type> attribute is not found.
8825     @@@@XSourceNodeParam:
8826 wakaba 1.12 @@@XSubTypeDef:
8827     @@@@QName: NO_METHOD_RETURN_ERR
8828     @@@@enDesc:
8829     A <Q::DISLang:Method> resource does not have any
8830     <Q::DISLang:MethodReturn> child.
8831     @@@@XSourceNodeParam:
8832 wakaba 1.22 @@@@XParam:
8833     @@@@@QName:errResource
8834     @@@@@enDesc: The method resource.
8835     @@@@XParam:
8836     @@@@@QName:uri
8837     @@@@@enDesc:
8838     The URI reference of the method.
8839     @@@@XParam:
8840     @@@@@QName:localName
8841     @@@@@enDesc:
8842     The local name of the resource.
8843     @@@@enMufDef:
8844     Method "%p (name => {<Q::DIS:localName>});" does not have
8845     "Return" child
8846 wakaba 1.12 @@@XSubTypeDef:
8847     @@@@QName: NO_ATTR_GET_ERR
8848     @@@@enDesc:
8849     A <Q::DISLang:Attribute> resource does not have any
8850     <Q::DISLang:AttributeGet> child.
8851     @@@@XSourceNodeParam:
8852 wakaba 1.13 @@@XSubTypeDef:
8853     @@@@QName:INTERFACE_CLASS_METHOD_ERR
8854     @@@@enDesc:
8855     An attempt is made to call a static (class) method
8856     from an interface.
8857     @@@@XSourceNodeParam:
8858     @@@@XParam:
8859     @@@@@QName:uri
8860     @@@@@enDesc:
8861     The URI reference of the interface.
8862     @@@@XParam:
8863     @@@@@QName:sourceCode
8864     @@@@@enDesc:
8865     Source code fragment that calls a class method.
8866     @@@@XParam:
8867     @@@@@QName:elementType
8868     @@@@@enDesc:
8869     The element type URI reference of the element
8870     that calls a method.
8871     @@@XSubTypeDef:
8872     @@@@QName: BROKEN_PARAM_SPEC_ERR
8873     @@@@enDesc:
8874     A parameter specification is broken.
8875     @@@@XParam:
8876     @@@@@QName: sourceCode
8877     @@@@@enDesc:
8878     Source code fragment that contains the broken parameter
8879     specification.
8880     @@@@XSourceNodeParam:
8881 wakaba 1.15 @@@@enMufDef:
8882     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8883     suffix => {": });Broken parameter specification
8884 wakaba 1.13 @@@XSubTypeDef:
8885     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
8886     @@@@enDesc:
8887     A preprocessing instruction does not have its element
8888     type.
8889     @@@@XSourceNodeParam:
8890     @@@@XParam:
8891     @@@@@QName:sourceCode
8892     @@@@@enDesc:
8893     Source code fragment.
8894 wakaba 1.16 @@@@enMufDef:
8895     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8896     suffix => {": });Element type name is not specified
8897 wakaba 1.13 @@@XSubTypeDef:
8898 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
8899 wakaba 1.13 @@@@enDesc:
8900 wakaba 1.15 No Perl package name is defined for the resource referred.
8901 wakaba 1.13 @@@@XSourceNodeParam:
8902     @@@@XParam:
8903 wakaba 1.15 @@@@@QName:sourceCode
8904 wakaba 1.13 @@@@@enDesc:
8905     Source code fragment.
8906     @@@@XParam:
8907 wakaba 1.15 @@@@@QName:uri
8908     @@@@@enDesc:
8909     THe URI reference of the resource referred.
8910     @@@@XParam:
8911     @@@@@QName:elementType
8912     @@@@@enDesc:
8913     The element type of Perl preprocessing instruction
8914     in which the resource is referred.
8915     @@@@enMufDef:
8916     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
8917     package name is not defined
8918     @@@XSubTypeDef:
8919     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
8920     @@@@enDesc:
8921     An exception type specification is required.
8922     @@@@XSourceNodeParam:
8923     @@@@XSourceCodeParam:
8924     @@@@XParam:
8925     @@@@@QName:elementType
8926     @@@@@enDesc:
8927     The element type of the preprocessing instruction.
8928     @@@XSubTypeDef:
8929     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
8930     @@@@enDesc:
8931     A code name specification is required.
8932     @@@@XSourceNodeParam:
8933     @@@@XSourceCodeParam:
8934     @@@@XParam:
8935 wakaba 1.13 @@@@@QName:elementType
8936     @@@@@enDesc:
8937 wakaba 1.15 The element type of the preprocessing instruction.
8938 wakaba 1.13 @@@XSubTypeDef:
8939     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
8940     @@@@enDesc:
8941 wakaba 1.15 The specified resource does not have its Perl definition.
8942 wakaba 1.13 @@@@XSourceNodeParam:
8943 wakaba 1.15 @@@@XSourceCodeParam:
8944 wakaba 1.13 @@@@XParam:
8945 wakaba 1.15 @@@@@QName:elementType
8946     @@@@@enDesc:
8947     The element type of the preprocessing instruction.
8948     @@@@XParam:
8949     @@@@@QName:uri
8950 wakaba 1.13 @@@@@enDesc:
8951 wakaba 1.15 The URI reference of the resource referred.
8952 wakaba 1.13 @@@@XParam:
8953     @@@@@QName:localName
8954     @@@@@enDesc:
8955     The local name of the resource referred.
8956 wakaba 1.15 @@@XSubTypeDef:
8957     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
8958     @@@@enDesc:
8959     A preprocessing instruction which is only allowed in
8960     method definitions is used in a code which is not a method.
8961     @@@@XSourceNodeParam:
8962     @@@@XSourceCodeParam:
8963 wakaba 1.13 @@@@XParam:
8964 wakaba 1.15 @@@@@QName:elementType
8965 wakaba 1.13 @@@@@enDesc:
8966 wakaba 1.15 The element type of the preprocessing instruction.
8967 wakaba 1.14 @@@XSubTypeDef:
8968 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
8969 wakaba 1.14 @@@@enDesc:
8970 wakaba 1.15 A <QUOTE::for> specification is required.
8971 wakaba 1.14 @@@@XSourceNodeParam:
8972 wakaba 1.15 @@@@XSourceCodeParam:
8973 wakaba 1.14 @@@@XParam:
8974 wakaba 1.15 @@@@@QName:elementType
8975 wakaba 1.14 @@@@@enDesc:
8976 wakaba 1.15 The element type of the preprocessing instruction.
8977     @@@XSubTypeDef:
8978     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
8979     @@@@enDesc:
8980     An assertion type specification is required.
8981     @@@@XSourceNodeParam:
8982     @@@@XSourceCodeParam:
8983 wakaba 1.14 @@@@XParam:
8984 wakaba 1.15 @@@@@QName:elementType
8985 wakaba 1.14 @@@@@enDesc:
8986 wakaba 1.15 The element type of the preprocessing instruction.
8987     @@@XSubTypeDef:
8988     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
8989     @@@@enDesc:
8990     A preprocessing instruction block occurred with
8991     element type which does not allow it.
8992     @@@@XSourceNodeParam:
8993     @@@@XSourceCodeParam:
8994 wakaba 1.14 @@@@XParam:
8995     @@@@@QName:elementType
8996     @@@@@enDesc:
8997 wakaba 1.15 The element type of the preprocessing instruction.
8998 wakaba 1.18 @@@XSubTypeDef:
8999     @@@@QName: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
9000     @@@@enDesc:
9001     A non-named method parameter following
9002     any named method parameter is occurred.
9003     @@@@XSourceNodeParam:
9004     @@@@XParam:
9005     @@@@@QName:uri
9006     @@@@@enDesc:
9007     The URI reference of the non-named method parameter resource.
9008     @@@@XParam:
9009     @@@@@QName:localName
9010     @@@@@enDesc:
9011     The local name of the non-named method parameter.
9012 wakaba 1.19 @@@XSubTypeDef:
9013     @@@@QName:DISPERL_NO_VALUE_ALLOWED_ERR
9014     @@@@enDesc:
9015     An element node have a value but the definition
9016     of that element type does not allow it.
9017     @@@@XSourceNodeParam:
9018     @@@@XParam:
9019     @@@@@QName:elementType
9020     @@@@@enDesc:
9021     The element type URI reference of the element.
9022     @@@XSubTypeDef:
9023     @@@@QName:NO_CONST_VALUE_ERR
9024     @@@@enDesc:
9025     The source element node for a constant value resource
9026     does not have <Q::dis:Value> attribute.
9027     @@@@XSourceNodeParam:
9028     @@@@XParam:
9029     @@@@@QName:elemntType
9030     @@@@@enDesc:
9031     The element type URI reference of the element from which
9032     a constant value resource is referred.
9033     @@@@XParam:
9034     @@@@@QName:uri
9035     @@@@@enDesc:
9036     The resource URI reference of the constant value resource.
9037     @@@@XParam:
9038     @@@@@QName:localName
9039     @@@@@enDesc:
9040     The local name of the constant value resource.
9041     @@@XSubTypeDef:
9042     @@@@QName:NO_ATTR_SET_ERR
9043     @@@@enDesc:
9044     An attribute setter is referred but the attribute
9045     does not define any setter.
9046     @@@@XSourceNodeParam:
9047     @@@@XParam:
9048     @@@@@QName:errResource
9049     @@@@@enDesc:
9050     The attribute resource.
9051     @@@@XParam:
9052     @@@@@QName:elementType
9053     @@@@@enDesc:
9054     The type of the element by which this attribute
9055     is referred.
9056 wakaba 1.20 @@@XSubTypeDef:
9057     @@@@QName: PERL_SUBROUTINE_ALREADY_DEFINED_ERR
9058     @@@@enDesc:
9059     A resource defines a Perl subroutine whose name is
9060     same as another subroutine.
9061     @@@@XSourceNodeParam:
9062     @@@@XParam:
9063     @@@@@QName:uri
9064     @@@@@enDesc:
9065     The URI reference of the resource that defines the Perl subroutine.
9066     @@@@XParam:
9067     @@@@@QName:
9068     PerlCode:localName
9069     @@@@@enDesc:
9070     The name of the Perl subroutine.
9071     @@@XSubTypeDef:
9072     @@@@QName: PERL_OPERATOR_ALREADY_OVERLOADED_ERR
9073     @@@@enDesc:
9074     A resource is defined to overload a Perl operator which
9075     is already overloaded by another resource.
9076     @@@@XSourceNodeParam:
9077     @@@@XParam:
9078     @@@@@QName:uri
9079     @@@@@enDesc:
9080     The URI reference of the resource that defines the overloading.
9081     @@@@XParam:
9082     @@@@@QName:
9083     PerlCode:operator
9084     @@@@@enDesc:
9085     The operator.
9086     @@@XSubTypeDef:
9087     @@@@QName: PERL_UNUSED_SUBROUTINE_ERR
9088     @@@@enDesc:
9089     A resource defines a Perl subroutine but it is not used.
9090     @@@@XSourceNodeParam:
9091     @@@@XParam:
9092     @@@@@QName:uri
9093     @@@@@enDesc:
9094     The URI reference of the resource.
9095 wakaba 1.22 @@@XSubTypeDef:
9096     @@@@QName: NO_LICENSE_ATTR_ERR
9097     @@@@enDesc:
9098     The <Q::dis:Module> element does not have the
9099     <Q::dis:License> attribute.
9100     @@@@XSourceNodeParam:
9101     @@@@XParam:
9102     @@@@@QName:uri
9103     @@@@@enDesc:
9104     The URI reference of the module.
9105 wakaba 1.25 @@@XSubTypeDef:
9106     @@@@QName: UNSUPPORTED_ROLE_ERR
9107     @@@@enDesc:
9108     A <Q::dis:Role> is not supported.
9109     @@@@XSourceNodeParam:
9110     @@@@XParam:
9111     @@@@@QName:uri
9112     @@@@@enDesc:
9113     The URI reference of the unsupported role.
9114     @@@@enMufDef:
9115     Role <%p (name => {<Q::DIS:uri>});> is not supported
9116 wakaba 1.4 ##DISException
9117 wakaba 1.13
9118     XParamDef:
9119     @QName:expectedType
9120     @Type: ResourceURI
9121     @enDesc:
9122     Expected resource type URI reference.
9123    
9124     XParamDef:
9125     @QName: sourceCode
9126     @Type:
9127     DISLang:String::ManakaiDOM:all
9128     @enDesc:
9129     The source code fragment in which an error occurred.
9130 wakaba 1.5
9131     XParamDef:
9132     @QName: elementType
9133     @Type: ResourceURI
9134     @enDesc:
9135     The name of the element type.
9136    
9137     XParamDef:
9138     @QName: uri
9139     @Type: ResourceURI
9140     @enDesc:
9141     The name of the resource, composed from <Q::namespaceURI>,
9142     <Q::localName> and <Q::for>.
9143    
9144     XParamDef:
9145     @QName: localName
9146     @Type:
9147 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
9148 wakaba 1.5 @enDesc:
9149     The local name of the resource, unique in <Q::namespaceURI> namespace.
9150    
9151     XParamDef:
9152     @QName: namespaceURI
9153     @Type: AnyURI
9154     @enDesc:
9155     The namespace URI reference of the resource name.
9156    
9157     XParamDef:
9158     @QName: for
9159     @Type: ForURI
9160     @enDesc:
9161     The <QUOTE::for> URI reference of the resource.
9162    
9163     ElementTypeBinding:
9164     @Name: XSourceNodeParam
9165     @ElementType:
9166     ManakaiDOM:exceptionOrWarningParameter
9167     @ShadowContent:
9168     @@QName: sourceNode
9169     @@Description:
9170     @@@lang:en
9171     @@@@:
9172     The node in which an error has occurred.
9173 wakaba 1.15
9174     ElementTypeBinding:
9175     @Name: XSourceCodeParam
9176     @ElementType:
9177     ManakaiDOM:exceptionOrWarningParameter
9178     @ShadowContent:
9179     @@QName: sourceCode
9180     @@Description:
9181     @@@lang:en
9182     @@@@:
9183     The source code in which an error has occurred.
9184 wakaba 1.4
9185     ClsDef:
9186     @ClsQName: ManakaiDISExceptionTarget
9187     @enDesc:
9188     Objects that is able to be the target of an exception.
9189     @IntMethod:
9190     @@Operator:
9191     @@@@:
9192     ManakaiDOM:MUErrorHandler
9193     @@@ContentType:
9194     dis:TypeQName
9195     @@Description:
9196     @@@lang:en
9197     @@@@:
9198     This method is a generic error handler; all manakai exceptions
9199     and warnings associated to an object are once reported to this method
9200     and then delivered to appropriate entities.
9201     \
9202     If the error is an exception (such as <X::DOMCore:DOMException> or
9203     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
9204     simply thrown. If the error is only a warning, it is reported
9205     via the <IF::DOMCore:DOMError> interface.
9206     \
9207     See <PerlModule::Message::Util::Error> documentation for more
9208     information on the error reporting mechanism.
9209     \
9210     {NOTE:: This kind of methods are named as <Perl::___report_error>
9211     in the convention of <PerlModule::Message::Util::Error>.
9212     \
9213     }
9214     @@Param:
9215     @@@Name:err
9216     @@@Type:
9217     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
9218     @@@Description:
9219     @@@@lang:en
9220     @@@@@:
9221     An exception object that describes what kind of error it is
9222     and how it should be recovered.
9223     \
9224     {NOTE:: Exception objects in manakai implementation
9225     inherit the class <PerlModule::Message::Util::Error>,
9226     that in turn inherits <PerlModule::Error>.
9227     \
9228     }
9229     @@Return:
9230     @@@PerlDef:
9231     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
9232     ::ManakaiDOM:Perl>)) {
9233     $err->throw;
9234     } else {
9235     \## TODO: Implement warning reporting
9236     warn $err->stringify;
9237     }
9238     ##DISExceptionTarget
9239    
9240     ForDef:
9241     @QName:
9242     DIS:ForIF
9243     ForDef:
9244     @QName:
9245     DIS:ForClass
9246    
9247     ElementTypeBinding:
9248     @Name: IFClsDef
9249     @ElementType:
9250     dis:ResourceDef
9251     @ShadowContent:
9252     @@rdf:type:
9253     @@@@:
9254     dis:MultipleResource
9255     @@@ForCheck: !ForClass !ForIF
9256     @@rdf:type:
9257     @@@@:
9258     ManakaiDOM:IF
9259     @@@ForCheck: ForIF
9260     @@rdf:type:
9261     @@@@:
9262     ManakaiDOM:Class
9263     @@@ForCheck: ForClass
9264     @@resourceFor: ForIF
9265     @@resourceFor:
9266     @@@@: ForClass
9267     @@@ForCheck: ForLatest
9268     @@DOMMain:implementFeature:
9269     @@@@:CoreFeature10
9270     @@@ForCheck: ForClass
9271     @@ForCheck:
9272     ManakaiDOM:Perl
9273 wakaba 1.3
9274     ElementTypeBinding:
9275     @Name: ClsDef
9276     @ElementType:
9277     dis:ResourceDef
9278     @ShadowContent:
9279     @@rdf:type:
9280     ManakaiDOM:Class
9281     @@AliasFor:
9282     @@@@:
9283 wakaba 1.11 ::DIS:ForLatest
9284 wakaba 1.3 @@@For:
9285 wakaba 1.11 !=DIS:ForLatest
9286 wakaba 1.3 @@ForCheck:
9287     ManakaiDOM:Perl
9288     @@DOMMain:implementFeature: CoreFeature10
9289    
9290     ElementTypeBinding:
9291     @Name: ExceptionDef
9292     @ElementType:
9293     dis:ResourceDef
9294     @ShadowContent:
9295     @@rdf:type:
9296     ManakaiDOM:ExceptionClass
9297     @@AliasFor:
9298     @@@@:
9299     ::ForLatest
9300     @@@For:
9301     !=ForLatest
9302     @@ForCheck:
9303     ManakaiDOM:Perl
9304     @@DOMMain:implementFeature: CoreFeature10
9305    
9306     ElementTypeBinding:
9307     @Name: ClsQName
9308     @ElementType:
9309     dis:QName
9310    
9311     ElementTypeBinding:
9312     @Name: ClsISA
9313     @ElementType:
9314     dis:ISA
9315    
9316     ElementTypeBinding:
9317     @Name: Method
9318     @ElementType:
9319     dis:ResourceDef
9320     @ShadowContent:
9321     @@rdf:type:
9322     DISLang:Method
9323    
9324     ElementTypeBinding:
9325     @Name: IntMethod
9326     @ElementType:
9327     dis:ResourceDef
9328     @ShadowContent:
9329     @@rdf:type:
9330     DISLang:Method
9331     @@ManakaiDOM:isForInternal:1
9332    
9333     ElementTypeBinding:
9334     @Name: Attr
9335     @ElementType:
9336     dis:ResourceDef
9337     @ShadowContent:
9338     @@rdf:type:
9339     DISLang:Attribute
9340    
9341     ElementTypeBinding:
9342     @Name: Return
9343     @ElementType:
9344     dis:ResourceDef
9345     @ShadowContent:
9346     @@rdf:type:
9347     DISLang:MethodReturn
9348    
9349     ElementTypeBinding:
9350     @Name: Get
9351     @ElementType:
9352     dis:ResourceDef
9353     @ShadowContent:
9354     @@rdf:type:
9355     DISLang:AttributeGet
9356    
9357     ElementTypeBinding:
9358     @Name: Set
9359     @ElementType:
9360     dis:ResourceDef
9361     @ShadowContent:
9362     @@rdf:type:
9363     DISLang:AttributeSet
9364    
9365     ElementTypeBinding:
9366     @Name: Param
9367     @ElementType:
9368     dis:ResourceDef
9369     @ShadowContent:
9370     @@rdf:type:
9371     DISLang:MethodParameter
9372    
9373     ElementTypeBinding:
9374     @Name: PerlDef
9375     @ElementType:
9376     dis:Def
9377     @ShadowContent:
9378     @@ContentType:
9379     lang:Perl
9380    
9381     ElementTypeBinding:
9382     @Name: disDef
9383     @ElementType:
9384     dis:Def
9385     @ShadowContent:
9386     @@ContentType:
9387     lang:dis
9388    
9389     ElementTypeBinding:
9390     @Name: InCase
9391     @ElementType:
9392     dis:ResourceDef
9393     @ShadowContent:
9394     @@rdf:type:
9395     ManakaiDOM:InCase
9396    
9397     ElementTypeBinding:
9398     @Name: nullCase
9399     @ElementType:
9400     dis:ResourceDef
9401     @ShadowContent:
9402     @@rdf:type:
9403     ManakaiDOM:InCase
9404     @@Value:
9405     @@@is-null:1
9406    
9407     ElementTypeBinding:
9408     @Name: TrueCase
9409     @ElementType:
9410     dis:ResourceDef
9411     @ShadowContent:
9412     @@rdf:type:
9413     ManakaiDOM:InCase
9414     @@Value:true
9415     @@Type:
9416 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
9417 wakaba 1.3
9418    
9419     ElementTypeBinding:
9420     @Name: FalseCase
9421     @ElementType:
9422     dis:ResourceDef
9423     @ShadowContent:
9424     @@rdf:type:
9425     ManakaiDOM:InCase
9426     @@Value:false
9427     @@Type:
9428 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
9429 wakaba 1.3
9430     ElementTypeBinding:
9431     @Name: enDesc
9432     @ElementType:
9433     dis:Description
9434     @ShadowContent:
9435     @@lang:en
9436    
9437     ElementTypeBinding:
9438     @Name: PropDef
9439     @ElementType:
9440     dis:ResourceDef
9441     @ShadowContent:
9442     @@rdf:type:
9443     rdf:Property
9444     @@AliasFor:
9445     @@@@:
9446     ::ManakaiDOM:all
9447     @@@For:
9448     !=ManakaiDOM:all
9449    
9450     ElementTypeBinding:
9451     @Name: MethodRedef
9452     @ElementType:
9453     dis:ResourceDef
9454     @ShadowContent:
9455     @@rdf:type:
9456     DISLang:Method
9457     @@ManakaiDOM:isRedefining:1
9458    
9459     ElementTypeBinding:
9460     @Name: NamedParam
9461     @ElementType:
9462     dis:ResourceDef
9463     @ShadowContent:
9464     @@rdf:type:
9465     DISLang:MethodParameter
9466     @@DISPerl:isNamedParameter:1
9467    
9468     ElementTypeBinding:
9469     @Name: NodeParam
9470     @ElementType:
9471     dis:ResourceDef
9472     @ShadowContent:
9473     @@rdf:type:
9474     DISLang:MethodParameter
9475     @@DISPerl:isNamedParameter:1
9476     @@Name: node
9477     @@Type: ManakaiDISNode
9478     @@Description:
9479     @@@lang:en
9480     @@@@:
9481     The node in which the name has occurred. It is intended
9482     to be reported when an exception had been raised.
9483     @@ResourceDef:
9484     @@@rdf:type:
9485     ManakaiDOM:InCase
9486     @@@Value:
9487     @@@@is-null:1
9488     @@@Description:
9489     @@@@lang:en
9490     @@@@@:
9491     The source of the name is not a node.
9492    
9493     ElementTypeBinding:
9494     @Name: ForParam
9495     @ElementType:
9496     dis:ResourceDef
9497     @ShadowContent:
9498     @@rdf:type:
9499     DISLang:MethodParameter
9500     @@DISPerl:isNamedParameter:1
9501     @@Name: forArg
9502     @@Type: ForURI
9503     @@Description:
9504     @@@lang:en
9505     @@@@:
9506     The <QUOTE::for> URI reference.
9507     @@ResourceDef:
9508     @@@rdf:type:
9509     ManakaiDOM:InCase
9510     @@@Value:
9511     @@@@is-null:1
9512     @@@Description:
9513     @@@@lang:en
9514     @@@@@:
9515     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
9516    
9517     ElementTypeBinding:
9518     @Name: ForpParam
9519     @ElementType:
9520     dis:ResourceDef
9521     @ShadowContent:
9522     @@rdf:type:
9523     DISLang:MethodParameter
9524     @@DISPerl:isNamedParameter:1
9525     @@Name: forpArg
9526     @@Type: ForURIList
9527     @@Description:
9528     @@@lang:en
9529     @@@@:
9530     An array reference containing additional <QUOTE::for>
9531     constraints (<QUOTE::For+> list).
9532     @@ResourceDef:
9533     @@@rdf:type:
9534     ManakaiDOM:InCase
9535     @@@Value:
9536     @@@@is-null:1
9537     @@@Description:
9538     @@@@lang:en
9539     @@@@@:
9540     Equivalent to the empty array reference.
9541    
9542     ElementTypeBinding:
9543     @Name: MediaTypeParam
9544     @ElementType:
9545     dis:ResourceDef
9546     @ShadowContent:
9547     @@rdf:type:
9548     DISLang:MethodParameter
9549     @@DISPerl:isNamedParameter:1
9550     @@Name: mediaType
9551     @@Type: MediaTypeURI
9552     @@Description:
9553     @@@lang:en
9554     @@@@:
9555     The URI reference identifying a media type.
9556     @@ResourceDef:
9557     @@@rdf:type:
9558     ManakaiDOM:InCase
9559     @@@Value:
9560     @@@@is-null:1
9561     @@@Description:
9562     @@@@lang:en
9563     @@@@@:
9564     No media type specified.
9565    
9566     ElementTypeBinding:
9567     @Name: MediaTypeDefaultParam
9568     @ElementType:
9569     dis:ResourceDef
9570     @ShadowContent:
9571     @@rdf:type:
9572     DISLang:MethodParameter
9573     @@DISPerl:isNamedParameter:1
9574     @@Name: defaultMediaType
9575     @@Type: MediaTypeURI
9576     @@Description:
9577     @@@lang:en
9578     @@@@:
9579     The default media type, i.e. the type used when no explicit
9580     specification is not found in the source tree.
9581     @@ResourceDef:
9582     @@@rdf:type:
9583     ManakaiDOM:InCase
9584     @@@Value:
9585     @@@@is-null:1
9586     @@@Description:
9587     @@@@lang:en
9588     @@@@@:
9589     Defaulted to <Q::DOMMain:any>.
9590    
9591     ElementTypeBinding:
9592     @Name: RaiseException
9593     @ElementType:
9594     ManakaiDOM:raises
9595    
9596     ElementTypeBinding:
9597     @Name: UndeclaredPrefixException
9598     @ElementType:
9599     ManakaiDOM:raises
9600     @ShadowContent:
9601     @@@: UNDECLARED_NS_PREFIX_ERR
9602     @@Description:
9603     @@@lang:en
9604     @@@@:
9605     The implementation has encounted an undeclared namespace prefix.
9606    
9607     ElementTypeBinding:
9608     @Name: NoDBException
9609     @ElementType:
9610     ManakaiDOM:raises
9611     @ShadowContent:
9612     @@@: NO_DB_ASSOCIATED_ERR
9613     @@Description:
9614     @@@lang:en
9615     @@@@:
9616     No <QUOTE::dis> database is associated to this document.
9617    
9618     ElementTypeBinding:
9619     @Name: XConstGroupDef
9620     @ElementType:
9621     dis:ResourceDef
9622     @ShadowContent:
9623     @@rdf:type:
9624     ManakaiDOM:ConstGroup
9625     @@Type:
9626     DOMMain:unsigned-short::ManakaiDOM:all
9627     @@rdfs:subClassOf:
9628     DOMMain:unsigned-short::ManakaiDOM:all
9629    
9630     ElementTypeBinding:
9631     @Name: XConstDef
9632     @ElementType:
9633     dis:ResourceDef
9634     @ShadowContent:
9635     @@rdf:type:
9636     ManakaiDOM:Const
9637    
9638     ElementTypeBinding:
9639     @Name: XSubTypeDef
9640     @ElementType:
9641     dis:ResourceDef
9642     @ShadowContent:
9643     @@rdf:type:
9644     ManakaiDOM:ExceptionOrWarningSubType
9645    
9646     ElementTypeBinding:
9647     @Name: XParam
9648     @ElementType:
9649     ManakaiDOM:exceptionOrWarningParameter
9650    
9651     ElementTypeBinding:
9652     @Name: XParamDef
9653     @ElementType:
9654     dis:ResourceDef
9655     @ShadowContent:
9656     @@rdf:type:
9657     DOMMain:XWParameter
9658 wakaba 1.12 @@For:
9659     =ManakaiDOM:all
9660 wakaba 1.3
9661     ElementTypeBinding:
9662     @Name: enMufDef
9663     @ElementType:
9664     dis:Def
9665     @ShadowContent:
9666     @@ContentType:
9667     lang:muf
9668     @@lang:en
9669 wakaba 1.21
9670 wakaba 1.3

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24