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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24