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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24