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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24