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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24