/[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.30 - (hide annotations) (download)
Wed May 4 13:49:27 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.29: +68 -20 lines
lib/Message/DOM/DOMMain.dis is now dac-compilable

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24