/[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.36 - (hide annotations) (download)
Sat May 21 16:16:41 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.35: +3 -2 lines
Simple serializer implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24