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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24