/[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.26 - (hide annotations) (download)
Sat Apr 30 11:17:55 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.25: +69 -140 lines
Roles revised (See manakai//((memo))//2005-04-03 <http://suika.fam.cx/gate/2005/sw/manakai/%E3%83%A1%E3%83%A2/2005-04-30>)

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.26 $Date: 2005/04/30 06:52:21 $
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     for my $cls (@{$self-><M::ManakaiDISPropertyAccessor
3816     .getPropertyResourceList>
3817     (<Q::DIS:resource>)}) {
3818 wakaba 1.23 if ($cls-><AG::ManakaiDISResourceDefinition.ownerModule>
3819 wakaba 1.22 eq $ownermod) {
3820 wakaba 1.23 if ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
3821     (<Q::ManakaiDOM:Class>)) {
3822 wakaba 1.24 ## -- Subroutines and variables
3823 wakaba 1.23 my $pack = $cls-><AG::ManakaiDISResourceDefinition
3824     .plCodeFragment>;
3825     $r-><M::PLFile.appendPackage> ($pack);
3826 wakaba 1.24 my $pack_name = $cls-><AG::ManakaiDISResourceDefinition
3827     .plFullyQualifiedName>;
3828    
3829     ## -- Features
3830     my %feature;
3831     for my $el (@{$cls->{src}
3832     -><M::ManakaiDISElement.disChildElements>
3833     (for_arg => $self->{for},
3834     forp_arg => $self->{forp})}) {
3835     next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
3836     .expandedURI> eq <Q::DOMMetaImpl:provideFeature>;
3837     my $furi = $el-><AG::ManakaiDISElement.qnameValueURI>;
3838     my $f = $self->{db}-><M::ManakaiDISDatabase.getResource>
3839     ($furi);
3840     unless ($f-><AS::ManakaiDISResourceDefinition.isDefined>) {
3841     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3842     DIS:sourceNode => {$el},
3843     DIS:uri => {$furi},
3844     DIS:expectedType => {<Q::DOMMain:DOMFeature>},
3845     }__}__;
3846     }
3847     for my $s ($f, @{$f-><M::ManakaiDISPropertyAccessor
3848     .getPropertyResourceList>
3849     (<Q::DOMMetaImpl:extendFeature>,
3850     recursive => true,
3851     default_media_type => <Q::dis:TypeQName>)}) {
3852     $feature{$s-><AG::ManakaiDISResourceDefinition.uri>}
3853     = [$s, $el];
3854     }
3855     }
3856     for my $f (values %feature) {
3857     my @fname = @{$f->[0]-><AG::ManakaiDISResourceDefinition
3858     .featureNameList>};
3859     my $fver = $f->[0]-><M::ManakaiDISPropertyAccessor
3860     .getPropertyText>
3861     (<Q::dis:Version>, null);
3862     next unless defined $fver;
3863     my $fi = $self-><M::ManakaiDISPerlModuleDefinition
3864     .plIsFeatureImplemented> ($f->[0]->{uri}) ? true : false;
3865     my @ec = @{$f->[1]-><M::ManakaiDISElement.disChildElements>
3866     (for_arg => $self->{for},
3867     forp_arg => $self->{forp})};
3868     if (@ec) {
3869     for my $ec (@ec) {
3870     next unless $ec-><AG::swcfg21:SWCFGElement
3871     ::swcfg21:ForLatest
3872     .expandedURI> eq <Q::DOMMetaImpl:providedThrough>;
3873     my $curi = $ec-><M::ManakaiDISElement.tfqnamesValueURI>
3874     ($self->{nameURI}, $self->{for});
3875     my $c = $self->{db}-><M::ManakaiDISDatabase.getResource>
3876     ($curi);
3877     $c-><AS::ManakaiDISResourceDefinition.isReferred> ($ec);
3878     my $cp = $c-><AG::ManakaiDISResourceDefinition
3879     .plFullyQualifiedName>;
3880     for my $fname (@fname) {
3881     $r-><M::PLBlockCon.appendStatement>
3882     ('$' . $cp . '::ProvideFeature{q<' .
3883     $fname . '>}->{q<' . $fver . '>} ||= '.$fi);
3884     $r-><M::PLBlockCon.appendStatement>
3885     ('$' . $cp . '::ProvideFeature{q<' .
3886     $fname . '>}->{q<>} = 1');
3887     }
3888     }
3889     } else { ## No DOMMetaImpl:ProvidedThrough attribute
3890     for my $fname (@fname) {
3891     $r-><M::PLBlockCon.appendStatement>
3892     ('$' . $pack_name . '::ProvideFeature{q<' .
3893     $fname . '>}->{q<' . $fver . '>} ||= '.$fi);
3894     $r-><M::PLBlockCon.appendStatement>
3895     ('$' . $pack_name . '::ProvideFeature{q<' .
3896     $fname . '>}->{q<>} = 1');
3897     }
3898     }
3899     }
3900 wakaba 1.25
3901     ## -- Roles
3902     for my $role (@{$cls-><M::ManakaiDISPropertyAccessor
3903 wakaba 1.26 .getPropertyResourceList>
3904     (<Q::DISLang:role>, isa_recursive => true,
3905     default_media_type => <Q::dis:TypeQName>)}) {
3906     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3907     (<Q::DOMMetaImpl:ImplementationSourceForManakaiDOMImplementationRegistry>)) {
3908     $r-><M::PLBlockCon.appendStatement>
3909     ('$Message::DOM::ManakaiDOMImplementationRegistry'.
3910     '::SourceClass{q<' . $pack_name . '>} = 1');
3911 wakaba 1.25 }
3912 wakaba 1.26 if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3913     (<Q::DOMMetaImpl:ImplementationForManakaiDOMImplementationSource>)) {
3914     $r-><M::PLBlockCon.appendStatement>
3915     ('$Message::DOM::ManakaiDOMImplementationSource'.
3916     '::SourceClass{q<' . $pack_name . '>} = 1');
3917     }
3918     if ($role-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3919     (<Q::DOMMetaImpl:ImplementationCompatibleWithManakaiDOMMinimumImplementation>)
3920     ) {
3921 wakaba 1.25 $r-><M::PLBlockCon.appendStatement>
3922 wakaba 1.26 ('$Message::DOM::ManakaiDOMMinimumImplementation'.
3923     '::CompatClass{q<' . $pack_name . '>} = 1');
3924 wakaba 1.25 }
3925     }
3926 wakaba 1.23 } elsif ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
3927     (<Q::DISPerl:ScalarVariable>) and
3928     not $cls-><M::ManakaiDISPropertyAccessor
3929     .getPropertyResource> (<Q::dis2pm:parentResource>)) {
3930     $r-><M::PLBlockCon.appendCodeFragment>
3931     ($cls-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
3932     }
3933 wakaba 1.22 }
3934     }
3935    
3936 wakaba 1.24 ## -- Require'ing external modules
3937 wakaba 1.22 ## TODO: Custom module construction support
3938     my $thismod_name = $self-><AG::ManakaiDISModuleDefinition
3939     .plFullyQualifiedName>;
3940     for my $uri (@{$r-><M::MPLCodeFragment.disGetRequireURIList>}) {
3941     my $mod = $self->{db}-><M::ManakaiDISDatabase.getResource> ($uri)
3942     -><AG::ManakaiDISResourceDefinition.ownerModule>;
3943     next unless $mod;
3944     my $pack = $mod-><AG::ManakaiDISModuleDefinition
3945     .plFullyQualifiedName>;
3946     $r-><M::PLFile.addRequirePerlModuleName> ($pack)
3947     unless $pack eq $thismod_name;
3948     }
3949 wakaba 1.24
3950    
3951 wakaba 1.22 }__;
3952    
3953 wakaba 1.24 @Method:
3954     @@Name: plIsFeatureImplemented
3955     @@enDesc
3956     Returns whether a feature is implemented by this module
3957     or resource or not.
3958     \
3959     {NOTE:: For modules, tests for features not provided
3960     by the modules will return <DOM::true>. For
3961     resources, if it does not provides the support
3962     for the feature, then this method will return <DOM::true>.
3963     \
3964     }
3965     \
3966     {NOTE:: Feature inheritances are not taken into account.
3967     \
3968     }
3969     @@Param:
3970     @@@Name:featureResourceURI
3971     @@@Type: ResourceURI
3972     @@@enDesc:
3973     The URI reference of the resource definition for
3974     the feature to test.
3975     @@Return:
3976     @@@Type:
3977     DOMMain:boolean::ManakaiDOM:all
3978     @@@enDesc:
3979     Whether the feature is implemented or not.
3980     @@@PerlDef:
3981     __DEEP{
3982     if (defined $self->{<Q::DIS:isFeatureImplemented>}
3983     ->{$featureResourceURI}) {
3984     $r = $self->{<Q::DIS:isFeatureImplemented>}
3985     ->{$featureResourceURI};
3986     } elsif ($self->isa (<ClassName::ManakaiDISModuleDefinition>)) {
3987     $r = true;
3988     for my $cls (@{$self-><M::ManakaiDISPropertyAccessor
3989     .getPropertyResourceList>
3990     (<Q::DIS:resource>)}) {
3991     if ($cls-><M::ManakaiDISResourceDefinition.isTypeURI>
3992     (<Q::ManakaiDOM:Class>)) {
3993     unless ($cls-><M::ManakaiDISPerlModuleDefinition
3994     .plIsFeatureImplemented>
3995     ($featureResourceURI)) {
3996     $r = false;
3997     last;
3998     }
3999     }
4000     ## NOTE: DISPerl:ScalarVariable's are always implemented
4001     }
4002     $self->{<Q::DIS:isFeatureImplemented>}
4003     ->{$featureResourceURI} = $r;
4004     } else { ## Resource definition
4005     ## TODO: Custom module definition
4006     if ($self-><M::ManakaiDISResourceDefinition.isFeatureProvided>
4007     ($featureResourceURI)) {
4008     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4009     (<Q::DISLang:MethodReturn>) or
4010     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4011     (<Q::DISLang:AttributeGet>) or
4012     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4013     (<Q::DISLang:AttributeSet>)) {
4014     my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4015     (<Q::dis:Def>, for_arg => $self->{for},
4016     forp_arg => $self->{forp});
4017     $r = $def ? true : false;
4018     } else {
4019     $r = true;
4020     for my $res (@{$self-><M::ManakaiDISPropertyAccessor
4021     .getPropertyResourceList>
4022     (<Q::DIS:childResource>)}) {
4023     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
4024     (<Q::DISLang:AnyMethod>)) {
4025     unless ($res-><M::ManakaiDISPerlModuleDefinition
4026     .plIsFeatureImplemented>
4027     ($featureResourceURI)) {
4028     $r = false;
4029     last;
4030     }
4031     }
4032     } # for
4033     } # self.type
4034     } else {
4035     $r = true;
4036     }
4037     $self->{<Q::DIS:isFeatureImplemented>}->{$featureResourceURI} = $r;
4038     }
4039     }__;
4040 wakaba 1.22
4041     ##DISPerlModuleDefinition
4042    
4043 wakaba 1.24 PropDef:
4044     @QName: isFeatureImplemented
4045     @enDesc:
4046     The list of whether a feature is implemented or not.
4047    
4048 wakaba 1.22 ResourceDef:
4049     @QName: PLFile
4050     @AliasFor:
4051     PerlCode:ManakaiPerlFile::ManakaiDOM:Perl
4052     @rdf:type:
4053     rdfs:Class
4054    
4055     ClsDef:
4056 wakaba 1.2 @ClsQName: ManakaiDISResourceDefinition
4057     @enDesc:
4058     <QUOTE::dis> resource definitions.
4059     @ClsISA: ManakaiDISPropertyAccessor
4060 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
4061 wakaba 1.22 @ClsISA: ManakaiDISPerlModuleDefinition
4062 wakaba 1.21
4063     @IntMethod:
4064     @@Operator:
4065     @@@@:eq
4066     @@@ContentType:
4067     lang:Perl
4068     @@enDesc:
4069     Whether two <QUOTE::dis> resource definitions are equal or not.
4070     Two resource definitions are equal iff one's <A::.uri> is
4071     literally equal to another's <A::.uri>.
4072     @@Param:
4073     @@@Name: anotherResource
4074     @@@Type: ManakaiDISResourceDefinition
4075     @@@enDesc:
4076     Another resource definition to compare.
4077     @@Return:
4078     @@@Type:
4079     DOMMain:boolean::ManakaiDOM:all
4080     @@@enDesc:
4081     Whether two resources are equal or not.
4082     @@@PerlDef:
4083     if (UNIVERSAL::isa ($anotherResource,
4084     <ClassName::ManakaiDISResourceDefinition>)) {
4085     $r = $self->{uri} eq $anotherResource->{uri};
4086     } else {
4087     $r = false;
4088     }
4089 wakaba 1.2
4090     @Attr:
4091     @@Name: uri
4092     @@Type: ResourceURI
4093     @@Description:
4094     @@@lang:en
4095     @@@@:
4096     The URI reference of this <QUOTE::dis> resource.
4097     @@Get:
4098     @@@PerlDef:
4099     $r = $self->{uri};
4100    
4101     @Attr:
4102     @@Name: nameURI
4103     @@Type: NameURI
4104     @@enDesc:
4105     The URI reference of this <QUOTE::dis> resource, without
4106     <QUOTE::for> identifier.
4107     @@Get:
4108     @@@nullCase:
4109     @@@@enDesc:
4110     This resource does not have its name URI reference.
4111 wakaba 1.3 @@@PerlDef:
4112 wakaba 1.4 $r = $self->{nameURI};
4113 wakaba 1.2
4114     @Attr:
4115     @@Name: localName
4116     @@enDesc:
4117     The local name of this resource.
4118     @@Type:
4119 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
4120 wakaba 1.2 @@Get:
4121     @@@nullCase:
4122     @@@@enDesc:
4123     This resource does not have its local name.
4124     @@@PerlDef:
4125     $r = $self->{localName};
4126    
4127     @Attr:
4128     @@Name: namespaceURI
4129     @@Type: AnyURI
4130     @@enDesc:
4131     The namespace URI of the name of this resource.
4132     @@Get:
4133     @@@nullCase:
4134     The name of this resource does not have its namespace
4135     or this resource does not have its name.
4136     @@@PerlDef:
4137     $r = $self->{namespaceURI};
4138    
4139     @Attr:
4140     @@Name: isAnonymous
4141     @@enDesc:
4142     Whether this <QUOTE::dis> resource has name or not.
4143     @@Type:
4144 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4145 wakaba 1.2 @@Get:
4146     @@@TrueCase:
4147     This resource does not have any global unique name.
4148     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
4149     @@@FalseCase:
4150     This resource does have its formal name.
4151     <A::ManakaiDISResourceDefinition.uri> is a URI reference
4152     generated from the name and the <QUOTE::for> URI reference
4153     of this resource.
4154     @@@PerlDef:
4155     $r = $self->{<Q::isAnon>};
4156    
4157     @Attr:
4158     @@Name: forURI
4159     @@enDesc:
4160     The <QUOTE::for> URI reference for which this resource is defined.
4161     @@Type:ForURI
4162     @@Get:
4163     @@@PerlDef:
4164     $r = $self->{for};
4165    
4166     @Attr:
4167     @@Name: forpURI
4168     @@enDesc:
4169     The <QUOTE::for+> URI references for which this resource is defined.
4170     @@Type: ForURIList
4171     @@Get:
4172 wakaba 1.15 @@@enDesc:
4173     List of <QUOTE::for> URI references. Note that this list is
4174     <QUOTE::dead>.
4175 wakaba 1.3 @@@PerlDef:
4176 wakaba 1.15 $r = [@{$self->{forp}}];
4177    
4178     @Method:
4179     @@Name: isForURI
4180     @@enDesc:
4181     Tests whether this resource is defined for a <QUOTE::for>
4182     or <QUOTE::for+> URI reference or not.
4183     @@Param:
4184     @@@Name:forURI
4185     @@@Type:ForURI
4186     @@@enDesc:
4187     A <QUOTE::for> URI reference to test.
4188     @@Return:
4189     @@@Type:
4190     DOMMain:boolean::ManakaiDOM:all
4191     @@@TrueCase:
4192     @@@@enDesc:
4193     This resource is for <P::forURI>.
4194     @@@FalseCase:
4195     @@@@enDesc:
4196     This resource is not for <P::forURI>.
4197     @@@PerlDef:
4198     __DEEP{
4199     for my $this_for_uri ($self->{for}, @{$self->{forp}}) {
4200     if ($this_for_uri eq $forURI) { ## Shortcut
4201     $r = true;
4202     last;
4203     }
4204     my $this_for = $self->{db}-><M::ManakaiDISDatabase.getFor>
4205     ($this_for_uri);
4206     if ($this_for-><M::ManakaiDISForDefinition.isaURI> ($forURI)) {
4207     $r = true;
4208     last;
4209     }
4210     }
4211     }__;
4212 wakaba 1.2
4213     @Method:
4214 wakaba 1.7 @@Name: isSubsetOfURI
4215 wakaba 1.2 @@Description:
4216     @@@lang:en
4217     @@@@:
4218     Whether this resource is a subset of another resource or not.
4219     @@Param:
4220     @@@Name: superURI
4221     @@@Type: ResourceURI
4222     @@@Description:
4223     @@@@lang:en
4224     @@@@@:
4225     Another resource URI reference to test.
4226     @@Return:
4227     @@@Type:
4228 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4229 wakaba 1.2 @@@TrueCase:
4230     @@@@enDesc:
4231     <P::superURI> is a super-resource of this resource.
4232     @@@FalseCase:
4233     @@@@enDesc:
4234     <P::superURI> is not a super-resource of this resource.
4235     @@@PerlDef:
4236 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
4237 wakaba 1.2
4238 wakaba 1.7 @Method:
4239     @@Name: addSuperResource
4240     @@enDesc:
4241     Adds a <QUOTE::dis> resource to the list of super-resource
4242     of this <QUOTE::dis> resource.
4243     @@Param:
4244     @@@Name: superRes
4245     @@@Type: ManakaiDISResourceDefinition
4246     @@@enDesc:
4247     A <QUOTE::dis> resource definition object.
4248     @@Return:
4249     @@@PerlDef:
4250     my @from = ($self->{uri},
4251     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
4252     my @to = ($superRes->{uri},
4253     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
4254     __DEEP{
4255     for my $from (@from) {
4256     for my $to (@to) {
4257     $self->{db}-><M::ManakaiDISDatabase.getResource>
4258     ($from)->{subOf}->{$to} = true;
4259     $self->{db}-><M::ManakaiDISDatabase.getResource>
4260     ($to)->{supOf}->{$from} = true;
4261     }
4262     }
4263     }__;
4264    
4265 wakaba 1.2 @Attr:
4266     @@Name: isDefined
4267     @@Description:
4268     @@@lang:en
4269     @@@@:
4270     Whether this resource is already defined or not.
4271     @@Type:
4272 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4273 wakaba 1.2 @@Get:
4274     @@@TrueCase:
4275     This resource is already defined.
4276     @@@FalseCase:
4277     This resource is not defined.
4278     @@@PerlDef:
4279     $r = $self->{<Q::isDefined>};
4280    
4281     @Attr:
4282     @@Name: isReferred
4283     @@Description:
4284     @@@lang:en
4285     @@@@:
4286     Whether this resource is referred or not.
4287 wakaba 1.7 @@Type: ManakaiDISElement
4288 wakaba 1.2 @@Get:
4289 wakaba 1.7 @@@enDesc:
4290 wakaba 1.9 An element that referres this resource.
4291 wakaba 1.2 @@@nullCase:
4292     This resource is not referred.
4293     @@@PerlDef:
4294     $r = $self->{<Q::isReferred>};
4295     @@Set:
4296 wakaba 1.7 @@@enDesc:
4297 wakaba 1.9 An element that referres this resource.
4298 wakaba 1.2 @@@PerlDef:
4299 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
4300 wakaba 1.2
4301     @Attr:
4302 wakaba 1.22 @@Name: ownerModule
4303     @@ManakaiDOM:isRedefining:1
4304 wakaba 1.2 @@Description:
4305     @@@lang:en
4306     @@@@:
4307     The <QUOTE::dis> module in which this resource is defined.
4308     @@Type: ManakaiDISModuleDefinition
4309     @@Get:
4310     @@@Description:
4311     @@@@lang:en
4312     @@@@@:
4313     The module object.
4314 wakaba 1.3 @@@nullCase:
4315 wakaba 1.2 @@@@Description:
4316     @@@@@lang:en
4317     @@@@@@:
4318     This resource is not associated to any module.
4319     @@@PerlDef:
4320     $r = $self->{db}
4321     -><M::ManakaiDISDatabase.getModule>
4322     ($self->{<Q::definingModule>})
4323     if defined $self->{<Q::definingModule>};
4324    
4325 wakaba 1.6 @Method:
4326     @@Name: mergeAsAlias
4327     @@enDesc:
4328     Merges another resource definition as an alias of this resource.
4329     @@Param:
4330     @@@Name: aliasResource
4331     @@@Type: ManakaiDISResourceDefinition
4332     @@@enDesc:
4333     A resource to merge.
4334     \
4335     {NOTE:: After merging all references to <P::aliasResource>
4336     should be discarded.
4337     \
4338     }
4339 wakaba 1.11 @@NodeParam:
4340 wakaba 1.6 @@Return:
4341 wakaba 1.11 @@@RaiseException:
4342     @@@@@:MERGE_ITSELF_ERR
4343     @@@@@@enDesc:
4344     An attempt is made to merge this resource itself.
4345     @@@PerlDef:
4346     if ($self eq $aliasResource) {
4347     __EXCEPTION{MERGE_ITSELF_ERR::
4348     DIS:uri => {$self->{uri}},
4349     DIS:sourceNode => {$node},
4350     }__;
4351     }
4352 wakaba 1.6 for my $uri ($aliasResource->{uri},
4353     grep {$aliasResource->{aliasURI}->{$_}}
4354     keys %{$aliasResource->{aliasURI}}) {
4355     $self->{aliasURI}->{$uri} = true;
4356     $self->{db}->{resDef}->{$uri} = $self;
4357     $self->{subOf}->{$uri} = true;
4358     $self->{supOf}->{$uri} = true;
4359     }
4360     for my $uri (grep {$aliasResource->{subOf}->{$_}}
4361     keys %{$aliasResource->{subOf}}) {
4362     $self->{subOf}->{$uri} = true;
4363     }
4364     for my $uri (grep {$aliasResource->{supOf}->{$_}}
4365     keys %{$aliasResource->{supOf}}) {
4366     $self->{supOf}->{$uri} = true;
4367     }
4368     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
4369     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
4370     __DEEP{
4371     for my $from (@from) {
4372     for my $to (@to) {
4373     $self->{db}-><M::ManakaiDISDatabase.getResource>
4374     ($from)->{subOf}->{$to} = true;
4375     $self->{db}-><M::ManakaiDISDatabase.getResource>
4376     ($to)->{supOf}->{$from} = true;
4377     }
4378     }
4379     }__;
4380 wakaba 1.7
4381     @Method:
4382     @@Name: isTypeURI
4383     @@enDesc:
4384     Tests whether this resource is of a type or not.
4385     @@Param:
4386     @@@Name: typeURI
4387     @@@Type: ResourceURI
4388     @@@enDesc:
4389     A type URI reference to test.
4390     @@Return:
4391     @@@Type:
4392 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4393 wakaba 1.7 @@@TrueCase:
4394     @@@@enDesc:
4395     This is a <P::typeURI> resource.
4396     @@@FalseCase:
4397     @@@@enDesc:
4398     This is not a <P::typeURI> resource.
4399     @@@PerlDef:
4400 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
4401     $r = $self->{<Q::rdf:type>}->{$typeURI};
4402     } else {
4403     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
4404     keys %{$self->{<Q::rdf:type>}}) {
4405     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
4406     ($t_type_uri);
4407     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4408     ($typeURI)) {
4409     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
4410     last;
4411     }
4412 wakaba 1.7 }
4413     }
4414 wakaba 1.8
4415     @Attr:
4416     @@Name: plName
4417     @@enDesc:
4418     The Perl name of this resource.
4419     @@Get:
4420     @@@Type:
4421 wakaba 1.18 DISLang:String::ManakaiDOM:all
4422 wakaba 1.8 @@@enDesc:
4423     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
4424     \
4425     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
4426     <CHAR::COLON> prefix).
4427     \
4428     - <Q::DISLang:Attribute>::: Method name.
4429     \
4430     - <Q::DISLang:Method>::: Method name.
4431     @@@nullCase:
4432     @@@@enDesc:
4433     Either the type of this resource is not listed above
4434     or this Perl constructure is anonymous.
4435     @@@RaiseException:
4436     @@@@@: NO_LOCAL_NAME_ERR
4437     @@@@enDesc:
4438     The type of this resource is either
4439     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
4440     the local name of this resource is not defined.
4441     @@@RaiseException:
4442     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
4443     @@@@enDesc:
4444     The Perl method name constructed from the source
4445     result in a reserved name.
4446     @@@PerlDef:
4447     __DEEP{
4448     if (exists $self->{<Q::dis2pm:name>}) {
4449     $r = $self->{<Q::dis2pm:name>};
4450     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4451     (<Q::ManakaiDOM:Const>) or
4452     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4453     (<Q::ManakaiDOM:ConstGroup>)) {
4454 wakaba 1.21 $r = uc $self->{localName};
4455 wakaba 1.8 unless (defined $r) {
4456     __UNDEEP{
4457     __EXCEPTION{NO_LOCAL_NAME_ERR::
4458 wakaba 1.18 DIS:uri => {$self->{uri}},
4459 wakaba 1.8 DIS:sourceNode => {$self->{src}},
4460     }__;
4461     }__;
4462     }
4463 wakaba 1.21 if ($r =~ /^_/ or $r =~ /_$/) {
4464     __UNDEEP{
4465     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4466     DIS:uri => {$self->{uri}},
4467     DIS:localName => {$self->{localName}},
4468     DIS:soruceNode => {$self->{src}},
4469     DIS:generatedName => {$r},
4470     }__;
4471     }__;
4472     }
4473 wakaba 1.8 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4474     (<Q::DISLang:Method>) or
4475     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4476     (<Q::DISLang:Attribute>)) {
4477     if (defined $self->{localName}) {
4478     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
4479     ($self->{localName});
4480     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4481     (<Q::ManakaiDOM:isForInternal>, false)) {
4482     $r = '_' . $r;
4483     }
4484     if ({
4485     import => 1,
4486     unimport => 1,
4487     isa => 1,
4488     can => 1,
4489     new => 1,
4490     as_string => 1,
4491     stringify => 1,
4492     clone => 1,
4493     }->{$r} or $r =~ /^___/) {
4494     __UNDEEP{
4495     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4496     DIS:uri => {$self->{uri}},
4497     DIS:soruceNode => {$self->{src}},
4498     DIS:generatedName => {$r},
4499     }__;
4500     }__;
4501 wakaba 1.11 }
4502     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
4503 wakaba 1.8 .plMethodOperator>) {
4504     $r = {
4505     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
4506     <Q::DISPerl:AsStringMethod> => 'as_string',
4507 wakaba 1.16 <Q::DISPerl:NewMethod> => 'new',
4508     <Q::DISPerl:CloneMethod> => 'clone',
4509 wakaba 1.8 }->{$op_uri};
4510     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
4511     } else {
4512     $r = null;
4513     }
4514     } else {
4515     $r = null;
4516     }
4517     $self->{<Q::dis2pm:name>} = $r;
4518     }__;
4519    
4520     @Attr:
4521     @@Name: plFullyQualifiedName
4522     @@enDesc:
4523     The fully-qualified Perl name of this resource.
4524     @@Type:
4525     DISLang:String::ManakaiDOM:all
4526     @@Get:
4527     @@@enDesc:
4528     Fully-qualified name.
4529     \
4530     - <Q::ManakaiDOM:Class>::: Class package name.
4531     \
4532     - <Q::ManakaiDOM:IF>::: Interface package name.
4533     \
4534     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
4535     type symbol such as <CODE::$>).
4536     @@@nullCase:
4537     @@@@enDesc:
4538     Otherwise.
4539     @@@NoPerlModuleNameException:
4540     @@@RaiseException:
4541     @@@@@: NO_LOCAL_NAME_ERR
4542     @@@@enDesc:
4543     The local name of this resource is not defined.
4544     @@@PerlDef:
4545     __DEEP{
4546     if (exists $self->{<Q::dis2pm:name>}) {
4547     $r = $self->{<Q::dis2pm:name>};
4548     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4549     (<Q::ManakaiDOM:Class>) or
4550     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4551     (<Q::ManakaiDOM:IF>) or
4552     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4553     (<Q::DISPerl:ScalarVariable>)) {
4554 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4555 wakaba 1.8 (<Q::dis:AppName>, for_arg => $self->{for},
4556     forp_arg => $self->{forp},
4557     media_type => <Q::lang:Perl>);
4558     if ($an_node) {
4559     ## NOTE: "lang:Perl" is fully-qualified name by definition
4560 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4561 wakaba 1.8 } else {
4562 wakaba 1.10 unless (defined $self->{localName}) {
4563     __UNDEEP{
4564     __EXCEPTION{NO_LOCAL_NAME_ERR::
4565     DIS:sourceNode => {$self->{src}},
4566     }__;
4567     }__;
4568     }
4569 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4570     (<Q::ManakaiDOM:IF>)) {
4571 wakaba 1.22 $r = $self-><AG::ManakaiDISResourceDefinition.ownerModule>
4572 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
4573 wakaba 1.8 . '::' . $self->{localName};
4574     } else {
4575 wakaba 1.22 $r = $self-><AG::ManakaiDISResourceDefinition.ownerModule>
4576 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
4577 wakaba 1.8 . '::' . $self->{localName};
4578     }
4579     }
4580     } else {
4581     $r = null;
4582     }
4583     $self->{<Q::dis2pm:name>} = $r;
4584     }__;
4585    
4586     @Attr:
4587 wakaba 1.15 @@Name: plVariableName
4588     @@enDesc:
4589     The Perl variable name with prefix.
4590     @@Type:
4591     lang:Perl::ManakaiDOM:all
4592     @@Get:
4593     @@@nullCase:
4594     @@@@enDesc:
4595     This resource does not define any Perl variable.
4596     @@@PerlDef:
4597 wakaba 1.23 my $pnm_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4598     (<Q::dis:AppName>,
4599     for_arg => $self->{for},
4600     forp_arg => $self->{forp},
4601     media_type => <Q::lang:Perl>,
4602     default_media_type => <Q::lang:Perl>);
4603     $r = $pnm_node ? $pnm_node-><M::SWCFGNode.value> : $self->{localName};
4604 wakaba 1.15 if (defined $r) {
4605     __DEEP{
4606 wakaba 1.18 if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4607     (<Q::DISPerl:isNamedParameter>, false)) {
4608     $r = '$opt{' .
4609 wakaba 1.21 <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
4610     ($r) .
4611 wakaba 1.18 '}';
4612 wakaba 1.22 } else {
4613     my $dt = $self-><AG::ManakaiDISResourceDefinition
4614     .disActualDataTypeResource>;
4615     if ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4616 wakaba 1.18 (<Q::Perl:Array>)) {
4617 wakaba 1.22 $r = '@' . $r;
4618     } elsif ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4619 wakaba 1.18 (<Q::Perl:Hash>)) {
4620 wakaba 1.22 $r = '%' . $r;
4621     } else {
4622     $r = '$' . $r;
4623     }
4624 wakaba 1.18 }
4625     }__;
4626     }
4627    
4628     @Attr:
4629     @@Name: plPrototype
4630     @@enDesc:
4631     The Perl parameter prototype character.
4632     @@Type:
4633     lang:Perl::ManakaiDOM:all
4634     @@Get:
4635     @@@PerlDef:
4636     __DEEP{
4637 wakaba 1.22 my $dt = $self-><AG::ManakaiDISResourceDefinition
4638     .disActualDataTypeResource>;
4639     if ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4640 wakaba 1.15 (<Q::Perl:Array>)) {
4641     $r = '@' . $r;
4642 wakaba 1.22 } elsif ($dt-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4643 wakaba 1.15 (<Q::Perl:Hash>)) {
4644     $r = '%' . $r;
4645     } else {
4646     $r = '$' . $r;
4647     }
4648     }__;
4649    
4650     @Attr:
4651 wakaba 1.8 @@Name: plMethodOperator
4652     @@enDesc:
4653     The operator to overload by this method.
4654     @@Type:
4655     DISLang:String::ManakaiDOM:all
4656     @@Get:
4657     @@@enDesc:
4658     The operator, either Perl <CODE::use operator> operator name
4659     of manakai operator URI reference.
4660     @@@nullCase:
4661     @@@@enDesc:
4662     Either this resource does not define a Perl method or
4663     this method does not overload any operator.
4664     @@@UndeclaredPrefixException:
4665     @@@RaiseException:
4666     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
4667     @@@@enDesc:
4668     Media type of the <Q::dis:Operator> node is not supported.
4669     @@@PerlDef:
4670     __DEEP{
4671     if (exists $self->{<Q::dis:Operator>}) {
4672     $r = $self->{<Q::dis:Operator>};
4673     } else {
4674     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4675     (<Q::dis:Operator>, for_arg => $self->{for},
4676     forp_arg => $self->{forp});
4677     if ($op_node) {
4678     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
4679 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
4680     for_arg => $self->{forp})) {
4681 wakaba 1.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4682 wakaba 1.8 } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
4683 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
4684     for_arg => $self->{forp})) {
4685 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
4686     } else {
4687 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
4688     (for_arg => $self->{for},
4689     forp_arg => $self->{forp});
4690 wakaba 1.8 __UNDEEP{
4691     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4692     DIS:uri => {$ct_uri},
4693 wakaba 1.10 DIS:sourceNode => {$op_node},
4694 wakaba 1.8 }__;
4695     }__;
4696     }
4697     } else {
4698     $r = null;
4699     }
4700     $self->{<Q::dis:Operator>} = $r;
4701     }
4702     }__;
4703    
4704     @Attr:
4705     @@Name: disDataTypeResource
4706     @@enDesc:
4707     <Q::dis:Type> attribute value of this resource.
4708     @@Type: ManakaiDISResourceDefinition
4709     @@Get:
4710     @@@RaiseException:
4711     @@@@@:NO_DIS_TYPE_ERR
4712     @@@@enDesc:
4713     <Q::dis:Type> attribute is not specified.
4714     @@@PerlDef:
4715     __DEEP{
4716     if (defined $self->{<Q::dis:Type>}) {
4717 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4718     ($self->{<Q::dis:Type>});
4719 wakaba 1.8 } else {
4720     $self->{<Q::dis2pm:TypeNode>}
4721     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4722     (<Q::dis:Type>, for_arg => $self->{for},
4723     forp_arg => $self->{forp});
4724     if ($self->{<Q::dis2pm:TypeNode>}) {
4725     $r = $self->{<Q::dis:Type>}
4726     = $self->{<Q::dis2pm:TypeNode>}
4727 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4728     (null, $self->{for});
4729     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4730     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4731     ($self->{<Q::dis2pm:TypeNode>});
4732 wakaba 1.8 } else {
4733     my $pr = $self-><M::ManakaiDISPropertyAccessor
4734     .getPropertyResource>
4735     (<Q::DIS:dynamicParentResource>);
4736     if ($pr) {
4737     $r = $pr-><AG::ManakaiDISResourceDefinition
4738     .disDataTypeResource>;
4739     $self->{<Q::dis2pm:TypeNode>}
4740     = $pr->{<Q::dis2pm:TypeNode>};
4741 wakaba 1.18 $self->{<Q::dis:Type>}
4742     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4743 wakaba 1.8 } else { ## No parent
4744     __UNDEEP{
4745     __EXCEPTION{NO_DIS_TYPE_ERR::
4746     DIS:sourceNode => {$self->{src}},
4747     }__;
4748     }__;
4749     }
4750     }
4751     }
4752     }__;
4753    
4754     @Attr:
4755     @@Name: disDataTypeNode
4756     @@enDesc:
4757     <Q::dis:Type> node for this resource.
4758     @@Get:
4759     @@@Type: ManakaiDISElement
4760     @@@RaiseException:
4761     @@@@@:NO_DIS_TYPE_ERR
4762     @@@@enDesc:
4763     <Q::dis:Type> attribute is not specified.
4764     @@@PerlDef:
4765     __DEEP{
4766 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disDataTypeResource>;
4767 wakaba 1.8 }__;
4768     $r = $self->{<Q::dis2pm:TypeNode>};
4769    
4770     @Attr:
4771     @@Name: disActualDataTypeResource
4772     @@enDesc:
4773     <Q::dis:actualType> attribute value of this resource.
4774     @@Type: ManakaiDISResourceDefinition
4775     @@Get:
4776     @@@RaiseException:
4777     @@@@@:NO_DIS_TYPE_ERR
4778     @@@@enDesc:
4779     <Q::dis:actualType> attribute is not specified,
4780     and <Q::dis:Type> attribute, neigher.
4781     @@@PerlDef:
4782     __DEEP{
4783     if (defined $self->{<Q::dis:actualType>}) {
4784 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4785     ($self->{<Q::dis:actualType>});
4786 wakaba 1.8 } else {
4787     $self->{<Q::dis2pm:actualTypeNode>}
4788     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4789     (<Q::dis:actualType>, for_arg => $self->{for},
4790     forp_arg => $self->{forp});
4791     if ($self->{<Q::dis2pm:actualTypeNode>}) {
4792     $r = $self->{<Q::dis:actualType>}
4793     = $self->{<Q::dis2pm:actualTypeNode>}
4794 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4795     (null, $self->{for});
4796     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4797     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4798     ($self->{<Q::dis2pm:actualTypeNode>});
4799 wakaba 1.8 } elsif (defined $self->{<Q::dis:Type>}) {
4800     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
4801     $self->{<Q::dis2pm:actualTypeNode>}
4802     = $self->{<Q::dis2pm:TypeNode>};
4803 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4804 wakaba 1.8 } else {
4805     $self->{<Q::dis2pm:actualTypeNode>}
4806     = $self->{<Q::dis2pm:TypeNode>}
4807     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4808     (<Q::dis:Type>, for_arg => $self->{for},
4809     forp_arg => $self->{forp});
4810     if ($self->{<Q::dis2pm:TypeNode>}) {
4811     $r = $self->{<Q::dis:actualType>}
4812     = $self->{<Q::dis:Type>}
4813     = $self->{<Q::dis2pm:TypeNode>}
4814 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4815     (null, $self->{for});
4816     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4817     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4818     ($self->{<Q::dis2pm:actualTypeNode>});
4819 wakaba 1.8 } else {
4820     my $pr = $self-><M::ManakaiDISPropertyAccessor
4821     .getPropertyResource>
4822     (<Q::DIS:dynamicParentResource>);
4823     if ($pr) {
4824 wakaba 1.18 $r = $pr-><AG::ManakaiDISResourceDefinition
4825 wakaba 1.8 .disActualDataTypeResource>;
4826     $self->{<Q::dis2pm:actualTypeNode>}
4827     = $pr->{<Q::dis2pm:actualTypeNode>};
4828 wakaba 1.18 $self->{<Q::dis:actualType>}
4829     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4830 wakaba 1.8 } else { ## No parent
4831     __UNDEEP{
4832     __EXCEPTION{NO_DIS_TYPE_ERR::
4833     DIS:sourceNode => {$self->{src}},
4834     }__;
4835     }__;
4836     }
4837     }
4838     }
4839     }
4840     }__;
4841    
4842     @Attr:
4843     @@Name: disActualDataTypeNode
4844     @@enDesc:
4845     <Q::dis:actualType> node for this resource.
4846     @@Get:
4847     @@@Type: ManakaiDISElement
4848     @@@RaiseException:
4849     @@@@@:NO_DIS_TYPE_ERR
4850     @@@@enDesc:
4851     <Q::dis:actualType> attribute is not specified,
4852     and <Q::dis:Type> attribute, neigher.
4853     @@@PerlDef:
4854     __DEEP{
4855 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeResource>;
4856 wakaba 1.8 }__;
4857     $r = $self->{<Q::dis2pm:actualTypeNode>};
4858 wakaba 1.9
4859     @IntMethod:
4860     @@Operator:
4861     @@@@: <=>
4862     @@@ContentType:
4863     lang:Perl
4864     @@enDesc:
4865     Which is greater (i.e. the spaceship operator).
4866     A resource is less than another if it is loaded by
4867     <M::ManakaiDISDatabase.loadResource> before another is loaded.
4868     Order for non-loaded resource definitions are not defined.
4869     \
4870     {NOTE:: In the current implementation, non-loaded resources
4871     are less than any loaded resource and the order in
4872     non-loaded resources is unknown.
4873     \
4874     }
4875     @@Param:
4876     @@@Name: anotherResource
4877     @@@Type: ManakaiDISResourceDefinition
4878     @@@enDesc: Another resource to compare.
4879     @@Return:
4880     @@@Type:
4881 wakaba 1.18 DOMMain:unsigned-long::ManakaiDOM:all
4882 wakaba 1.9 @@@PerlDef:
4883     if (UNIVERSAL::isa ($anotherResource,
4884     <ClassName::ManakaiDISResourceDefinition>)) {
4885     $r = $self->{seq} <=> $anotherResource->{seq};
4886     } else {
4887     $r = overload::Overloaded ($self) <=> $anotherResource;
4888     }
4889 wakaba 1.12
4890     @Attr:
4891     @@Name: plCodeFragment
4892     @@enDesc:
4893     Perl code definition fragment of this resource.
4894     @@Type: MPLCodeFragment
4895     @@Get:
4896     @@@enDesc:
4897     Perl code.
4898     @@@nullCase:
4899     @@@@enDesc:
4900     This node does not have Perl code definition.
4901     @@@RaiseException:
4902     @@@@@:NO_METHOD_RETURN_ERR
4903     @@@@enDesc:
4904     This resource is a <Q::DISLang:Method> but it does not
4905     have <Q::DISLang:MethodReturn> child-resource.
4906     @@@RaiseException:
4907     @@@@@:NO_ATTR_GET_ERR
4908     @@@@enDesc:
4909     This resource is a <Q::DISLang:Attribute> but it does not
4910     have <Q::DISLang:AttributeGet> child-resource.
4911     @@@RaiseException:
4912     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4913     @@@@enDesc:
4914     The media type of <Q::dis:Def> element is not supported.
4915 wakaba 1.18 @@@RaiseException:
4916     @@@@@: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
4917     @@@@enDesc:
4918     A non-named method paarameter is defined after
4919     a named method parameter appeared.
4920 wakaba 1.19 @@@disPerlException:
4921     @@@InlineElementException:
4922     @@@BlockElementException:
4923 wakaba 1.20 @@@RaiseException:
4924     @@@@@:PERL_SUBROUTINE_ALREADY_DEFINED_ERR
4925     @@@@enDesc:
4926     A resource defines a Perl subroutine whose name is
4927     same as the name of another subroutine.
4928     @@@RaiseException:
4929     @@@@@:PERL_OPERATOR_ALREADY_OVERLOADED_ERR
4930     @@@@enDesc:
4931     A resource is defined to overload an operator
4932     that is also defined to be overloaded by another resource.
4933     @@@RaiseException:
4934     @@@@@:PERL_UNUSED_SUBROUTINE_ERR
4935     @@@@enDesc:
4936     A resource defines a Perl subroutine which is not
4937     used anywhere.
4938 wakaba 1.12 @@@PerlDef:
4939     __DEEP{
4940     if (exists $self->{<Q::plCodeFragment>}) {
4941     $r = $self->{<Q::plCodeFragment>};
4942     } elsif (not $self->{src}) {
4943     $r = $self->{<Q::plCodeFragment>} = null;
4944     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4945     (<Q::DISLang:MethodReturn>) or
4946     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4947     (<Q::DISLang:AttributeGet>) or
4948     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4949 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
4950     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4951     (<Q::dis2pm:BlockCode>) or
4952     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4953 wakaba 1.18 (<Q::dis2pm:InlineCode>) or
4954     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4955     (<Q::DISLang:InputProcessor>)) {
4956 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4957 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4958     (<Q::dis:Def>, for_arg => $self->{for},
4959     forp_arg => $self->{forp});
4960 wakaba 1.19 my $is_inline = $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4961     (<Q::dis2pm:InlineCode>) ? true : false;
4962     unless ($def) {
4963     $r = null;
4964     } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4965     (<Q::lang:Perl>)) {
4966 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
4967     ::swcfg21:ForLatest.value>;
4968 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4969 wakaba 1.19 = $is_inline
4970     ? $self-><M::ManakaiDISResourceDefinition
4971     .plPreprocessPerlStatement>
4972     ($source_code,
4973     node => $def,
4974     contains_statements => false)
4975     : $self-><M::ManakaiDISResourceDefinition
4976 wakaba 1.17 .plPreprocessPerlCode> ($source_code,
4977     node => $def);
4978 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4979     (<Q::lang:dis>)) {
4980     $r = $self->{<Q::plCodeFragment>}
4981 wakaba 1.19 = $def-><M::ManakaiDISElement.plCodeFragment>
4982     ($self, for_arg => $self->{for},
4983     forp_arg => $self->{forp},
4984     contains_statements => not $is_inline);
4985 wakaba 1.12 } else {
4986     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
4987     (for_arg => $self->{for},
4988     forp_arg => $self->{forp});
4989     __UNDEEP{
4990     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4991     DIS:uri => {$mt},
4992     DIS:sourceNode => {$def},
4993     }__;
4994     }__;
4995     } # media type
4996     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4997     (<Q::DISLang:Method>)) {
4998 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4999 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
5000     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
5001     unless ($ret) {
5002     __UNDEEP{
5003     __EXCEPTION{NO_METHOD_RETURN_ERR::
5004     DIS:errResource => {$self},
5005     DIS:sourceNode => {$self->{src}},
5006 wakaba 1.22 DIS:uri => {$self->{uri}},
5007     DIS:localName => {$self->{localName}},
5008 wakaba 1.12 }__;
5009     }__;
5010     }
5011 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5012 wakaba 1.18 .plImplementation>;
5013 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5014 wakaba 1.18 = $plimpl-><M::MPLImpl.createPerlSub>
5015 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
5016    
5017 wakaba 1.18 ## Method parameters
5018     my $params = $self-><M::ManakaiDISPropertyAccessor
5019     .getPropertyResourceList>
5020     (<Q::DIS:childResource>);
5021     my @param_variables;
5022     my @named_param_variables;
5023     my $prototype = '$';
5024     my $is_optional_param = false;
5025     my $is_named_param = false;
5026     for my $param (@$params) {
5027     next unless $param-><M::ManakaiDISResourceDefinition.isTypeURI>
5028     (<Q::DISLang:MethodParameter>);
5029     unless ($is_named_param) {
5030     if ($param-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
5031     (<Q::DISPerl:isNamedParameter>, false)) {
5032     $is_named_param = true;
5033     $is_optional_param = true;
5034     push @param_variables, ['%opt'];
5035     $prototype .= '%';
5036     } else { ## Non-named parameter
5037     push @param_variables, [
5038     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
5039     ];
5040     if ($param-><AG::ManakaiDISResourceDefinition.plIsNullable>) {
5041     $prototype .= ';' unless $is_optional_param;
5042     $is_optional_param = true;
5043     }
5044     $prototype .= $param-><AG::ManakaiDISResourceDefinition
5045     .plPrototype>;
5046     my $param_processor
5047     = $param-><M::ManakaiDISResourceDefinition
5048     .plGetMethodInputNormalizer>;
5049     if ($param_processor) {
5050     $param_variables[-1]->[1]
5051     = $param_processor-><AG::ManakaiDISResourceDefinition
5052     .plCodeFragment>->clone;
5053     $param_variables[-1]->[1]
5054     -><M::MPLCodeFragment.replaceVariable>
5055     ('$INPUT' => $param_variables[-1]->[0]);
5056     }
5057     }
5058     } else { ## Named parameter
5059     unless ($param-><M::ManakaiDISPropertyAccessor
5060     .getPropertyBoolean>
5061     (<Q::DISPerl:isNamedParameter>, false)) {
5062     __UNDEEP{__EXCEPTION{NON_NAMED_PARAMETER_AFTER_NAMED_ERR::
5063     DIS:sourceNode => {$param->{src}},
5064     DIS:uri => {$param->{uri}},
5065     DIS:localName => {$param->{localName}},
5066     }__}__;
5067     }
5068     }
5069     if ($is_named_param) {
5070     push @named_param_variables, [
5071     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
5072     null,
5073     '$' . $param-><AG::ManakaiDISResourceDefinition.localName>,
5074     ];
5075     my $param_processor
5076     = $param-><M::ManakaiDISResourceDefinition
5077     .plGetMethodInputNormalizer>;
5078     if ($param_processor) {
5079     $named_param_variables[-1]->[1]
5080     = $param_processor-><AG::ManakaiDISResourceDefinition
5081     .plCodeFragment>->clone;
5082     $named_param_variables[-1]->[1]
5083     -><M::MPLCodeFragment.replaceVariable>
5084     ('$INPUT' => $param_variables[-1]->[0]);
5085     }
5086     }
5087     } # %$params
5088    
5089     $r-><AS::MPLSub.prototype> ($prototype);
5090 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
5091 wakaba 1.18 ($plimpl-><M::MPLImpl.createPerlStatement>
5092     ('my (' . join (', ', '$self',
5093     map {$_->[0]} @param_variables) . ') = @_'));
5094     for my $p (@param_variables, @named_param_variables) {
5095     if ($p->[1]) { ## Input processor
5096     $r-><M::MPLSS.appendCodeFragment> ($p->[1]);
5097     }
5098     }
5099    
5100     ## TODO: in/out
5101    
5102     ## Return value
5103     my $data_type;
5104     try {
5105     $data_type = $ret-><AG::ManakaiDISResourceDefinition
5106     .disActualDataTypeResource>;
5107     } catch <Class::ManakaiDISException> with {
5108     my $err = shift;
5109     if ($err->{<Q::MDOMX:subtype>} ne <Q::NO_DIS_TYPE_ERR>) {
5110     $err->throw;
5111     }
5112     };
5113    
5114     if ($data_type) {
5115     my $def = $ret->{src}-><M::ManakaiDISElement
5116     .plValueCodeFragment>
5117 wakaba 1.23 (<Q::dis:DefaultValue>, $self,
5118 wakaba 1.18 for_arg => $self->{for},
5119     forp_arg => $self->{forp},
5120     use_default_value => true,
5121     data_type_uri => $data_type
5122     -><AG::ManakaiDISResourceDefinition.uri>);
5123     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
5124     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
5125     ('$', null, 'r');
5126     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5127     .variableScope> ('my');
5128     if ($def) {
5129     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
5130     } else {
5131     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
5132     }
5133     $r-><M::MPLSS.appendCodeFragment> ($rs);
5134     }
5135    
5136     my $code = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5137 wakaba 1.19 if ($code) {
5138     for my $np (@named_param_variables) {
5139     $code-><M::MPLCodeFragment.replaceVariable>
5140     ($np->[2] => $np->[0]);
5141     }
5142     $r-><M::MPLSS.appendCodeFragment> ($code);
5143    
5144     $ret->{<Q::DIS:plDefined>} = true;
5145     $self->{<Q::DIS:plDefined>} = true;
5146 wakaba 1.21 } else { ## Method code not defined
5147 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5148     (<Q::DOMException:CoreException>,
5149     for_arg => <Q::ManakaiDOM:Perl>);
5150     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5151     (<Q::DOMException:NOT_SUPPROTED_ERR>,
5152     for_arg => <Q::ManakaiDOM:Perl>);
5153     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5154     (<Q::MDOMX:MDOM_IMPL_METHOD_NOT_IMPLEMENTED>,
5155     for_arg => <Q::ManakaiDOM:Perl>);
5156     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5157     ($ret->{src}) for $cls, $const, $subtype;
5158     my $context_param = $ret-><M::ManakaiDISResourceDefinition
5159     .plGetContextParameter>;
5160     $self-><M::ManakaiDISResourceDefinition
5161     .plAppendThrow>
5162     ($r, $cls, $const, $subtype,
5163     {%$context_param});
5164     $ret->{<Q::DIS:plDefined>} = false;
5165     $self->{<Q::DIS:plDefined>} = false;
5166 wakaba 1.18 }
5167 wakaba 1.12
5168 wakaba 1.18 if ($data_type) {
5169     $r-><M::MPLSS.appendCodeFragment>
5170     ($plimpl-><M::MPLImpl.createPerlVariable>
5171     ('$', null, 'r'));
5172     }
5173 wakaba 1.12 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5174     (<Q::DISLang:Attribute>)) {
5175 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
5176 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
5177     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
5178     unless ($get) {
5179     __UNDEEP{
5180     __EXCEPTION{NO_ATTR_GET_ERR::
5181     DIS:errResource => {$self},
5182     DIS:sourceNode => {$self->{src}},
5183     }__;
5184     }__;
5185     }
5186 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5187 wakaba 1.20 .plImplementation>;
5188 wakaba 1.19 my $data_type = $get-><AG::ManakaiDISResourceDefinition
5189     .disActualDataTypeResource>;
5190     my $get_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5191 wakaba 1.21 $get_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5192 wakaba 1.19 my $code = $get-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5193     if ($code) {
5194     ## Default value
5195     my $def = $get->{src}-><M::ManakaiDISElement
5196     .plValueCodeFragment>
5197 wakaba 1.23 (<Q::dis:DefaultValue>, $self,
5198 wakaba 1.19 for_arg => $self->{for},
5199     forp_arg => $self->{forp},
5200     use_default_value => true,
5201     data_type_uri => $data_type
5202     -><AG::ManakaiDISResourceDefinition.uri>);
5203     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
5204     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
5205     ('$', null, 'r');
5206     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5207     .variableScope> ('my');
5208     if ($def) {
5209     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
5210     } else {
5211     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
5212     }
5213     $get_code-><M::PLBlockCon.appendCodeFragment> ($rs);
5214    
5215     ## Main code
5216     $get_code-><M::PLBlockCon.appendCodeFragment> ($code);
5217    
5218     ## Return value
5219     $get_code-><M::PLBlockCon.appendStatement> (q<$r>);
5220    
5221     $get->{<Q::DIS:plDefined>} = true;
5222     } else { ## Getter code not defined
5223     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5224     (<Q::DOMException:CoreException>,
5225     for_arg => <Q::ManakaiDOM:Perl>);
5226     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5227     (<Q::DOMException:NOT_SUPPROTED_ERR>,
5228     for_arg => <Q::ManakaiDOM:Perl>);
5229     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5230     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
5231     for_arg => <Q::ManakaiDOM:Perl>);
5232     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5233     ($get->{src}) for $cls, $const, $subtype;
5234     my $context_param = $get-><M::ManakaiDISResourceDefinition
5235     .plGetContextParameter>;
5236     $self-><M::ManakaiDISResourceDefinition
5237     .plAppendThrow>
5238     ($get_code, $cls, $const, $subtype,
5239     {%$context_param});
5240     $get->{<Q::DIS:plDefined>} = false;
5241     $self->{<Q::DIS:plDefined>} = false;
5242     }
5243    
5244     my $set = $self-><M::ManakaiDISResourceDefinition
5245     .getChildResourceByType> (<Q::DISLang:AttributeSet>);
5246     my $set_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5247     if ($set) {
5248     my $data_type = $set-><AG::ManakaiDISResourceDefinition
5249     .disActualDataTypeResource>;
5250     my $code = $set-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5251     if ($code) {
5252     ## Input
5253     $set_code-><M::PLBlockCon.appendStatement>
5254     (q<my ($self, $given) = @_>);
5255     my $param_processor
5256     = $set-><M::ManakaiDISResourceDefinition
5257     .plGetMethodInputNormalizer>;
5258     if ($param_processor) {
5259     my $pcode = $param_processor-><AG::ManakaiDISResourceDefinition
5260     .plCodeFragment>->clone;
5261     $pcode-><M::MPLCodeFragment.replaceVariable>
5262     ('$INPUT' => '$given');
5263     $set_code-><M::PLBlockCon.appendCodeFragment> ($pcode);
5264     }
5265    
5266     ## Main code
5267     $set_code-><M::PLBlockCon.appendCodeFragment> ($code);
5268    
5269     $set->{<Q::DIS:plDefined>} = true;
5270     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
5271     } else { ## Setter code not defined
5272 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5273 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5274     (<Q::DOMException:CoreException>,
5275     for_arg => <Q::ManakaiDOM:Perl>);
5276     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5277     (<Q::DOMException:NOT_SUPPROTED_ERR>,
5278     for_arg => <Q::ManakaiDOM:Perl>);
5279     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5280     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
5281     for_arg => <Q::ManakaiDOM:Perl>);
5282     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5283     ($set->{src}) for $cls, $const, $subtype;
5284     my $context_param = $get-><M::ManakaiDISResourceDefinition
5285     .plGetContextParameter>;
5286     $self-><M::ManakaiDISResourceDefinition
5287     .plAppendThrow>
5288     ($set_code, $cls, $const, $subtype,
5289     {%$context_param});
5290     }
5291     $set->{<Q::DIS:plDefined>} = false;
5292     $self->{<Q::DIS:plDefined>} = false;
5293     } else { ## No attribute setter
5294 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
5295 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5296     (<Q::DOMException:CoreException>,
5297     for_arg => <Q::ManakaiDOM:Perl>);
5298     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5299     (<Q::DOMException:NO_MODIFICATION_ALLOWED_ERR>,
5300     for_arg => <Q::ManakaiDOM:Perl>);
5301     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5302     (<Q::DOMException:READ_ONLY_ATTRIBUTE_ERR>,
5303     for_arg => <Q::ManakaiDOM:Perl>);
5304     $_-><AS::ManakaiDISResourceDefinition.isReferred>
5305     ($self->{src}) for $cls, $const, $subtype;
5306     my $context_param = $get-><M::ManakaiDISResourceDefinition
5307     .plGetContextParameter>;
5308     $self-><M::ManakaiDISResourceDefinition
5309     .plAppendThrow>
5310     ($set_code, $cls, $const, $subtype,
5311     {%$context_param});
5312     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
5313     }
5314    
5315 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
5316 wakaba 1.19 = $plimpl-><M::MPLImpl.createPerlSub>
5317 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
5318 wakaba 1.19 $r-><AS::MPLSub.prototype> (q<$;$>);
5319 wakaba 1.12
5320 wakaba 1.19 ## TODO: Don't output "if" if non-debug build
5321 wakaba 1.12
5322 wakaba 1.19 $r-><M::PLBlockCon.appendNewIf>
5323     ($plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
5324     (q<@_ == 1>),
5325     $get_code,
5326     $set_code);
5327 wakaba 1.25
5328     ## -- Constants
5329 wakaba 1.20 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5330 wakaba 1.21 (<Q::ManakaiDOM:Const>)) {
5331     my $data_type = $self-><AG::ManakaiDISResourceDefinition
5332     .disActualDataTypeResource>;
5333     my $value = $self->{src}
5334     -><M::ManakaiDISElement.plValueCodeFragment>
5335 wakaba 1.23 (<Q::dis:Value>, $self,
5336 wakaba 1.21 for_arg => $self->{for},
5337     forp_arg => $self->{forp},
5338     data_type_uri => $data_type
5339     -><AG::ManakaiDISResourceDefinition.uri>);
5340 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5341 wakaba 1.21 .plImplementation>;
5342     $r = $plimpl-><M::MPLImpl.createPerlSub>
5343     ($self-><AG::ManakaiDISResourceDefinition.plName>);
5344     $r-><M::PLBlockCon.appendCodeFragment> ($value);
5345     $r-><AS::MPLSub.prototype> ('');
5346 wakaba 1.25
5347     ## -- Classes
5348 wakaba 1.21 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5349 wakaba 1.20 (<Q::ManakaiDOM:Class>)) {
5350 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5351 wakaba 1.20 .plImplementation>;
5352     $r = $plimpl-><M::MPLImpl.createPerlPackage>
5353     ($self-><AG::ManakaiDISResourceDefinition
5354     .plFullyQualifiedName>);
5355 wakaba 1.25 ## - Inheritance
5356 wakaba 1.20 for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5357     .getPropertyResourceList>
5358     (<Q::dis:ISA>,
5359     default_media_type => <Q::dis:TFQNames>)}) {
5360     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5361     .plFullyQualifiedName>;
5362     if (defined $spack_name) {
5363     $r-><M::PLPack.addISAPackage> ($spack_name);
5364     }
5365 wakaba 1.22 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
5366     ($scls => $r);
5367 wakaba 1.20 }
5368 wakaba 1.25
5369     ## - Implementing interfaces
5370 wakaba 1.20 for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5371     .getPropertyResourceList>
5372     (<Q::dis:Implement>, recursive_isa => true,
5373     default_media_type => <Q::dis:TFQNames>)}) {
5374     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5375     .plFullyQualifiedName>;
5376     if (defined $spack_name) {
5377     $r-><M::PLPack.addImplementPackage> ($spack_name);
5378     }
5379     }
5380    
5381 wakaba 1.25 ## - Class members
5382 wakaba 1.20 my @cr = @{$self-><M::ManakaiDISPropertyAccessor
5383     .getPropertyResourceList>
5384     (<Q::DIS:childResource>)};
5385 wakaba 1.21 my @const;
5386 wakaba 1.20 for my $cr (@cr) {
5387 wakaba 1.25 ## - Subroutines
5388 wakaba 1.20 if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5389     (<Q::DISLang:Method>) or
5390     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5391     (<Q::DISLang:Attribute>)) {
5392     my $is_attr = $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5393     (<Q::DISLang:Attribute>) ? true : false;
5394     my $pname = $cr-><AG::ManakaiDISResourceDefinition.plName>;
5395     my $op = $cr-><AG::ManakaiDISResourceDefinition
5396     .plMethodOperator>;
5397     my $psub = $cr-><AG::ManakaiDISResourceDefinition
5398     .plCodeFragment>;
5399     if (defined $pname) {
5400     if ($r-><M::PLPack.getSub> ($pname)) {
5401     __UNDEEP{__EXCEPTION{PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5402     PerlCode:localName => {$pname},
5403     DIS:uri => {$cr->{uri}},
5404     DIS:sourceNode => {$cr->{src}},
5405     }__}__;
5406     }
5407     $r-><M::PLPack.setSub> ($pname => $psub);
5408    
5409     if (defined $op and not $cr-><AG::ManakaiDISResourceDefinition
5410     .isAnonymous>) {
5411     if ($op =~ /^[A-Z]+$/) {
5412     if ($r-><M::PLPack.getSubAliasName> ($op)) {
5413     __UNDEEP{__EXCEPTION{
5414     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5415     PerlCode:localName => {$op},
5416     DIS:uri => {$cr->{uri}},
5417     DIS:sourceNode => {$cr->{src}},
5418     }__}__;
5419     }
5420     $r-><M::PLPack.setSubAliasName> ($op => $pname);
5421     } else {
5422     if ($r-><M::PLPack.getOverloadMethodName> ($op)) {
5423     __UNDEEP{__EXCEPTION{
5424     PERL_OPERATOR_ALREADY_OVERLOADED_ERR::
5425     PerlCode:operator => {$op},
5426     DIS:uri => {$cr->{uri}},
5427     DIS:sourceNode => {$cr->{src}},
5428     }__}__;
5429     }
5430     $r-><M::PLPack.setOverloadMethodName> ($op => $pname);
5431     }
5432     }
5433     } elsif (defined $op) {
5434     $r-><M::PLPack.setOverloadSub> ($op => $psub);
5435     } else {
5436     __UNDEEP{__EXCEPTION{PERL_UNUSED_SUBROUTINE_ERR::
5437     DIS:uri => {$cr->{uri}},
5438     DIS:sourceNode => {$cr->{src}},
5439     }__}__;
5440     }
5441 wakaba 1.25 ## - Constant groups
5442 wakaba 1.21 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5443     (<Q::ManakaiDOM:ConstGroup>)) {
5444     for my $gcr (@{$cr-><M::ManakaiDISPropertyAccessor
5445     .getPropertyResourceList>
5446     (<Q::DIS:childResource>)}) {
5447     if ($gcr-><M::ManakaiDISResourceDefinition.isTypeURI>
5448     (<Q::ManakaiDOM:Const>)) {
5449     my $sub = $gcr-><AG::ManakaiDISResourceDefinition
5450     .plCodeFragment>;
5451     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5452     __UNDEEP{__EXCEPTION{
5453     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5454     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5455     DIS:uri => {$gcr->{uri}},
5456     DIS:sourceNode => {$gcr->{src}},
5457     }__}__;
5458     }
5459     $r-><M::PLPack.setSub>
5460     ($sub-><AG::MPLSub.localName> => $sub);
5461     push @const, $gcr;
5462     }
5463     }
5464 wakaba 1.25 ## - Constants
5465 wakaba 1.21 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5466     (<Q::ManakaiDOM:Const>)) {
5467     my $sub = $cr-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5468     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5469     __UNDEEP{__EXCEPTION{
5470     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5471     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5472     DIS:uri => {$cr->{uri}},
5473     DIS:sourceNode => {$cr->{src}},
5474     }__}__;
5475     }
5476     $r-><M::PLPack.setSub> ($sub-><AG::MPLSub.localName> => $sub);
5477     push @const, $cr;
5478 wakaba 1.25 ## Package-scope variables
5479 wakaba 1.23 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5480     (<Q::DISPerl:ScalarVariable>)) {
5481     my $varn = $cr-><AG::ManakaiDISResourceDefinition
5482     .plVariableName>;
5483     my $var = $plimpl-><M::MPLImpl.createPerlVariable>
5484     (null, null, $varn);
5485     my $data_type = $cr-><AG::ManakaiDISResourceDefinition
5486     .disActualDataTypeResource>;
5487     my $value = $cr->{src}
5488     -><M::ManakaiDISElement.plValueCodeFragment>
5489     (<Q::dis:DefaultValue>, $cr,
5490     for_arg => $cr->{for},
5491     forp_arg => $cr->{forp},
5492     use_default_value => true,
5493     data_type_uri => $data_type
5494     -><AG::ManakaiDISResourceDefinition.uri>);
5495     if ($cr-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
5496     (<Q::DISPerl:defaultValueHasSelfReference>)) {
5497     $r-><M::PLBlockCon.appendStatement>
5498     -><M::PLBlockCon.appendCodeFragment> (my $v = $var->clone);
5499     $v-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5500     .variableScope> ('our');
5501     } else {
5502     $var-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
5503     .variableScope> ('our');
5504     }
5505     $r-><M::PLBlockCon.appendStatement>
5506     -><M::PLAnyCon.appendNewAssignment> ($var => $value);
5507     } # Type of child resources
5508 wakaba 1.20 }
5509 wakaba 1.21
5510 wakaba 1.25 ## - Exceptions
5511 wakaba 1.21 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5512     (<Q::DOMException:AnyExceptionClass>)) {
5513     my $err_def = $plimpl-><M::MPLImpl.createPerlSub> ('___error_def');
5514     $err_def-><AS::MPLSub.prototype> ('');
5515     $err_def-><M::PLBlockCon.appendCode>
5516     ($plimpl-><M::MPLImpl.perlList>
5517     ([{
5518     map {
5519     $_-><AG::ManakaiDISResourceDefinition.plName> => {
5520     <Q::DOMCore:code> => 0 + $_
5521     -><AG::ManakaiDISResourceDefinition.plCodeFragment>,
5522     description => $_
5523     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
5524     # ($_->{ExpandedURI q< DOMCore:severity>}
5525     # ? (ExpandedURI q< DOMCore:severity>
5526     # => $_->{ExpandedURI q< DOMCore:severity>},
5527     # ExpandedURI q< DOMCore:type>
5528     # => $_->{ExpandedURI q< DOMCore:type>})
5529     # : ()),
5530     <Q::MDOMX:subtype> => {
5531     map {
5532     $_-><AG::ManakaiDISResourceDefinition.nameURI>
5533     => {
5534     description => $_
5535     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
5536     # ($_->{ExpandedURI q< DOMCore:severity>}
5537     # ? (ExpandedURI q< DOMCore:severity>
5538     # => $_->{ExpandedURI q< DOMCore:severity>},
5539     # ExpandedURI q< DOMCore:type>
5540     # => $_->{ExpandedURI q< DOMCore:type>})
5541     # : ()),
5542     },
5543     } grep {
5544     $_-><M::ManakaiDISResourceDefinition.isTypeURI>
5545     (<Q::ManakaiDOM:ExceptionOrWarningSubType>)
5546     } @{$_-><M::ManakaiDISPropertyAccessor
5547     .getPropertyResourceList>
5548     (<Q::DIS:childResource>)}
5549     },
5550     },
5551     } @const
5552     }]));
5553     $r-><M::PLPack.setSub> (___error_def => $err_def);
5554     }
5555 wakaba 1.25
5556     ## -- Global variables
5557 wakaba 1.23 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5558     (<Q::DISPerl:ScalarVariable>)) {
5559     my $plimpl = $self-><AG::ManakaiDISPropertyAccessor
5560     .plImplementation>;
5561     my $varn = $self-><AG::ManakaiDISResourceDefinition.plVariableName>;
5562     my $var = $plimpl-><M::MPLImpl.createPerlVariable>
5563     (null, null, $varn);
5564     my $data_type = $self-><AG::ManakaiDISResourceDefinition
5565     .disActualDataTypeResource>;
5566     my $value = $self->{src}
5567     -><M::ManakaiDISElement.plValueCodeFragment>
5568     (<Q::dis:DefaultValue>, $self,
5569     for_arg => $self->{for},
5570     forp_arg => $self->{forp},
5571     use_default_value => true,
5572     data_type_uri => $data_type
5573     -><AG::ManakaiDISResourceDefinition.uri>);
5574     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
5575     $r-><M::PLAnyCon.appendNewAssignment> ($var => $value);
5576 wakaba 1.13 } else { ## Not supported
5577 wakaba 1.19 $r = $self->{<Q::plCodeFragment>} = null;
5578 wakaba 1.12 } # rdf:type
5579     }__;
5580    
5581     @Method:
5582     @@Name: getChildResourceByType
5583     @@enDesc:
5584     Gets a static child resource selected by its type.
5585     @@Param:
5586     @@@Name:typeURI
5587     @@@Type:ResourceURI
5588     @@@enDesc:
5589     A URI reference identifying a resource type.
5590     @@Return:
5591     @@@Type: ManakaiDISResourceDefinition
5592     @@@enDesc:
5593     The first (by document order) child resource whose
5594     type matches with <P::resType>.
5595     @@@nullCase:
5596     @@@@enDesc:
5597     There is no resource whose type is <P::resType>.
5598     @@@PerlDef:
5599     __DEEP{
5600 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5601 wakaba 1.12 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5602 wakaba 1.26 ($cr_uri);
5603 wakaba 1.12 if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
5604     $r = $cr;
5605     last;
5606     }
5607     }
5608     }__;
5609 wakaba 1.13
5610     @Method:
5611     @@Name: getChildResourceByNameAndType
5612     @@enDesc:
5613     Gets a static child resource selected by its local name and type.
5614     @@Param:
5615     @@@Name: localName
5616     @@@Type:
5617     DISCore:LocalName::ManakaiDOM:all
5618     @@@enDesc:
5619     A local name.
5620     @@Param:
5621     @@@Name:typeURI
5622     @@@Type:ResourceURI
5623     @@@enDesc:
5624     A URI reference identifying a resource type.
5625     @@Return:
5626     @@@Type: ManakaiDISResourceDefinition
5627     @@@enDesc:
5628     The first (by document order) child resource whose
5629     type matches for <P::localName> and <P::resType>.
5630     @@@nullCase:
5631     @@@@enDesc:
5632     There is no resource whose name is <P::localName> and
5633     whose type is <P::resType>.
5634     @@@PerlDef:
5635     __DEEP{
5636 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5637 wakaba 1.13 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5638 wakaba 1.26 ($cr_uri);
5639 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
5640 wakaba 1.13 if (defined $ln and $ln eq $localName and
5641     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
5642     $r = $cr;
5643     last;
5644     }
5645     }
5646     }__;
5647    
5648     @Method:
5649     @@Name: getConstResourceByName
5650     @@enDesc:
5651     Gets a constant value resource by its local name.
5652     @@Param:
5653     @@@Name:localName
5654     @@@Type:
5655     DISLang:String::ManakaiDOM:all
5656     @@@enDesc:
5657     Constant name.
5658     @@Return:
5659     @@@Type: ManakaiDISResourceDefinition
5660     @@@enDesc:
5661     The constant resource identified by <P::localName>.
5662     @@@nullCase:
5663     @@@@enDesc:
5664     There is no such constant resource.
5665     @@@PerlDef:
5666     __DEEP{
5667     my @constGroup;
5668 wakaba 1.26 for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5669 wakaba 1.13 my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5670 wakaba 1.26 ($cr_uri);
5671 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
5672 wakaba 1.13 if ($ln and $ln eq $localName and
5673     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5674     (<Q::ManakaiDOM:Const>)) {
5675     $r = $cr;
5676     last;
5677     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5678     (<Q::ManakaiDOM:ConstGroup>)) {
5679     push @constGroup, $cr;
5680     }
5681     }
5682     unless ($r) {
5683     for my $cg (@constGroup) {
5684     $r = $cg-><M::ManakaiDISResourceDefinition
5685     .getChildResourceByNameAndType>
5686     ($localName, <Q::ManakaiDOM:Const>);
5687     last if $r;
5688     }
5689     }
5690     }__;
5691    
5692 wakaba 1.23 @ResourceDef:
5693     @@Name: RegQNameChar
5694     @@enDesc:
5695     A regular expression character class for <Q::dis:TypeQName>
5696     character.
5697     @@rdf:type:
5698     DISPerl:ScalarVariable
5699     @@DefaultValue:
5700     @@@@: qr/[^\s<>"'\\\[\]\{\},=\$\@%]/
5701     @@@ContentType:
5702     lang:Perl
5703     @@Type:
5704     DOMMain:any::ManakaiDOM:all
5705    
5706     @ResourceDef:
5707     @@Name: RegBlockContent
5708     @@enDesc:
5709     A regular expression for a block.
5710     @@rdf:type:
5711     DISPerl:ScalarVariable
5712     @@Type:
5713     DOMMain:any::ManakaiDOM:all
5714     @@DefaultValue:
5715     @@@@:
5716     qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{$RegBlockContent})\})*)/
5717     @@@ContentType:
5718     lang:Perl
5719     @@DISPerl:defaultValueHasSelfReference:1
5720    
5721 wakaba 1.13 @Method:
5722     @@Name: plPreprocessPerlCode
5723     @@enDesc:
5724     Preprocesses a Perl block-level code fragment.
5725     @@Param:
5726     @@@Name:codeArg
5727     @@@Type:
5728     lang:Perl::ManakaiDOM:all
5729     @@@enDesc:
5730     A Perl block-level code (statements and/or blocks).
5731 wakaba 1.15 @@NodeParam:
5732     @@NamedParam:
5733     @@@Name:methodResource
5734     @@@Type:ManakaiDISResourceDefinition
5735     @@@enDesc:
5736     The resource definition of the Perl method to which
5737     the <P::codeArg> belongs.
5738     @@@nullCase:
5739     @@@@enDesc:
5740     The <P::codeArg> does not belong to any method.
5741 wakaba 1.17 @@NamedParam:
5742     @@@Name:sourceFile
5743     @@@Type:
5744     DISLang:String::ManakaiDOM:all
5745     @@@enDesc:
5746     The source file name of the <P::codeArg>.
5747     @@@nullCase:
5748     @@@@enDesc:
5749     No source file information available.
5750     @@NamedParam:
5751     @@@Name:sourceLine
5752     @@@Type:
5753     DOMMain:unsigned-long::ManakaiDOM:all
5754     @@@enDesc:
5755     The line number in the <P::sourceFile> from which
5756     the <P::codeArg> begins.
5757     @@@nullCase:
5758     @@@@enDesc:
5759     No source file information available.
5760 wakaba 1.13 @@Return:
5761     @@@Type:
5762     lang:Perl::ManakaiDOM:all
5763     @@@enDesc:
5764     Preprocessed Perl code.
5765 wakaba 1.15 @@@BlockElementException:
5766     @@@InlineElementException:
5767 wakaba 1.13 @@@PerlDef:
5768 wakaba 1.15 unless ($self->{src}) {
5769     __EXCEPTION{NO_SOURCE_NODE_ERR::
5770     DIS:uri => {$self->{uri}},
5771     }__;
5772     }
5773     __DEEP{
5774     our $RegQNameChar;
5775     our $RegBlockContent;
5776 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor.plImplementation>;
5777 wakaba 1.15 $r = $plimpl-><M::MPLImpl.createPerlBlock>;
5778 wakaba 1.17 if (defined $sourceLine) {
5779     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
5780     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
5781     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
5782     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
5783     } elsif ($node) {
5784     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
5785     (key => [qw/Name QName Type type/]);
5786     $r-><AS::PLBlockCon.currentSourceFile> ($np);
5787     $r-><AS::PLBlockCon.currentSourceLine> (1);
5788     $r-><AS::PLBlockCon.sourceFile> ($np);
5789     $r-><AS::PLBlockCon.sourceLine> (1);
5790     }
5791 wakaba 1.15
5792 wakaba 1.16 for my $source_code (split /\b(_ _(?:(?!_ _)$RegQNameChar)+
5793 wakaba 1.15 (?:\{$RegBlockContent\})?
5794 wakaba 1.16 _ _)\b/x, $codeArg) {
5795 wakaba 1.15 ## Block-level element
5796 wakaba 1.16 if ($source_code =~ /_\_\z/ and
5797     $source_code =~ s/^_\_((?:(?!_\_)$RegQNameChar)+)//) {
5798 wakaba 1.15 my $et = $self->{src}
5799     -><M::ManakaiDISElement.qnameToURI>
5800     ($1,
5801     node => $node,
5802     default_namespace_uri => <Q::disPerl:>);
5803     if ($source_code =~ s/^\{//) {
5804     $source_code =~ s/\}__\z//;
5805     } else {
5806     $source_code = '';
5807     }
5808    
5809     # ## ISSUE: __FILE__ & __LINE__ will break if multiline substition happens.
5810    
5811     if ($et eq <Q::disPerl:DEEP> or $et eq <Q::disPerl:UNDEEP>) {
5812     my $block = $r-><M::PLBlockCon.appendBlock>;
5813     $block-><M::PLBlockCon.appendStatement>
5814     ('local $Error::Depth = $Error::Depth '.
5815     ($et eq <Q::disPerl:DEEP> ? '+' : '-').
5816     ' 1');
5817     $block-><M::PLBlockCon.appendCodeFragment>
5818 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
5819     .plPreprocessPerlCode>
5820     ($source_code, node => $node,
5821     method_resource => $methodResource,
5822     source_file => $r-><AG::PLBlockCon
5823     .currentSourceFile>,
5824     source_line => $r-><AG::PLBlockCon
5825     .currentSourceLine>));
5826     $r-><M::PLBlockCon.skipLines> ($source_code);
5827 wakaba 1.15 } elsif ({
5828     <Q::disPerl:EXCEPTION> => 1,
5829     <Q::disPerl:WARNING> => 1,
5830     }->{$et}) {
5831 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5832 wakaba 1.15 if ($source_code =~ s/^((?:(?!::).)+)(::\s*)?//s) {
5833     my ($cls, $const, $subtype)
5834     = @{$self->{db}-><M::ManakaiDISDatabase.xcrefToResource>
5835 wakaba 1.16 ($1, $self->{src},
5836     node => $node,
5837     for_arg => $self->{for})};
5838 wakaba 1.15 my $param = $self-><M::ManakaiDISResourceDefinition
5839     .plParsePreprocessParameter>
5840     ($source_code, node => $node);
5841     my $context_param
5842     = $self-><M::ManakaiDISResourceDefinition
5843     .plGetContextParameter>;
5844    
5845     $self-><M::ManakaiDISResourceDefinition
5846     .plAppendThrow>
5847     ($r, $cls, $const, $subtype,
5848     {%$param, %$context_param});
5849     } else {
5850     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR::
5851     DIS:sourceNode => {$node},
5852     DIS:sourceCode => {$source_code},
5853     DIS:elementType => {$et},
5854     }__}__;
5855     }
5856     } elsif ($et eq <Q::disPerl:CODE>) {
5857 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5858 wakaba 1.15 my $code_name;
5859     $source_code =~ s/^\s+//;
5860     if ($source_code =~ s/^((?>(?!::).)+)//s) {
5861     $code_name = $1;
5862     } else {
5863     __UNDEEP{
5864     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
5865     DIS:sourceCode => {$source_code},
5866     DIS:sourceNode => {$node},
5867     DIS:elementType => {$et},
5868     }__;
5869     }__;
5870     }
5871     $source_code =~ s/^::\s*//;
5872     my $param = $self-><M::ManakaiDISResourceDefinition
5873     .plParsePreprocessParameter>
5874     ($source_code, node => $node);
5875     my $code_uri = $self->{src}-><M::ManakaiDISElement
5876     .tfqnamesToURI>
5877     ($code_name, null, $self->{for},
5878     node => $node);
5879     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
5880     ($code_uri);
5881     $code-><AS::ManakaiDISResourceDefinition.isReferred>
5882     ($node || $self->{src});
5883     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
5884     (<Q::dis2pm:BlockCode>)) {
5885     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5886     DIS:uri => {$code_uri},
5887     DIS:sourceNode => {$node},
5888     DIS:sourceCode => {$source_code},
5889     DIS:expectedType => {<Q::dis2pm:BlockCode>},
5890     }__;}__;
5891     }
5892     my $pc = $code-><AG::ManakaiDISResourceDefinition
5893     .plCodeFragment>->clone;
5894     unless (defined $pc) {
5895     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
5896     DIS:sourceNode => {$node},
5897     DIS:sourceCode => {$source_code},
5898     DIS:uri => {$code_uri},
5899     }__}__;
5900     }
5901     for my $var (grep {/^\$/} keys %$param) {
5902     my $value;
5903     if ($param->{$var}->{type} eq 'variable') {
5904     $value = $plimpl-><M::MPLImpl.createPerlVariable>
5905     ('$', null, $param->{$var}->{value});
5906     } elsif ($param->{$var}->{type} eq 'code') {
5907 wakaba 1.22 $value = $self-><M::ManakaiDISResourceDefinition
5908     .plPreprocessPerlStatement>
5909     ($param->{$var}->{value},
5910     contains_statements => false);
5911 wakaba 1.15 } else {
5912     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
5913     ($param->{$var}->{value});
5914     }
5915     $pc-><M::MPLCodeFragment.replaceVariable>
5916     ($var => $value);
5917     }
5918 wakaba 1.16 $r-><M::PLBlockCon.appendCodeFragment> ($pc);
5919 wakaba 1.15 } elsif ($et eq <Q::ManakaiDOM:InputNormalize>) {
5920 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5921 wakaba 1.15 unless ($methodResource) {
5922     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_METHOD_ERR::
5923     DIS:sourceNode => {$node},
5924     DIS:sourceCode => {$source_code},
5925     DIS:elementType => {$et},
5926     }__}__;
5927     }
5928     my $param = $methodResource
5929     -><M::ManakaiDISResourceDefinition
5930     .getChildResourceByNameAndType>
5931     ($source_code, <Q::DISLang:MethodParameter>);
5932     unless ($param) {
5933     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5934     DIS:sourceNode => {$node},
5935     DIS:sourceCode => {$source_code},
5936     DIS:elementType => {$et},
5937     DIS:localName => {$source_code},
5938     DIS:expectedType => {<Q::DISLang:MethodParameter>},
5939     }__}__;
5940     }
5941     my $norm = $param-><M::ManakaiDISResourceDefinition
5942     .plGetMethodInputNormalizer>;
5943     if ($norm) {
5944     my $norm_code = $norm-><AG::ManakaiDISResourceDefinition
5945     .plCodeFragment>->clone;
5946     $norm_code-><M::MPLCodeFragment.replaceVariable>
5947     ('$INPUT' => $param-><AG::ManakaiDISResourceDefinition
5948     .plVariableName>);
5949     $r-><M::PLBlockCon.appendCodeFragment> ($norm_code);
5950     }
5951     } elsif ($et eq <Q::disPerl:FOR>) {
5952 wakaba 1.17 if ($source_code =~ s/^(((?>(?!::).)*)::\s*)//) {
5953     $r-><M::PLBlockCon.skipLines> ($1);
5954     V: for (split /\s*\|\s*/, $2) {
5955 wakaba 1.15 my $for_uri = $self->{src}
5956     -><M::ManakaiDISElement.qnameToURI>
5957     ($_, node => $node);
5958     if ($self-><M::ManakaiDISResourceDefinition
5959     .isForURI> ($for_uri)) {
5960     $r-><M::PLBlockCon.appendCodeFragment>
5961 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
5962     .plPreprocessPerlCode>
5963     ($source_code, node => $node,
5964     method_resource => $methodResource,
5965     source_file => $r-><AG::PLBlockCon.
5966     currentSourceFile>,
5967     source_line => $r-><AG::PLBlockCon.
5968     currentSourceLine>));
5969 wakaba 1.15 last V;
5970     }
5971     } # V
5972 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5973 wakaba 1.15 } else {
5974     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_FOR_ERR::
5975     DIS:sourceNode => {$node},
5976     DIS:sourceCode => {$source_code},
5977     DIS:elementType => {$et},
5978     }__}__;
5979     }
5980     } elsif ($et eq <Q::disPerl:ASSERT>) {
5981 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5982 wakaba 1.15 my $assert_type;
5983     if ($source_code =~ s/^\s*($RegQNameChar+)\s*::\s*//o) {
5984     $assert_type = $self->{src}
5985     -><M::ManakaiDISElement.qnameToURI>
5986     ($1, node => $node);
5987     } else {
5988     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ASSERT_TYPE_ERR::
5989     DIS:sourceNode => {$node},
5990     DIS:sourceCode => {$source_code},
5991     DIS:elementType => {$et},
5992     }__}__;
5993     }
5994     # if output assertion then
5995     =pod
5996     my $assert_block = $r-><M::PLBlockCon.appendBlock>;
5997    
5998     my $param = $self-><M::ManakaiDISResourceDefinition
5999     .plParsePreprocessParameter>
6000     ($source_code, node => $node);
6001     my $context_param
6002     = $self-><M::ManakaiDISResourceDefinition
6003     .plGetContextParameter>;
6004    
6005     if ($assert_type eq <Q::DISPerl:isPositive>) {
6006    
6007     $pre = perl_statement
6008     perl_assign
6009     'my $asActual' =>
6010     '('.perl_code ($param->{actual}, %opt).')';
6011     $cond = '$asActual > 0';
6012     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = 'a positive value';
6013     $xparam->{ExpandedURI q<DOMMain:actualValue>}
6014     = perl_code_literal q<$asActual>;
6015     } elsif ($atype eq ExpandedURI q<DISPerl:invariant>) {
6016     $cond = '0';
6017     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = $param->{msg};
6018     $xparam->{ExpandedURI q<DOMMain:actualValue>} = '(invariant)';
6019     } else {
6020     valid_err (q[Assertion type <].$atype.q[> is not supported],
6021     node => $opt{node});
6022     }
6023    
6024     $r = $pre . perl_if
6025     $cond,
6026     undef,
6027    
6028    
6029     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
6030     (<Q::DOMException:CoreException>);
6031     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
6032     (<Q::MDOMX:MDOM_DEBUG_BUG>);
6033     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
6034     (<Q::DOMMain:ASSERTION_ERR>);
6035 wakaba 1.16 $_-><AS::ManakaiDISResourceDefinition.isReferred>
6036 wakaba 1.15 ($node || $self->{src}) for $cls, $const, $subtype;
6037     $self-><M::ManakaiDISResourceDefinition
6038     .plAppendThrow>
6039     ($assert_block, $cls, $const, $subtype,
6040     {%$param, %$context_param,
6041     <Q::DOMMain:assertionType> => {
6042     type => 'quoted', value => $assert_type,
6043     },
6044     <Q::DOMMain:traceText> => {
6045     type => 'code',
6046     value => q<(sprintf 'at %s line %s%s%s',
6047     __FILE__, __LINE__, "\n\t",
6048     Carp::longmess ())>,
6049     }});
6050    
6051     =cut
6052    
6053     } elsif ({
6054     <Q::disPerl:FILE> => 1,
6055     <Q::disPerl:LINE> => 1,
6056     <Q::disPerl:PACKAGE> => 1,
6057     }->{$et}) {
6058     $r-><M::PLAnyCon.appendAtom>
6059     ('__'.{
6060     <Q::disPerl:FILE> => 'FILE',
6061     <Q::disPerl:LINE> => 'LINE',
6062     <Q::disPerl:PACKAGE> => 'PACKAGE',
6063     }->{$et}.'__');
6064     if (length $source_code) {
6065     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR::
6066     DIS:sourceNode => {$node},
6067     DIS:sourceCode => {$source_code},
6068     DIS:elementType => {$et},
6069     }__}__;
6070     }
6071     } else {
6072     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
6073     DIS:sourceNode => {$node},
6074     DIS:sourceCode => {$source_code},
6075     DIS:elementType => {$et},
6076     }__}__;
6077     }
6078     } else { ## Other than block-level element
6079     $r-><M::PLBlockCon.appendCodeFragment>
6080     ($self-><M::ManakaiDISResourceDefinition
6081 wakaba 1.16 .plPreprocessPerlStatement>
6082 wakaba 1.17 ($source_code, contains_statements => true,
6083     source_file => $r-><AG::PLBlockCon
6084     .currentSourceFile>,
6085     source_line => $r-><AG::PLBlockCon
6086     .currentSourceLine>));
6087     $r-><M::PLBlockCon.skipLines> ($source_code);
6088 wakaba 1.15 }
6089     } # for
6090     }__; # DEEP
6091    
6092    
6093     ## Checks \p character classes
6094     # while ($s =~ /\\p{([^{}]+)}/gs) {
6095     # my $name = $1;
6096     # $State->{ExpandedURI q<dis2pm:Package>}
6097     # ->{$State->{ExpandedURI q<dis2pm:currentPackage>}}
6098     # ->{ExpandedURI q<dis2pm:requiredCharClass>}
6099     # ->{$name} ||= $opt{node} || 1;
6100     # }
6101    
6102 wakaba 1.13
6103     @Method:
6104     @@Name: plPreprocessPerlStatement
6105     @@enDesc:
6106     Preprocesses a Perl inline code fragment
6107     (code fragment smaller than statement).
6108     @@Param:
6109     @@@Name:codeArg
6110     @@@Type:
6111     lang:Perl::ManakaiDOM:all
6112     @@@enDesc:
6113     A Perl code fragment.
6114     @@NodeParam:
6115 wakaba 1.16 @@NamedParam:
6116     @@@Name:containsStatements
6117     @@@Type:
6118     DOMMain:boolean::ManakaiDOM:all
6119     @@@enDesc:
6120     Whether one or more statements might be contained
6121     in <P::codeArg> or not.
6122 wakaba 1.17 @@NamedParam:
6123     @@@Name:sourceFile
6124     @@@Type:
6125     DISLang:String::ManakaiDOM:all
6126     @@@enDesc:
6127     The source file name of the <P::codeArg>.
6128     @@@nullCase:
6129     @@@@enDesc:
6130     No source file information available.
6131     @@NamedParam:
6132     @@@Name:sourceLine
6133     @@@Type:
6134     DOMMain:unsigned-long::ManakaiDOM:all
6135     @@@enDesc:
6136     The line number in the <P::sourceFile> from which
6137     the <P::codeArg> begins.
6138     @@@nullCase:
6139     @@@@enDesc:
6140     No source file information available.
6141 wakaba 1.13 @@Return:
6142 wakaba 1.16 @@@Type:MPLCodeFragment
6143 wakaba 1.13 @@@enDesc:
6144     Preprocessed Perl code.
6145 wakaba 1.16 @@@InCase:
6146     @@@@Type:
6147     PerlCode:ManakaiPerlBlock::ManakaiDOM:Perl
6148     @@@@enDesc:
6149 wakaba 1.19 If <P::containsStatements> is <DOM::false>.
6150 wakaba 1.16 @@@InCase:
6151     @@@@Type:
6152     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
6153     @@@@enDesc:
6154 wakaba 1.19 If <P::containsStatements> is <DOM::true>.
6155 wakaba 1.13 @@@InlineElementException:
6156     @@@PerlDef:
6157     unless ($self->{src}) {
6158     __EXCEPTION{NO_SOURCE_NODE_ERR::
6159     DIS:uri => {$self->{uri}},
6160     }__;
6161     }
6162     __DEEP{
6163     our $RegQNameChar;
6164 wakaba 1.22 my $plimpl = $self-><AG::ManakaiDISPropertyAccessor.plImplementation>;
6165 wakaba 1.16 if ($containsStatements) {
6166     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
6167 wakaba 1.17 if (defined $sourceLine) {
6168     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
6169     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
6170     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
6171     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
6172     } elsif ($node) {
6173     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
6174     (key => [qw/Name QName Type type/]);
6175     $r-><AS::PLBlockCon.sourceFile> ($np);
6176     $r-><AS::PLBlockCon.sourceLine> (1);
6177     $r-><AS::PLBlockCon.currentSourceFile> ($np);
6178     $r-><AS::PLBlockCon.currentSourceLine> (1);
6179     }
6180 wakaba 1.16 } else {
6181     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
6182     }
6183     for my $source_code (split /(?<![\^\?qwr])(\x3C$RegQNameChar[^<>]+>
6184     )/ox, $codeArg) {
6185 wakaba 1.13 if ($source_code =~ s/^\x3C//) {
6186     $source_code =~ s/>$//;
6187     if ($source_code =~ /=$/) {
6188     ## TODO: Warning
6189     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
6190     # q{should "=" be used place of "=>"?};
6191     }
6192     if ($source_code =~ s/^(.+?):://) {
6193     my $et = $self->{src}
6194     -><M::ManakaiDISElement.qnameToURI>
6195     ($1,
6196     node => $node,
6197     default_namespace_uri => <Q::disPerl:>);
6198     if ($et eq <Q::disPerl:Q>) { ## QName constant
6199     $r-><M::PLAnyCon.appendStringLiteral>
6200     ($self->{src}
6201     -><M::ManakaiDISElement.qnameToURI>
6202     ($source_code, node => $node));
6203     } elsif ({
6204     <Q::disPerl:M> => 1,
6205     <Q::disPerl:ClassM> => 1,
6206     <Q::disPerl:AG> => 1,
6207     <Q::disPerl:AS> => 1,
6208     }->{$et}) { ## Method call
6209     my ($class_qname, $method_qname)
6210     = split /\s*\.\s*/, $source_code, 2;
6211     my $class_uri
6212     = $self->{src}
6213     -><M::ManakaiDISElement.tfqnamesToURI>
6214     ($class_qname,
6215     $self-><AG::ManakaiDISResourceDefinition
6216     .ownerClassURI>,
6217     $self->{for},
6218     node => $node);
6219     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6220     ($class_uri);
6221 wakaba 1.16 unless ($class-><AG::ManakaiDISResourceDefinition
6222     .isDefined>) {
6223     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6224     DIS:sourceNode => {$node},
6225     DIS:sourceCode => {$source_code},
6226     DIS:uri => {$class_uri},
6227     DIS:elementType => {$et},
6228     DIS:expectedType => {<Q::DISLang:AnyClass>},
6229     }__}__;
6230     }
6231 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6232 wakaba 1.13 ($node || $self->{src});
6233     if ($et eq <Q::disPerl::ClassM> and
6234     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
6235     (<Q::ManakaiDOM:IF>)) {
6236     __UNDEEP{
6237     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
6238     DIS:uri => {$class_uri},
6239     DIS:elementType => {$et},
6240     DIS:sourceNode => {$node || $self->{src}},
6241     DIS:sourceCode => {$source_code},
6242 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
6243 wakaba 1.13 }__;
6244     }__;
6245     }
6246     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
6247     (<Q::ManakaiDOM:IF>)) {
6248 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
6249     ($class => $r);
6250 wakaba 1.13 }
6251 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
6252 wakaba 1.13 .getChildResourceByNameAndType>
6253     ($method_qname,
6254     {
6255     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
6256     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
6257     }->{$et} || <Q::DISLang:Method>);
6258     if (not $method or
6259     not $method-><AG::ManakaiDISResourceDefinition
6260     .isDefined>) {
6261     __UNDEEP{
6262     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6263     DIS:localName => {$method_qname},
6264     DIS:elementType => {$et},
6265     DIS:sourceNode => {$node || $self->{src}},
6266     DIS:sourceCode => {$source_code},
6267 wakaba 1.14 DIS:expectedType => {{
6268     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
6269     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
6270     }->{$et} || <Q::DISLang:Method>},
6271 wakaba 1.13 }__;
6272     }__;
6273     }
6274     my $class_name = '';
6275     if ($et eq <Q::disPerl:ClassM>) {
6276     $class_name = $class-><AG::ManakaiDISResourceDefinition
6277     .plFullyQualifiedName> . '->';
6278     }
6279     my $method_name = $method-><AG::ManakaiDISResourceDefinition
6280     .plName>;
6281     $r-><M::PLAnyCon.appendBare>
6282     ($class_name . $method_name);
6283     } elsif ({
6284     <Q::disPerl:Class> => 1,
6285     <Q::disPerl:ClassName> => 1,
6286     <Q::disPerl:IF> => 1,
6287     <Q::disPerl:IFName> => 1,
6288     }->{$et}) { ## Perl package name
6289     my $class_uri
6290     = $self->{src}
6291     -><M::ManakaiDISElement.tfqnamesToURI>
6292     ($source_code,
6293     $self-><AG::ManakaiDISResourceDefinition
6294     .ownerClassURI>,
6295     $self->{for},
6296     node => $node);
6297     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6298     ($class_uri);
6299 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6300 wakaba 1.13 ($node || $self->{src});
6301 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
6302 wakaba 1.13 .plFullyQualifiedName>;
6303 wakaba 1.14 unless ($pack) {
6304     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
6305     DIS:sourceNode => {$node || $self->{src}},
6306     DIS:sourceCode => {$source_code},
6307     DIS:uri => {$class_uri},
6308     DIS:elementType => {$et},
6309     }__}__;
6310     }
6311 wakaba 1.13 if ({
6312     <Q::disPerl:ClassName> => 1,
6313     <Q::disPerl:IFName> => 1,
6314     }->{$et}) {
6315     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
6316     } else {
6317     $r-><M::PLAnyCon.appendBare> ($pack);
6318     }
6319     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
6320     my $code_name;
6321     $source_code =~ s/^\s+//;
6322     if ($source_code =~ s/^((?>(?!::).)+)//s) {
6323     $code_name = $1;
6324     } else {
6325     __UNDEEP{
6326     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
6327     DIS:sourceCode => {$source_code},
6328     DIS:sourceNode => {$node || $self->{src}},
6329     }__;
6330     }__;
6331     }
6332     $source_code =~ s/^::\s*//;
6333     my $param = $self-><M::ManakaiDISResourceDefinition
6334     .plParsePreprocessParameter>
6335     ($source_code, node => $node);
6336     my $code_uri = $self->{src}-><M::ManakaiDISElement
6337     .tfqnamesToURI>
6338     ($code_name, null, $self->{for},
6339     node => $node);
6340     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
6341     ($code_uri);
6342 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
6343 wakaba 1.13 ($node || $self->{src});
6344     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
6345     (<Q::dis2pm:InlineCode>)) {
6346     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6347     DIS:uri => {$code_uri},
6348     DIS:sourceNode => {$node || $self->{src}},
6349     DIS:sourceCode => {$source_code},
6350     DIS:expectedType => {<Q::dis2pm:InlineCode>},
6351     }__;}__;
6352     }
6353     my $pc = $code-><AG::ManakaiDISResourceDefinition
6354     .plCodeFragment>->clone;
6355     unless (defined $pc) {
6356     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
6357     DIS:sourceNode => {$node || $self->{src}},
6358     DIS:sourceCode => {$source_code},
6359     DIS:uri => {$code_uri},
6360     }__}__;
6361     }
6362     for my $var (grep {/^\$/} keys %$param) {
6363     my $value;
6364     if ($param->{$var}->{type} eq 'variable') {
6365     $value = $plimpl-><M::MPLImpl.createPerlVariable>
6366     ('$', null, $param->{$var}->{value});
6367     } elsif ($param->{$var}->{type} eq 'code') {
6368 wakaba 1.22 $value = $self-><M::ManakaiDISResourceDefinition
6369     .plPreprocessPerlStatement>
6370     ($param->{$var}->{value},
6371     contains_statements => false);
6372 wakaba 1.13 } else {
6373     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
6374     ($param->{$var}->{value});
6375     }
6376     $pc-><M::MPLCodeFragment.replaceVariable>
6377     ($var => $value);
6378     }
6379 wakaba 1.16 $r-><M::PLInCon.appendCodeFragment> ($pc);
6380 wakaba 1.13 } elsif ($et eq <Q::disPerl:C>) {
6381     my ($class_qname, $const_name) = split /\./, $source_code, 2;
6382     my $class_uri
6383     = $self->{src}
6384     -><M::ManakaiDISElement.tfqnamesToURI>
6385     ($class_qname,
6386     $self-><AG::ManakaiDISResourceDefinition
6387     .ownerClassURI>,
6388     $self->{for},
6389     node => $node);
6390     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
6391     ($class_uri);
6392 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
6393 wakaba 1.13 ($node || $self->{src});
6394     my $const = $class-><M::ManakaiDISResourceDefinition
6395     .getConstResourceByName> ($const_name);
6396     unless (defined $const) {
6397     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6398     DIS:sourceNode => {$node || $self->{src}},
6399     DIS:sourceCode => {$source_code},
6400     DIS:localName => {$const_name},
6401 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
6402 wakaba 1.13 }__}__;
6403     }
6404 wakaba 1.14 my $pc = $const-><AG::ManakaiDISResourceDefinition
6405 wakaba 1.13 .plCodeFragment>->clone;
6406     unless (defined $pc) {
6407     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
6408     DIS:sourceNode => {$node || $self->{src}},
6409     DIS:sourceCode => {$source_code},
6410     DIS:localName => {$const_name},
6411     }__}__;
6412     }
6413     $r-><M::PLInCon.appendCodeFragment> ($pc);
6414     } else {
6415     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
6416     DIS:elementType => {$et},
6417     DIS:sourceNode => {$node || $self->{src}},
6418 wakaba 1.16 DIS:sourceCode => {$source_code},
6419 wakaba 1.13 }__}__;
6420     }
6421     } else {
6422     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
6423     DIS:sourceNode => {$node || $self->{src}},
6424     DIS:sourceCode => {$source_code},
6425 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
6426 wakaba 1.13 }__}__;
6427     }
6428     } else {
6429 wakaba 1.18 for my $source_code (split /\b( t r u e \b|
6430     f a l s e \b|
6431     n u l l \b|
6432     t r y \s* \{)/x, $source_code) {
6433 wakaba 1.16 if ({
6434     'tr'.'ue' => true,
6435     'fal'.'se' => true,
6436     'nu'.'ll' => true,
6437     }->{$source_code}) {
6438     $r-><M::PLAnyCon.appendAtom> ({
6439     'tr'.'ue' => 1,
6440     'fal'.'se' => 0,
6441     'nu'.'ll' => 'undef',
6442     }->{$source_code});
6443 wakaba 1.18 } elsif ($source_code =~ /^t r y \s* \x7B$/x) {
6444     $r-><M::PLInCon.appendCode> ('tr'.
6445     'y '."\x7B".'local $Error::Depth = $Error::Depth + 3;');
6446 wakaba 1.20 $r-><M::MPLCodeFragment.addUsePerlModuleName>
6447     ('Message::Util::Error');
6448 wakaba 1.16 } else {
6449     $r-><M::PLInCon.appendCode> ($source_code);
6450     }
6451     }
6452     } # Inline instruction or not
6453 wakaba 1.13 } # for
6454     }__; # DEEP
6455    
6456     @Attr:
6457     @@Name: ownerClassURI
6458     @@enDesc:
6459     The URI reference of the class resource this resource
6460     belongs to.
6461     @@Type: ResourceURI
6462     @@Get:
6463     @@@enDesc:
6464     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
6465     If this resource is a class, then the URI reference
6466     of this resource is returned.
6467     @@@nullCase:
6468     @@@@enDesc:
6469     This resource does not belong to any class.
6470     @@@PerlDef:
6471     if (exists $self->{<Q::DIS:ownerClass>}) {
6472     $r = $self->{<Q::DIS:ownerClass>};
6473     } else {
6474     my $res = $self;
6475     __DEEP{
6476     {
6477     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
6478     (<Q::ManakaiDOM:Class>)) {
6479     $r = $res->{uri};
6480     } else {
6481     $res = $res-><M::ManakaiDISPropertyAccessor
6482     .getPropertyResource> (<Q::dis2pm:parentResource>);
6483     redo if $res;
6484     }
6485     }
6486     }__;
6487     $self->{<Q::DIS:ownerClass>} = $r;
6488     }
6489    
6490     @IntMethod:
6491     @@Name: plParsePreprocessParameter
6492     @@enDesc:
6493     Parses a parameter specification in preprocessing instruction
6494     and return it as a hash reference.
6495     \
6496     {NOTE:: The callee have to ensure that this resource has its
6497     <CODE::src> before the call to this method.
6498     \
6499     }
6500     @@Param:
6501     @@@Name: paramSpec
6502     @@@Type:
6503     DISLang:String::ManakaiDOM:all
6504     @@@enDesc:
6505     A parameter specification to parse.
6506     @@NodeParam:
6507     @@Return:
6508     @@@Type:
6509     Perl:hash::ManakaiDOM:all
6510     @@@enDesc:
6511     Hash containing parameters. Each hash value is also
6512     a hash reference, containing two keys <CODE::type>
6513     (its value is either <CODE::bare>, <CODE::quoted>,
6514     <CODE::code> or <CODE::variable>) and
6515     <CODE::value>.
6516     @@@RaiseException:
6517     @@@@@:BROKEN_PARAM_SPEC_ERR
6518     @@@@enDesc:
6519     The <P::paramSpec> is not well-formed.
6520     @@@PerlDef:
6521     our $RegQNameChar;
6522     our $RegBlockContent;
6523     $r = {};
6524     while ($paramSpec =~ s/^
6525     ## Parameter name
6526     (\$? $RegQNameChar+)\s*
6527    
6528     (?: =>? \s*
6529     ## ">" is now optional for inline element (">" is delimiter)
6530    
6531     ## Parameter value
6532     (
6533 wakaba 1.15 ## Variable or Bare string
6534     \ \$? $RegQNameChar+
6535 wakaba 1.13 |
6536     ## Quoted string
6537     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
6538     |
6539     ## Code
6540 wakaba 1.15 \ \{$RegBlockContent\}
6541 wakaba 1.13
6542     )
6543    
6544     \s*)?
6545    
6546     (?:,\s*|$)//ox) {
6547    
6548     my ($n, $v) = ($1, $2);
6549     if (defined $v) {
6550     if ($v =~ /^'/) {
6551     $v = {type => 'quoted',
6552     value => substr ($v, 1, length ($v) - 2)};
6553     } elsif ($v =~ /^\{/) {
6554     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
6555     } elsif ($v =~ /^\$/) {
6556 wakaba 1.21 $v = {type => 'variable', value => substr $v, 1};
6557 wakaba 1.13 } else {
6558     $v = {type => 'bare', value => $v};
6559     }
6560     } else {
6561     $v = {type => 'boolean', value => true};
6562     }
6563    
6564     if ($n =~ /^\$/) {
6565     $r->{$n} = $v;
6566     } else {
6567     __DEEP{
6568     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
6569     ($n, node => $node || $self->{src})} = $v;
6570     }__;
6571     }
6572     } # while
6573    
6574     if (length $paramSpec) {
6575     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
6576     DIS:sourceCode => {$paramSpec},
6577     DIS:sourceNode => {$node || $self->{src}},
6578     }__;
6579     }
6580    
6581 wakaba 1.15 @IntMethod:
6582     @@Name: plGetContextParameter
6583     @@enDesc:
6584     Returns contextual parameters which describes the <QUOTE::location>
6585     of this resource.
6586     @@Return:
6587     @@@Type:
6588     Perl:hash::ManakaiDOM:all
6589     @@@enDesc:
6590     Hash of parameters as <M::.plParsePreprocessParameter> returns.
6591     @@@PerlDef:
6592     $r = {};
6593     __DEEP{
6594     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6595     (<Q::DISLang:MethodReturn>)) {
6596     my $method = $self-><M::ManakaiDISPropertyAccessor
6597     .getPropertyResource> (<Q::dis2pm:parentResource>);
6598     $r->{<Q::MDOMX:method>}
6599     = {type => 'quoted',
6600     value => $method-><AG::ManakaiDISResourceDefinition.plName>};
6601     my $class = $method-><M::ManakaiDISPropertyAccessor
6602     .getPropertyResource> (<Q::dis2pm:parentResource>);
6603     $r->{<Q::MDOMX:class>}
6604     = {type => 'quoted',
6605     value => $class-><AG::ManakaiDISResourceDefinition
6606     .plFullyQualifiedName>};
6607     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6608     (<Q::DISLang:AttributeGet>)) {
6609     my $attr = $self-><M::ManakaiDISPropertyAccessor
6610     .getPropertyResource> (<Q::dis2pm:parentResource>);
6611     $r->{<Q::MDOMX:attr>}
6612     = {type => 'quoted',
6613     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
6614     my $class = $attr-><M::ManakaiDISPropertyAccessor
6615     .getPropertyResource> (<Q::dis2pm:parentResource>);
6616     $r->{<Q::MDOMX:class>}
6617     = {type => 'quoted',
6618     value => $class-><AG::ManakaiDISResourceDefinition
6619     .plFullyQualifiedName>};
6620     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'get'};
6621     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6622     (<Q::DISLang:AttributeSet>)) {
6623     my $attr = $self-><M::ManakaiDISPropertyAccessor
6624     .getPropertyResource> (<Q::dis2pm:parentResource>);
6625     $r->{<Q::MDOMX:attr>}
6626     = {type => 'quoted',
6627     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
6628     my $class = $attr-><M::ManakaiDISPropertyAccessor
6629     .getPropertyResource> (<Q::dis2pm:parentResource>);
6630     $r->{<Q::MDOMX:class>}
6631     = {type => 'quoted',
6632     value => $class-><AG::ManakaiDISResourceDefinition
6633     .plFullyQualifiedName>};
6634     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'set'};
6635     } else {
6636     $r->{<Q::MDOMX:resourceURI>} = {type => 'quoted',
6637     value => $self->{uri}};
6638     }
6639     }__;
6640    
6641     @Method:
6642     @@Name: plGetMethodInputNormalizer
6643     @@enDesc:
6644     Returns an input processor. This method assumes that
6645 wakaba 1.19 this resource is a method parameter (<Q::DISLang:MethodParameter>)
6646     or an attribute setter (<Q::DISLang:AttributeSet>).
6647 wakaba 1.15 @@Return:
6648     @@@Type:ManakaiDISResourceDefinition
6649     @@@enDesc:
6650     A <Q::DISLang:InputProcessor> corresponding to
6651     the parameter defined by this resource.
6652     \
6653     {NOTE:: <Q::ManakaiDOM:inputNormalize> property is
6654     obsolete in favor of <Q::DISLang:InputProcessor>;
6655     this method does not support the former.
6656     \
6657     }
6658     @@@nullCase:
6659     @@@@enDesc:
6660     No input processor found.
6661     @@@PerlDef:
6662     my $type;
6663     try {
6664     $type = $self-><AG::ManakaiDISResourceDefinition
6665     .disActualDataTypeResource>;
6666 wakaba 1.16 #$type_node = $self->< AG::ManakaiDISResourceDefinition
6667 wakaba 1.15 # .disActualDataTypeNode>;
6668     } catch <Class::ManakaiDISException> with {
6669     my $err = shift;
6670     unless ($err->{<Q::MDOMX:subtype>} eq <Q::DIS:NO_DIS_TYPE_ERR>) {
6671     $err->throw;
6672     }
6673     };
6674     if ($type) {
6675     __DEEP{
6676     $r = $type-><M::ManakaiDISResourceDefinition.getChildResourceByType>
6677     (<Q::DISLang:InputProcessor>);
6678     }__;
6679     }
6680    
6681     @IntMethod:
6682     @@Name: plAppendThrow
6683     @@enDesc:
6684     Appends a <Perl::report> method call statement for exception reporting.
6685     @@Param:
6686     @@@Name: parentNode
6687     @@@enDesc:
6688     The parent Perl code node to which a new statement is appended.
6689     @@@Type: PLBlockCon
6690     @@Param:
6691     @@@Name: xclass
6692     @@@Type: ManakaiDISResourceDefinition
6693     @@@enDesc:
6694     An exception class.
6695     @@Param:
6696     @@@Name: xcode
6697     @@@Type: ManakaiDISResourceDefinition
6698     @@@enDesc:
6699     An exception code constant.
6700     @@Param:
6701     @@@Name: xsubtype
6702     @@@Type: ManakaiDISResourceDefinition
6703     @@@enDesc:
6704     An exception subtype.
6705     @@@nullCase:
6706     @@@@enDesc:
6707     No subtype.
6708     @@Param:
6709     @@@Name: xparam
6710     @@@Type:
6711     Perl:hash::ManakaiDOM:all
6712     @@@enDesc:
6713     A hash containing parameters passed to the <Perl:report> method.
6714     A hash key is to be a parameter name. Hash values
6715     should also be hashes. A hash value hash has two values:
6716     <CODE::type> and <CODE::value>. A <CODE::value>
6717     value is a parameter value. If <CODE::type> is
6718     <CODE::code>, then <CODE::value> is assumed as a Perl code fragment.
6719     Otherwise, <CODE::value> is quoted to be interpreted as a string as is.
6720     @@Return:
6721 wakaba 1.16 @@@RaiseException:
6722     @@@@@: RESOURCE_NOT_DEFINED_ERR
6723     @@@@enDesc:
6724     Either <P::xclass>, <P::xcode> or <P::xsubtype>
6725     is not defined.
6726 wakaba 1.15 @@@PerlDef:
6727     my $statement = $parentNode-><M::PLBlockCon.appendStatement>
6728     ('report '.
6729     $xclass-><AG::ManakaiDISResourceDefinition.plFullyQualifiedName>.
6730     ' -object => $self');
6731 wakaba 1.16 my $xclass_module = $xclass-><AG::ManakaiDISResourceDefinition
6732 wakaba 1.22 .ownerModule>;
6733 wakaba 1.16 unless ($xclass-><AG::ManakaiDISResourceDefinition.isDefined> or
6734     not $xclass_module) {
6735     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6736     DIS:sourceNode => {$self->{src}},
6737     DIS:uri => {$xclass->{uri}},
6738     DIS:localName => {$xclass->{localName}},
6739     DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
6740     }__;
6741     }
6742 wakaba 1.22 $xclass_module-><AS::ManakaiDISResourceDefinition
6743     .isReferred> ($self->{src});
6744 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
6745     ($xclass_module => $statement);
6746 wakaba 1.15 $xparam->{-type} = {type => 'quoted',
6747     value => $xcode-><AG::ManakaiDISResourceDefinition
6748     .plName>};
6749     $xparam->{<Q::MDOMX:subtype>} = {type => 'quoted',
6750     value => $xsubtype->{nameURI}}
6751     if $xsubtype;
6752     for my $name (keys %$xparam) {
6753     my $pname = $name;
6754     $pname =~ s/(['\\])/\\$1/g;
6755     $pname = qq<'$pname'>;
6756     $statement-><M::PLInCon.appendCode>
6757     (', ' . $pname . ' => ');
6758     if ($xparam->{$name}->{type} eq 'code') {
6759     if (ref $xparam->{$name}->{value}) {
6760     $statement-><M::PLInCon.appendCodeFragment>
6761     ($xparam->{$name}->{value});
6762     } else {
6763 wakaba 1.16 $statement-><M::PLInCon.appendCodeFragment>
6764 wakaba 1.15 ($self-><M::ManakaiDISResourceDefinition
6765     .plPreprocessPerlStatement>
6766     ($xparam->{$name}->{value}));
6767     }
6768     } else { ## String as is
6769     $statement-><M::PLAnyCon.appendStringLiteral>
6770     ($xparam->{$name}->{value});
6771     }
6772     }
6773    
6774 wakaba 1.18 @Attr:
6775     @@Name: plIsNullable
6776     @@enDesc:
6777     Whether this resource is <QUOTE::nullable> or not.
6778     <QUOTE::Nullability> is defined for method parameters,
6779     method returns, attribute getters and attribute setters.
6780     @@Type:
6781     DOMMain:boolean::ManakaiDOM:all
6782     @@Get:
6783     @@@RaiseException:
6784     @@@@@:NO_DIS_TYPE_ERR
6785     @@@@enDesc:
6786     There is a <Q::ManakaiDOM:InCase> child resource
6787     that does not have <Q::dis:Type> attribute.
6788     @@@PerlDef:
6789     __DEEP{
6790     for my $incase (@{$self-><M::ManakaiDISPropertyAccessor
6791     .getPropertyResourceList>
6792     (<Q::DIS:childResource>)}) {
6793     next unless $incase-><M::ManakaiDISResourceDefinition.isTypeURI>
6794     (<Q::ManakaiDOM:InCase>);
6795     if ($incase-><AG::ManakaiDISResourceDefinition.disIsNullValue> or
6796     $incase-><AG::ManakaiDISResourceDefinition
6797     .disActualDataTypeResource>
6798     -><M::ManakaiDISResourceDefinition
6799     .isSubsetOfURI> (<Q::DOMMain:boolean>)) {
6800     $r = true;
6801     last;
6802     }
6803     }
6804     }__;
6805    
6806     @Attr:
6807     @@Name: disIsNullValue
6808     @@enDesc:
6809     Whether this resource have <DOM::null> value or not.
6810     A resource have <DOM::null> value iff it has
6811     <Q::dis:Value> attribute node that in turn has
6812     <Q::dis:is-null> attribute whose value set to <DOM::true>.
6813     @@Type:
6814     DOMMain:boolean::ManakaiDOM:all
6815     @@Get:
6816     @@@PerlDef:
6817     if ($self->{src}) {
6818     __DEEP{
6819     my $val = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6820     (<Q::dis:Value>,
6821     for_arg => $self->{for},
6822     forp_arg => $self->{forp});
6823     if ($val) {
6824     my $isnull = $val-><M::ManakaiDISElement.disGetAttribute>
6825     (<Q::dis:is-null>,
6826     for_arg => $self->{for},
6827     forp_arg => $self->{forp});
6828     if ($isnull and $isnull-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
6829     .value>) {
6830     $r = true;
6831     }
6832     }
6833     }__;
6834     }
6835 wakaba 1.19
6836     @Attr:
6837     @@Name:plIsDefined
6838     @@enDesc:
6839     Whether a Perl implementation for this resource is available or not.
6840     @@Type:
6841     DOMMain:boolean::ManakaiDOM:all
6842     @@Get:
6843     @@@TrueCase:
6844     @@@@enDesc:
6845     This resource has its Perl definition and it is implemented.
6846     @@@FalseCase:
6847     @@@@enDesc:
6848     Either this resource does not have any Perl definition
6849     or it does have but it is not implemented yet.
6850     @@@PerlDef:
6851     if (exists $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>}) {
6852     $r = $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>};
6853     } else {
6854     __DEEP{
6855     my $typeuri = {
6856     <Q::ManakaiDOM:Class> => [
6857     <Q::DISLang:Method>, <Q::DISLang:Attribute>,
6858     ],
6859     <Q::DISLang:Method> => [
6860     <Q::DISLang:MethodReturn>,
6861     ],
6862     <Q::DISLang:Attribute> => [
6863     <Q::DISLang:AttributeGet>, <Q::DISLang::AttributeSet>,
6864     ],
6865     };
6866     OUTMOST:
6867     for my $mytype (keys %$typeuri) {
6868     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI> ($mytype)) {
6869     for my $ctype ($typeuri->{$mytype}) {
6870     for my $cres (@{$self-><M::ManakaiDISPropertyAccessor
6871     .getPropertyResourceList>
6872     (<Q::DIS:childResource>)}) {
6873     if ($cres-><M::ManakaiDISResourceDefinition.isTypeURI>
6874     ($ctype)) {
6875     unless ($cres-><AG::ManakaiDISResourceDefinition
6876     .plIsDefined>) {
6877     $r = false; last OUTMOST;
6878     }
6879     }
6880     }
6881     next OUTMOST;
6882     }
6883     }
6884     } # OUTMOST
6885     }__;
6886     $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>} = $r;
6887     }
6888 wakaba 1.20
6889     @IntMethod:
6890     @@Name: plAddRequireResource
6891     @@enDesc:
6892     Adds a resource to the list of resources that should
6893     be <Perl::require>d from a Perl code fragment.
6894     @@Param:
6895     @@@Name: resourceArg
6896     @@@Type: ManakaiDISResourceDefinition
6897     @@@enDesc:
6898     A resource that is <Perl::require>d by <P::codeArg>.
6899     @@Param:
6900     @@@Name: codeArg
6901     @@@Type: MPLCodeFragment
6902     @@@enDesc:
6903     A code fragment. <P::resourceArg> is added to the
6904     list of <Perl::require>d resources of this code fragment.
6905     @@Return:
6906     @@@PerlDef:
6907     __DEEP{
6908     $codeArg-><M::MPLCodeFragment.disAddRequireURI>
6909     ($resourceArg-><AG::ManakaiDISResourceDefinition.uri>);
6910     }__;
6911 wakaba 1.21
6912 wakaba 1.22 @Attr:
6913     @@ManakaiDOM:isForInternal:1
6914 wakaba 1.21 @@Name: plMufDescriptionText
6915     @@enDesc:
6916     {TODO:: Formal documentation-access API required.
6917     \
6918     }
6919 wakaba 1.22 @@Get:
6920 wakaba 1.21 @@@Type:
6921     DISLang:String::ManakaiDOM:all
6922     @@@PerlDef:
6923     __DEEP{
6924     my $muf = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6925     (<Q::dis:Def>, for_arg => $self->{for},
6926     forp_arg => $self->{forp},
6927     media_type => <Q::lang:muf>);
6928     if ($muf) {
6929     $r = $muf-><M::SWCFGNode.value>;
6930     $r =~ s/<Q::([^<>]+)>/$self->{src}-><M::ManakaiDISElement.
6931     qnameToURI> ($1, node => $muf)/ge;
6932     $r =~ s/\s+/ /g;
6933     $r =~ s/^ //;
6934     $r =~ s/ $//;
6935     } else {
6936     my $desc = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6937     (<Q::dis:Description>, for_arg => $self->{for},
6938     forp_arg => $self->{forp},
6939     media_type => <Q::lang:disdoc>,
6940     default_media_type => <Q::lang:disdoc>);
6941     if ($desc) {
6942     $r = $desc-><M::SWCFGNode.value>;
6943     $r =~ s/\s+/ /g;
6944     $r =~ s/^ //;
6945     $r =~ s/ $//;
6946     $r =~ s/%/%percent;/g;
6947     }
6948     }
6949     }__;
6950     @@@ImplNote:
6951     @@@@lang:en
6952     @@@@@: Currently only common-used patterns are supported.
6953 wakaba 1.24
6954     @Method:
6955     @@Name: isFeatureProvided
6956     @@enDesc:
6957     Whether a feature is provided by this resource or not.
6958     Note that the feature is actually available (implemented)
6959     or not is other thing (use <M::ManakaiDISPerlModuleDefinition
6960     .plIsFeatureImplemented> instead).
6961     @@Param:
6962     @@@Name: featureResourceURI
6963     @@@Type: ResourceURI
6964     @@@enDesc:
6965     The URI reference of the resource definition for the feature to test.
6966     @@Return:
6967     @@@Type:
6968     DOMMain:boolean::ManakaiDOM:all
6969     @@@enDesc:
6970     Whether the feature is provided or not.
6971     @@@PerlDef:
6972     __DEEP{
6973     my @f = @{$self-><M::ManakaiDISPropertyAccessor
6974     .getPropertyResourceList>
6975     (<Q::DOMMain:implementFeature>,
6976 wakaba 1.26 isa_recursive => true,
6977 wakaba 1.24 default_media_type => <Q::dis:TypeQName>)};
6978     if (@f) {
6979     for my $f (@f) {
6980     if ($f-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
6981     ($featureResourceURI)) {
6982     $r = true;
6983     last;
6984     }
6985     }
6986     } else {
6987     my $parent = $self-><M::ManakaiDISPropertyAccessor
6988     .getPropertyResource>
6989     (<Q::dis2pm:parentResource>);
6990     $r = $parent-><M::ManakaiDISResourceDefinition.isFeatureProvided>
6991     ($featureResourceURI)
6992     if $parent;
6993     }
6994     }__;
6995    
6996     @Attr:
6997     @@Name: featureNameList
6998     @@enDesc:
6999     The list of the names of the feature defined by this resource.
7000     @@Type:
7001     Perl:ARRAY::ManakaiDOM:all
7002     @@Get:
7003     @@@RaiseException:
7004     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
7005     @@@@enDesc:
7006     There is an <Q::dis:AppName> attribute whose media
7007     type is not supported.
7008     @@@RaiseException:
7009     @@@@@: NO_SOURCE_NODE_ERR
7010     @@@@enDesc:
7011     This resource definition does not have associated node
7012     in the source tree.
7013     @@@PerlDef:
7014     unless ($self->{src}) {
7015     __EXCEPTION{NO_SOURCE_NODE_ERR::
7016     DIS:uri => {$self->{uri}},
7017     }__;
7018     }
7019     __DEEP{
7020     for my $ce (@{$self->{src}-><M::ManakaiDISElement.disChildElements>
7021     (for_arg => $self->{for},
7022     forp_arg => $self->{forp})}) {
7023     if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest.expandedURI>
7024     eq <Q::dis:AppName>) {
7025     if ($ce-><M::ManakaiDISElement.mediaTypeMatch>
7026     (<Q::dis:TypeQName>,
7027     for_arg => $self->{for},
7028     forp_arg => $self->{forp},
7029     default_media_type => <Q::dis:String>)) {
7030     push @$r, lc $ce-><AG::ManakaiDISElement.qnameValueURI>;
7031     } elsif ($ce-><M::ManakaiDISElement.mediaTypeMatch>
7032     (<Q::dis:String>,
7033     for_arg => $self->{for},
7034     forp_arg => $self->{forp},
7035     default_media_type => <Q::dis:String>)) {
7036     push @$r, lc $ce-><M::SWCFGNode.value>;
7037     } else {
7038     my $mt = $ce-><M::ManakaiDISElement.mediaTypeURI>
7039     (for_arg => $self->{for},
7040     forp_arg => $self->{forp});
7041     __UNDEEP{
7042     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
7043     DIS:uri => {$mt},
7044     DIS:sourceNode => {$ce},
7045     }__;
7046     }__;
7047     }
7048     }
7049     }
7050     unless (@$r) {
7051     if ($self-><AG::ManakaiDISResourceDefinition.isAnonymous>) {
7052     my $ln = $self-><AG::ManakaiDISResourceDefinition.localName>;
7053     push @$r, $ln if defined $ln;
7054     } else {
7055     push @$r, $self-><AG::ManakaiDISResourceDefinition.nameURI>;
7056     }
7057     }
7058     }__;
7059 wakaba 1.2 ##DISResourceDefinition
7060    
7061 wakaba 1.19 PropDef:
7062     @QName:plDefined
7063     @enDesc:
7064     Whether a Perl definition for this resource is implemented or not.
7065    
7066 wakaba 1.13 ElementTypeBinding:
7067 wakaba 1.15 @Name: BlockElementException
7068     @ElementType:
7069     ManakaiDOM:raises
7070     @ShadowContent:
7071     @@@: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
7072     @@Description:
7073     @@@lang:en
7074     @@@@:
7075     An exception type specification is required but not specified.
7076     @ShadowSibling:
7077     @@ManakaiDOM:raises:
7078     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
7079     @@@Description:
7080     @@@@lang:en
7081     @@@@@:
7082     A code qualified name is required but not specified.
7083     @@ManakaiDOM:raises:
7084     @@@@: RESOURCE_NOT_DEFINED_ERR
7085     @@@Description:
7086     @@@@lang:en
7087     @@@@@:
7088     A referred resource is not defined or has different type.
7089     @@ManakaiDOM:raises:
7090     @@@@: PERL_CODE_NOT_DEFINED_ERR
7091     @@@Description:
7092     @@@@lang:en
7093     @@@@@:
7094     A referred resource does not have its Perl definition.
7095     @@ManakaiDOM:raises:
7096     @@@@: PERL_PREPROCESS_NO_METHOD_ERR
7097     @@@Description:
7098     @@@@lang:en
7099     @@@@@:
7100     A preprocessing instruction which is allowed only in
7101     methods is embeded in a context which is not in any method.
7102     @@ManakaiDOM:raises:
7103     @@@@: PERL_PREPROCESS_NO_FOR_ERR
7104     @@@Description:
7105     @@@@lang:en
7106     @@@@@:
7107     A <QUOTE::for> qualified name is required but not specified.
7108     @@ManakaiDOM:raises:
7109     @@@@: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
7110     @@@Description:
7111     @@@@lang:en
7112     @@@@@:
7113     An assertion type qualified name is required but not specified.
7114     @@ManakaiDOM:raises:
7115     @@@@: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
7116     @@@Description:
7117     @@@@lang:en
7118     @@@@@:
7119     A preprocessing instruction block is specified
7120     but not allowed for this element type.
7121    
7122     ElementTypeBinding:
7123 wakaba 1.13 @Name: InlineElementException
7124     @ElementType:
7125     ManakaiDOM:raises
7126     @ShadowContent:
7127     @@@: NO_SOURCE_NODE_ERR
7128     @@Description:
7129     @@@lang:en
7130     @@@@:
7131     This resource definition does not have associated node
7132     in the source tree.
7133     @ShadowSibling:
7134     @@ManakaiDOM:raises:
7135     @@@@: INTERFACE_CLASS_METHOD_ERR
7136     @@@Description:
7137     @@@@lang:en
7138     @@@@@:
7139     An attempt is made to call a class (static) method
7140     via an interface, not class.
7141     @@ManakaiDOM:raises:
7142     @@@@: RESOURCE_NOT_DEFINED_ERR
7143     @@@Description:
7144     @@@@lang:en
7145     @@@@@:
7146     A package, method or attribute is not defined or not
7147     a resoure of that type.
7148     @@ManakaiDOM:raises:
7149     @@@@: NO_LOCAL_NAME_ERR
7150     @@@Description:
7151     @@@@lang:en
7152     @@@@@:
7153     A referred resource does not have its local name so
7154     that it is impossible to refer it by name.
7155     @@ManakaiDOM:raises:
7156     @@@@: RESERVED_PERL_METHOD_NAME_ERR
7157     @@@Description:
7158     @@@@lang:en
7159     @@@@@:
7160     A referred method has its name reserved for special-purpose.
7161     @@ManakaiDOM:raises:
7162     @@@@: BROKEN_PARAM_SPEC_ERR
7163     @@@Description:
7164     @@@@lang:en
7165     @@@@@:
7166     A parameter specification is not well-formed.
7167     @@ManakaiDOM:raises:
7168     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
7169 wakaba 1.14 @@@Description:
7170     @@@@lang:en
7171     @@@@@:
7172     A preprocessing instruction does not contain
7173     Perl code fragment name.
7174 wakaba 1.13 @@ManakaiDOM:raises:
7175     @@@@: PERL_CODE_NOT_DEFINED_ERR
7176 wakaba 1.14 @@@Description:
7177     @@@@lang:en
7178     @@@@@:
7179     The referred resource does not have its Perl definition.
7180 wakaba 1.13 @@ManakaiDOM:raises:
7181     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
7182 wakaba 1.14 @@@Description:
7183     @@@@lang:en
7184     @@@@@:
7185     A preprocessing instruction does not contain its element type name.
7186 wakaba 1.13 @@ManakaiDOM:raises:
7187     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
7188 wakaba 1.14 @@@Description:
7189     @@@@lang:en
7190     @@@@@:
7191     An unknown element type is encounted.
7192     @@ManakaiDOM:raises:
7193     @@@@: NO_PERL_PACKAGE_NAME_ERR
7194     @@@Description:
7195     @@@@lang:en
7196     @@@@@:
7197     No Perl package name is defined for a class or interface.
7198 wakaba 1.13
7199     PropDef:
7200     @QName: ownerClass
7201     @enDesc:
7202     The class to which this resource belongs.
7203     @Type: ResourceURI
7204     @rdfs:range:
7205     rdf:Resource
7206     @rdfs:domain:
7207     ManakaiDOM:Class
7208    
7209 wakaba 1.12 ResourceDef:
7210     @QName: DOMMinImpl
7211     @rdf:type:
7212     ManakaiDOM:IF
7213     @AliasFor:
7214     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
7215    
7216     ResourceDef:
7217 wakaba 1.20 @QName: PLPack
7218     @rdf:type:
7219     ManakaiDOM:Class
7220     @AliasFor:
7221     PerlCode:ManakaiPerlPackageScope::ManakaiDOM:Perl
7222    
7223     ResourceDef:
7224 wakaba 1.12 @QName: SWCFGNode
7225     @rdf:type:
7226     ManakaiDOM:IF
7227     @AliasFor:
7228     swcfg21:SWCFGNode::swcfg21:ForLatest
7229    
7230     ResourceDef:
7231     @QName: SWCFGDoc
7232     @rdf:type:
7233     ManakaiDOM:IF
7234     @AliasFor:
7235     swcfg21:SWCFGDocument::swcfg21:ForLatest
7236    
7237     ResourceDef:
7238     @QName: MPLImpl
7239     @rdf:type:
7240     ManakaiDOM:Class
7241     @AliasFor:
7242     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
7243    
7244     ResourceDef:
7245     @QName: MPLCodeFragment
7246     @rdf:type:
7247     ManakaiDOM:Class
7248     @AliasFor:
7249     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
7250    
7251     ResourceDef:
7252 wakaba 1.13 @QName: PLInCon
7253     @rdf:type:
7254     ManakaiDOM:Class
7255     @AliasFor:
7256     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
7257    
7258     ResourceDef:
7259 wakaba 1.15 @QName: PLBlockCon
7260     @rdf:type:
7261     ManakaiDOM:Class
7262     @AliasFor:
7263     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
7264    
7265     ResourceDef:
7266 wakaba 1.13 @QName: PLAnyCon
7267     @rdf:type:
7268     ManakaiDOM:Class
7269     @AliasFor:
7270     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
7271    
7272     ResourceDef:
7273     @QName: MPLSS
7274     @rdf:type:
7275     ManakaiDOM:Class
7276     @AliasFor:
7277     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
7278    
7279     ResourceDef:
7280 wakaba 1.12 @QName: MPLSub
7281     @rdf:type:
7282     ManakaiDOM:Class
7283     @AliasFor:
7284     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
7285    
7286     ResourceDef:
7287     @QName: MPLUnparsedCode
7288     @rdf:type:
7289     ManakaiDOM:Class
7290     @AliasFor:
7291     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
7292    
7293     PropDef:
7294     @QName: plCodeFragment
7295     @enDesc:
7296     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
7297    
7298     XParamDef:
7299     @QName: errResource
7300     @enDesc:
7301     A resource on which an error has occurred.
7302    
7303 wakaba 1.8 XParamDef:
7304     @QName: generatedName
7305     @enDesc:
7306     A generated name.
7307    
7308 wakaba 1.2 ClsDef:
7309     @ClsQName: ManakaiDISPropertyAccessor
7310 wakaba 1.3 @enDesc:
7311 wakaba 1.2 Accessor methods for resource or module properties.
7312    
7313 wakaba 1.22 @Attr:
7314     @@Name:plImplementation
7315     @@enDesc:
7316     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
7317     @@Type: MPLImpl
7318     @@Get:
7319     @@@enDesc:
7320     The Perl code implementation object.
7321     @@@nullCase:
7322     This resource has no source tree associated.
7323     @@@RaiseException:
7324     @@@@@:NO_PERL_CODE_IMPL_ERR
7325     @@@@enDesc:
7326     There is no implementation that implements
7327     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
7328     @@@PerlDef:
7329     if ($self->{src}) {
7330     __DEEP{
7331     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
7332     $self->{src})-><AG::SWCFGDoc.implementation>
7333     -><M::DOMMinImpl.getFeature>
7334     (<Q::Util:PerlCode> => '1.0');
7335     }__;
7336     unless (defined $r) {
7337     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
7338    
7339     }__;
7340     }
7341     }
7342    
7343     @Attr:
7344     @@Name: ownerModule
7345     @@enDesc:
7346     The <QUOTE::dis> module in which this object is defined.
7347     For a <QUOTE::dis> module object, the module itself is the
7348     <QUOTE::owner>.
7349     @@Get:
7350     @@@Type: ManakaiDISModuleDefinition
7351     @@@PerlDef: $r = $self;
7352    
7353     @Attr:
7354     @@Name: sourceElement
7355     @@enDesc:
7356     The source <QUOTE::dis> element node from which this
7357     definition is read.
7358     @@Get:
7359     @@@Type: ManakaiDISElement
7360     @@@InCase:
7361     @@@@Type: ManakaiDISModuleElement
7362     @@@@enDesc: If this resource is a module.
7363     @@@PerlDef: $r = $self->{src};
7364     @@@nullCase:
7365     @@@@enDesc:
7366     The definition is not yet read.
7367    
7368 wakaba 1.2 @Method:
7369 wakaba 1.8 @@Name: getPropertyBoolean
7370     @@enDesc:
7371     Gets boolean property value.
7372     @@PropNameParam:
7373     @@Param:
7374     @@@Name:default
7375     @@@Type:
7376     DOMMain:boolean::ManakaiDOM:all
7377     @@@enDesc:
7378     The default value that is returned if no explicit property
7379     value specification found for this resource.
7380     @@Return:
7381     @@@Type:
7382     DOMMain:boolean::ManakaiDOM:all
7383     @@@enDesc:
7384     The property value.
7385     @@@PerlDef:
7386     if (exists $self->{$propName}) {
7387     $r = defined $self->{$propName} ? $self->{$propName} : $default;
7388     } elsif ($self->{src}) {
7389 wakaba 1.18 my $attr_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7390 wakaba 1.8 ($propName, for_arg => $self->{for},
7391     forp_arg => $self->{forp});
7392 wakaba 1.18 $r = $self->{$propName} = ($attr_node
7393     ? ($attr_node-><M::SWCFGNode.value>
7394     ? true : false)
7395     : null);
7396 wakaba 1.8 $r = $default unless defined $r;
7397     } else {
7398     $r = $default;
7399     }
7400    
7401     @Method:
7402 wakaba 1.2 @@Name: getPropertyText
7403     @@enDesc:
7404     Gets property value text.
7405     @@PropNameParam:
7406     @@Param:
7407     @@@Name:default
7408     @@@Type:
7409 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
7410 wakaba 1.2 @@@enDesc:
7411     The default value that is returned if no explicit property
7412     value specification found for this resource.
7413     @@@nullCase:
7414     @@@@enDesc:
7415     No default value supplied; <DOM::null> is returned if
7416     no value specified.
7417     @@Return:
7418     @@@Type:
7419 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
7420 wakaba 1.2 @@@enDesc:
7421     The property value string.
7422     @@@nullCase:
7423     @@@@enDesc:
7424     No value nor default value has specified.
7425     @@@PerlDef:
7426     if (exists $self->{$propName}) {
7427     $r = defined $self->{$propName} ? $self->{$propName} : $default;
7428     } elsif ($self->{src}) {
7429     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7430     ($propName, for_arg => $self->{for},
7431     forp_arg => $self->{forp});
7432 wakaba 1.8 if ($r) {
7433     $r = $self->{$propName}
7434 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
7435 wakaba 1.8 $r = $default unless defined $r;
7436     } else {
7437     $r = $default;
7438     $self->{$propName} = null;
7439     }
7440 wakaba 1.2 } else {
7441     $r = $default;
7442     }
7443    
7444     @Method:
7445     @@Name: getPropertyResource
7446     @@enDesc:
7447     Gets property value resource.
7448     @@PropNameParam:
7449 wakaba 1.10 @@NamedParam:
7450     @@@Name: defaultMediaType
7451     @@@Type: ResourceURI
7452     @@@enDesc:
7453     The URI reference of the default media type which is used
7454     when the property value is retrieved from the source tree
7455     and the source tree element does not have its <Q::dis:ContentType>
7456     attribute specified.
7457     @@@nullCase:
7458     @@@@enDesc:
7459     Defaulted to <Q::dis:TypeQName>.
7460 wakaba 1.2 @@Return:
7461     @@@Type: ManakaiDISResourceDefinition
7462     @@@enDesc:
7463     The property value resource.
7464     @@@nullCase:
7465     @@@@enDesc:
7466     No value has specified.
7467 wakaba 1.8 @@@UndeclaredPrefixException:
7468 wakaba 1.12 @@@RaiseException:
7469     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
7470     @@@@enDesc:
7471     The media type of the attribute node in the source tree
7472     corresponding to this resource is not supported.
7473 wakaba 1.2 @@@PerlDef:
7474     if (defined $self->{$propName}) {
7475 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
7476     ($self->{$propName});
7477 wakaba 1.8 } elsif ($self->{src}) {
7478     __DEEP{
7479     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
7480     ($propName, for_arg => $self->{for},
7481     forp_arg => $self->{forp});
7482     if ($r) {
7483 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
7484     unless defined $defaultMediaType;
7485     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
7486 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
7487     for_arg => $self->{for},
7488     forp_arg => $self->{forp})) {
7489 wakaba 1.10 $self->{$propName}
7490     = $r-><AG::ManakaiDISElement.qnameValueURI>;
7491     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
7492 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
7493     for_arg => $self->{for},
7494     forp_arg => $self->{forp})) {
7495 wakaba 1.10 $self->{$propName}
7496     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
7497     ($self->{src}-><AG::swcfg21:SWCFGNode
7498     ::swcfg21:ForLatest.nodeID>,
7499     $self->{for});
7500     } else {
7501     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
7502     (for_arg => $self->{for},
7503     forp_arg => $self->{forp});
7504     __UNDEEP{
7505     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
7506     DIS:uri => {$mt},
7507     DIS:sourceNode => {$r},
7508     }__;
7509     }__;
7510     }
7511 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
7512     ($self->{$propName});
7513 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
7514 wakaba 1.8 }
7515     }__;
7516 wakaba 1.2 }
7517    
7518     @Method:
7519 wakaba 1.10 @@Name: getPropertyResourceList
7520     @@enDesc:
7521     Gets property value resource list.
7522     @@PropNameParam:
7523     @@NamedParam:
7524 wakaba 1.24 @@@Name: recursive
7525     @@@Type:
7526     DOMMain:boolean::ManakaiDOM:all
7527     @@@enDesc:
7528     Whether property resource values of this resource
7529     should also be included to the returned list or not.
7530     @@NamedParam:
7531 wakaba 1.10 @@@Name: recursiveISA
7532     @@@Type:
7533 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
7534 wakaba 1.10 @@@enDesc:
7535 wakaba 1.26 Whether the <Q::dis:ISA> ancestors of the resources
7536     that are property values should also be included in the returned list
7537     or not.
7538     @@@TrueCase:
7539     @@@@enDesc:
7540     If a property value is a resource <VAR::R> and
7541     the resource <VAR::R> <Q::dis:ISA>'s (or inherits) <VAR::S>, then
7542     the resource <VAR::S> is also a value in the list.
7543     @@@FalseCase:
7544     @@@@enDesc:
7545     Only the resources directly specified as property values is returned.
7546     @@NamedParam:
7547     @@@Name: isaRecursive
7548     @@@Type:
7549     DOMMain:boolean::ManakaiDOM:all
7550     @@@enDesc:
7551     Whether property resource values of <Q::dis:ISA> resources
7552     of this resource should also be included to the returned list or not.
7553     @@@TrueCase:
7554     @@@@enDesc:
7555     If this resource <Q::dis:ISA>'s (or inherits) another resource
7556     <VAR::S> and the <VAR::S> resource has a <P::propName>
7557     property value of <VAR::R>, then the resource <VAR::R>
7558     is also a value in the list.
7559     @@@FalseCase:
7560     @@@@enDesc:
7561     Only the resource directly specified is the returned.
7562 wakaba 1.10 @@NamedParam:
7563     @@@Name: defaultMediaType
7564     @@@Type: ResourceURI
7565     @@@enDesc:
7566     The URI reference of the default media type which is used
7567     when the property value is retrieved from the source tree
7568     and the source tree element does not have its <Q::dis:ContentType>
7569     attribute specified.
7570     @@@nullCase:
7571     @@@@enDesc:
7572     Defaulted to <Q::dis:TypeQName>.
7573     @@Return:
7574     @@@Type: ResourceList
7575     @@@enDesc:
7576     An array reference of the property value resources.
7577     \
7578     {NOTE:: This list is <QUOTE::dead>.
7579     \
7580     }
7581     @@@UndeclaredPrefixException:
7582 wakaba 1.12 @@@RaiseException:
7583     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
7584     @@@@enDesc:
7585     The media type of the attribute node in the source tree
7586     corresponding to this resource is not supported.
7587 wakaba 1.10 @@@PerlDef:
7588     $r = [];
7589     if (defined $self->{$propName}) {
7590 wakaba 1.26 for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
7591 wakaba 1.10 ? $self->{$propName} : []}) {
7592     push @$r,
7593 wakaba 1.26 $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
7594 wakaba 1.10 }
7595     } elsif ($self->{src}) {
7596     __DEEP{
7597     $self->{$propName} = [];
7598     $defaultMediaType = <Q::dis:TypeQName>
7599     unless defined $defaultMediaType;
7600     for my $res_name_node
7601     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
7602     ($propName, for_arg => $self->{for},
7603     forp_arg => $self->{forp})}) {
7604     my $res_uri;
7605     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
7606 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
7607     for_arg => $self->{for},
7608     forp_arg => $self->{forp})) {
7609 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
7610     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
7611 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
7612     for_arg => $self->{for},
7613     forp_arg => $self->{forp})) {
7614 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
7615     ($self->{src}-><AG::swcfg21:SWCFGNode
7616     ::swcfg21:ForLatest.nodeID>,
7617     $self->{for});
7618     } else {
7619     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
7620     (for_arg => $self->{for},
7621     forp_arg => $self->{forp});
7622     __UNDEEP{
7623     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
7624     DIS:uri => {$mt},
7625     DIS:sourceNode => {$res_name_node},
7626     }__;
7627     }__;
7628     }
7629 wakaba 1.26 push @{$self->{$propName}}, $res_uri;
7630 wakaba 1.10 my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
7631     ($res_uri);
7632     push @$r, $res;
7633 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
7634 wakaba 1.10 ($res_name_node);
7635     }
7636     }__;
7637     }
7638 wakaba 1.24 if ($recursive) {
7639     __DEEP{
7640     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
7641     my @p_res = @$r;
7642     for my $p_res (@p_res) {
7643     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
7644     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
7645     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
7646     .getPropertyResourceList>
7647     ($propName, recursive => true,
7648     recursive_isa => $recursiveISA,
7649     ___recursive_isa_done => $opt{___recursive_isa_done},
7650     default_media_type => $defaultMediaType)};
7651     }
7652     }__;
7653     }
7654 wakaba 1.10 if ($recursiveISA) {
7655     __DEEP{
7656     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
7657     my @p_res = @$r;
7658     for my $p_res (@p_res) {
7659     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
7660     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
7661     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
7662     .getPropertyResourceList>
7663     (<Q::dis:ISA>, recursive_isa => true,
7664 wakaba 1.24 recursive => $recursive,
7665 wakaba 1.10 ___recursive_isa_done => $opt{___recursive_isa_done},
7666     default_media_type => $defaultMediaType)};
7667     }
7668     }__;
7669     }
7670 wakaba 1.26 if ($isaRecursive) {
7671 wakaba 1.25 __DEEP{
7672     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
7673 wakaba 1.26 my @p_res = @{$self-><M::ManakaiDISPropertyAccessor
7674     .getPropertyResourceList>
7675     (<Q::dis:ISA>, recursive_isa => false,
7676     recursive => true,
7677     default_media_type => <Q::dis:TFQNames>)};
7678 wakaba 1.25 for my $p_res (@p_res) {
7679     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
7680 wakaba 1.26 .getPropertyResourceList>
7681     ($propName, recursive_isa => false,
7682     recursive => false,
7683     default_media_type => $defaultMediaType)};
7684 wakaba 1.25 }
7685     }__;
7686     }
7687    
7688     @Method:
7689 wakaba 1.2 @@Name: addPropertyResourceList
7690     @@enDesc:
7691     Adds a resource to a resource-list property value.
7692     \
7693     {ISSUE:: Should an exception be thrown if the property is
7694     not of list?
7695     \
7696     }
7697 wakaba 1.10 \
7698     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
7699     an item clears the list --- i.e. the property values
7700     in the source tree will be ignored. Call
7701     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
7702     before adding to avoid this behavior.
7703     \
7704     }
7705 wakaba 1.2 @@PropNameParam:
7706     @@Param:
7707     @@@Name: res
7708     @@@Type: ManakaiDISResourceDefinition
7709     @@@enDesc:
7710     A resource to add.
7711     @@Return:
7712     @@@PerlDef:
7713     if (ref $self->{$propName} eq 'ARRAY') {
7714 wakaba 1.26 push @{$self->{$propName}}, $res->{uri};
7715 wakaba 1.2 } elsif (not defined $self->{$propName}) {
7716 wakaba 1.26 $self->{$propName} = [$res->{uri}];
7717 wakaba 1.25 } else {
7718     __ASSERT{DISPerl:invariant::
7719     msg => {q[ref $self->{<].qq[$propName>} = "@{[ref
7720     $self->{$propName}]}"]},
7721     }__;
7722 wakaba 1.2 }
7723    
7724 wakaba 1.3 ElementTypeBinding:
7725     @Name: PropNameParam
7726     @ElementType:
7727     dis:ResourceDef
7728     @ShadowContent:
7729     @@rdf:type:
7730     DISLang:MethodParameter
7731     @@Name: propName
7732     @@Type: ResourceURI
7733     @@Description:
7734     @@@lang:en
7735     @@@@:
7736     The name of the property.
7737    
7738 wakaba 1.2 ##DISPropertyAccessor
7739    
7740     PropDef:
7741     @QName:isAnon
7742     @Description:
7743     @@lang:en
7744     @@@:
7745     Whether the subject resource is anonymous or not.
7746     @Type:
7747 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
7748 wakaba 1.2
7749     PropDef:
7750     @QName:isDefined
7751     @Description:
7752     @@lang:en
7753     @@@:
7754     Whether the subject resource is defined or not.
7755    
7756     PropDef:
7757 wakaba 1.3 @QName:isReferred
7758 wakaba 1.2 @Description:
7759     @@lang:en
7760     @@@:
7761     Whether the subject resource is referred or not.
7762     @Type:
7763     DOMMain:any
7764    
7765     PropDef:
7766     @QName:definingModule
7767     @Description:
7768     @@lang:en
7769     @@@:
7770     The <QUOTE::dis> module in which the subject resource is defined.
7771 wakaba 1.22 \
7772     {NOTE:: The local name should have been <QUOTE::ownerModule> or some.
7773     \
7774     }
7775 wakaba 1.2 @rdfs:domain:
7776     DISCore:Module
7777 wakaba 1.1
7778     ## -- Datatypes
7779    
7780     URITypeDef:
7781 wakaba 1.3 @QName: AnyURI
7782     @Description:
7783     @@lang:en
7784     @@@:
7785     Any URI references.
7786    
7787     URITypeDef:
7788     @QName: FileURI
7789     @enDesc:
7790     URI references identifying file.
7791    
7792     URITypeDef:
7793 wakaba 1.1 @QName: ForURI
7794     @Description:
7795     @@lang:en
7796     @@@:
7797     <QUOTE::For> URI references.
7798    
7799     DataTypeDef:
7800     @QName: ForURIList
7801     @Description:
7802     @@lang:en
7803     @@@:
7804     References to the array containing <QUOTE::for> URI references.
7805    
7806     URITypeDef:
7807 wakaba 1.3 @QName: ResourceURI
7808     @Description:
7809     @@lang:en
7810     @@@:
7811     A URI reference for a <QUOTE::dis> resource.
7812    
7813     URITypeDef:
7814 wakaba 1.1 @QName: MediaTypeURI
7815     @Description:
7816     @@lang:en
7817     @@@:
7818     Media type URI references.
7819 wakaba 1.3 @rdfs:subClassOf: ResourceURI
7820    
7821     URITypeDef:
7822     @QName: ModuleURI
7823     @enDesc:
7824     URI references for <QUOET::dis> modules.
7825     @rdfs:subClassOf: ResourceURI
7826    
7827     URITypeDef:
7828     @QName: NameURI
7829     @enDesc:
7830     URI references identifying a resource.
7831     @rdfs:subClassOf: ResourceURI
7832 wakaba 1.10
7833     DataTypeDef:
7834     @QName: ResourceList
7835     @enDesc:
7836     References to array containing resource definition objects.
7837     @rdfs:subClassOf:
7838     Perl:ARRAY::ManakaiDOM:all
7839 wakaba 1.3
7840     ElementTypeBinding:
7841     @Name: DataTypeDef
7842     @ElementType:
7843     dis:ResourceDef
7844     @ShadowContent:
7845     @@rdf:type:
7846     ManakaiDOM:DataType
7847    
7848     ElementTypeBinding:
7849     @Name: URITypeDef
7850     @ElementType:
7851     dis:ResourceDef
7852     @ShadowContent:
7853     @@rdf:type:
7854     ManakaiDOM:DataType
7855     @@rdfs:subClassOf: AnyURI
7856 wakaba 1.1
7857     ## -- Exceptions
7858    
7859     XParamDef:
7860 wakaba 1.5 @QName: anotherSourceNode
7861     @enDesc:
7862     Another source node in which an error has occurred. In cases
7863     of <QUOTE::already defined> errors, it is the node that
7864     defines the resource first.
7865     @Type: ManakaiDISNode
7866 wakaba 1.3
7867 wakaba 1.12 ResourceDef:
7868     @QName: UNDECLARED_NS_PREFIX_ERR
7869     @For: ForLatest
7870     @AliasFor:
7871     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
7872    
7873 wakaba 1.3 ExceptionDef:
7874     @ClsQName: ManakaiDISException
7875     @enDesc:
7876     Exceptions for the <QUOTE::dis> operations.
7877 wakaba 1.4 @ClsISA:
7878     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
7879 wakaba 1.3 @XConstGroupDef:
7880     @@ClsQName: ManakaiDISExceptionCode
7881     @@enDesc:
7882     Exception codes for <Class::ManakaiDISException>.
7883     @@XConstDef:
7884 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
7885     @@@Value:3
7886     @@@enDesc:
7887     An attempt is made to break the hierarchy.
7888     @@@XSubTypeDef:
7889     @@@@QName: MERGE_ITSELF_ERR
7890     @@@@enDesc:
7891     An attempt is made to merge the resource to itself.
7892     @@@@XSourceNodeParam:
7893     @@@@XParam:
7894     @@@@@QName:uri
7895     @@@@@enDesc:
7896     The URI reference of the resource to merge.
7897     @@@@enMufDef:
7898     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
7899     );> to itself
7900     @@XConstDef:
7901 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
7902     @@@Value:9
7903     @@@enDesc:
7904     An attempt is made to do something the implementation does not support.
7905     @@@XSubTypeDef:
7906     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
7907     @@@@enDesc:
7908     The implementation does not support the media type.
7909     @@@@XParam:
7910     @@@@@QName: uri
7911     @@@@@enDesc:
7912     The URI reference of the media type that is not supported.
7913     @@@@XSourceNodeParam:
7914 wakaba 1.12 @@@@enMufDef:
7915     Media type <%p (name => {<Q::DIS:uri>});> is not supported
7916 wakaba 1.3 @@@XSubTypeDef:
7917 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
7918     @@@@enDesc:
7919     An unsupported type of element is encounted.
7920     @@@@XSourceNodeParam:
7921     @@@@XParam:
7922     @@@@@QName:elementType
7923     @@@@@enDesc:
7924     The element type URI reference of the element.
7925 wakaba 1.16 @@@@enMufDef:
7926     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
7927 wakaba 1.13 @@@XSubTypeDef:
7928 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
7929 wakaba 1.3 @@@@enDesc:
7930 wakaba 1.12 There is no implementation that supports the
7931     <Feature::Util:PerlCode> feature, version
7932     <FeatureVer::1.0>.
7933 wakaba 1.3 @@XConstDef:
7934     @@@Name: INVALID_STATE_ERR
7935     @@@Value:11
7936     @@@enDesc:
7937     An attempt is made to use an object that is not (or no longer) usable.
7938     @@@XSubTypeDef:
7939     @@@@QName: NO_ASSOCIATED_DB_ERR
7940     @@@@enDesc:
7941     No <QUOTE::dis> database has been associated with this document.
7942 wakaba 1.4 @@XConstDef:
7943     @@@Name: INVALID_SOURCE_ERR
7944     @@@Value: 200
7945     @@@enDesc:
7946     The source input is well-formed but invalid.
7947     @@@XSubTypeDef:
7948     @@@@QName: NO_MODULE_QNAME_ERR
7949     @@@@enDesc:
7950     The <Q::dis:Module> element must have its <Q::dis:QName>
7951     attribute.
7952 wakaba 1.8 @@@@XSourceNodeParam:
7953     @@@XSubTypeDef:
7954     @@@@QName: NO_LOCAL_NAME_ERR
7955     @@@@enDesc:
7956     The resource does not have a local name.
7957     @@@@XSourceNodeParam:
7958 wakaba 1.4 @@@XSubTypeDef:
7959     @@@@QName: UNABLE_TO_GET_MODULE_ERR
7960     @@@@enDesc:
7961     The implementation is unable to get the module source.
7962     @@@@Def:
7963     @@@@@ContentType:
7964     lang:muf
7965     @@@@@lang:en
7966     @@@@@@:
7967     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
7968     @@@@XParam:
7969     @@@@@QName: uri
7970     @@@@@enDesc:
7971     The URI reference of the module.
7972     @@@@XParam:
7973     @@@@@QName: namespaceURI
7974     @@@@@enDesc:
7975     The namespace URI of the module name.
7976     @@@@XParam:
7977     @@@@@QName: localName
7978     @@@@@enDesc:
7979     The local name of the module name.
7980     @@@@XParam:
7981     @@@@@QName: for
7982     @@@@@enDesc:
7983     The <QUOTE::for> of the module.
7984 wakaba 1.5 @@@XSubTypeDef:
7985     @@@@QName: NO_FOR_QNAME_ERR
7986     @@@@enDesc:
7987     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
7988     @@@@XSourceNodeParam:
7989     @@@XSubTypeDef:
7990     @@@@QName: FOR_ALREADY_DEFINED_ERR
7991     @@@@enDesc:
7992     The <QUOTE::for> named as the same URI reference has
7993     already defined.
7994     @@@@XSourceNodeParam:
7995     @@@@XParam:
7996     @@@@@QName: anotherSourceNode
7997     @@@@@enDesc:
7998     The node that defines the <QUOTE::for> URI reference before.
7999 wakaba 1.7 @@@@XParam:
8000     @@@@@Name: uri
8001     @@@@@enDesc:
8002     The URI reference of the <QUOTE::for> attempted to define.
8003     @@@@enMufDef:
8004     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
8005 wakaba 1.5 @@@XSubTypeDef:
8006     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
8007     @@@@enDesc:
8008     The <QUOTE::dis> resource named as the same URI reference has
8009     already defined.
8010     @@@@XSourceNodeParam:
8011     @@@@XParam:
8012     @@@@@QName: anotherSourceNode
8013     @@@@@enDesc:
8014     The node that defines the <QUOTE::for> URI reference before.
8015 wakaba 1.7 @@@@XParam:
8016     @@@@@Name: uri
8017     @@@@@enDesc:
8018     The URI reference of the resource attempted to define.
8019     @@@@enMufDef:
8020     Resource <%p (name => {<Q::DIS:uri>});> is already defined
8021 wakaba 1.5 @@@XSubTypeDef:
8022     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
8023     @@@@enDesc:
8024     An element has occured where it is not allowed.
8025     @@@@enMufDef:
8026     Module <%p (name => {<Q::DIS:uri>});>:
8027     Element of type <%p (name => {<Q::DIS:elementType>});>
8028     is not allowed here
8029     @@@@XSourceNodeParam:
8030     @@@@XParam:
8031     @@@@@QName: elementType
8032     @@@@@enDesc:
8033     The expanded element type name of the element.
8034     @@@@XParam:
8035     @@@@@QName: uri
8036     @@@@@enDesc:
8037     The URI reference of the module.
8038 wakaba 1.7 @@@XSubTypeDef:
8039     @@@@QName: NO_REQUIRED_ATTR_ERR
8040     @@@@enDesc:
8041     A required attribute is not specified.
8042     @@@@XSourceNodeParam:
8043     @@@@XParam:
8044     @@@@@QName: elementType
8045     @@@@@enDesc:
8046     The expanded URI reference of the attribute name.
8047     @@@@enMufDef:
8048     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
8049 wakaba 1.8 @@@XSubTypeDef:
8050     @@@@QName: FOR_NOT_DEFINED_ERR
8051     @@@@enDesc:
8052     A <QUOTE::for> is referred but not defined.
8053     @@@@XSourceNodeParam:
8054     @@@@XParam:
8055     @@@@@QName: uri
8056     @@@@@enDesc:
8057     The URI reference of the <QUOTE::for> that is not defined.
8058     @@@@enMufDef:
8059     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
8060     @@@XSubTypeDef:
8061     @@@@QName: RESOURCE_NOT_DEFINED_ERR
8062     @@@@enDesc:
8063 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
8064     or the resource referred does not have the type expected.
8065 wakaba 1.8 @@@@XSourceNodeParam:
8066     @@@@XParam:
8067     @@@@@QName: uri
8068     @@@@@enDesc:
8069     The URI reference of the resource that is not defined.
8070 wakaba 1.13 @@@@XParam:
8071     @@@@@QName: elementType
8072     @@@@@enDesc:
8073     <QUOTE::dis> element type (either tree element type
8074     or preprocessing element type) of the element
8075     in which a reference to the undefined resource is contained.
8076     @@@@XParam:
8077     @@@@@QName: localName
8078     @@@@@enDesc:
8079     The local name of the undefined resource.
8080     @@@@XParam:
8081     @@@@QName: sourceCode
8082     @@@@enDesc:
8083     Source code fragment that referres this resource.
8084     @@@@XParam:
8085     @@@@@QName:expectedType
8086     @@@@@enDesc:
8087     Expected resource type.
8088 wakaba 1.8 @@@@enMufDef:
8089 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
8090 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
8091     suffix => {>});%p (name => {<Q::DIS:localName>},
8092     prefix => { "}, suffix => {"}); is not defined or wrong type%p
8093     (name => {<Q::DIS:expectedType>}, prefix => { (<},
8094     suffix => {> is expected)});
8095     @@@XSubTypeDef:
8096     @@@@QName: NO_SOURCE_NODE_ERR
8097     @@@@enDesc:
8098     A resource does not have associated node in the source tree.
8099     @@@@XSourceNodeParam:
8100     @@@@XParam:
8101     @@@@@QName:uri
8102     @@@@@enDesc:
8103     The URI reference of the resource.
8104 wakaba 1.8 @@@XSubTypeDef:
8105     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
8106     @@@@enDesc:
8107     A reserved Perl method name is used.
8108     @@@@XParam:
8109     @@@@@QName:uri
8110     @@@@@enDesc:
8111     The URI reference of the method resource.
8112     @@@@XSourceNodeParam:
8113     @@@@XParam:
8114     @@@@@QName: generatedName
8115     @@@@@enDesc:
8116     A reserved method name.
8117     @@@XSubTypeDef:
8118     @@@@QName: NO_DIS_TYPE_ERR
8119     @@@@enDesc:
8120     <Q::dis:Type> attribute is not found.
8121     @@@@XSourceNodeParam:
8122 wakaba 1.12 @@@XSubTypeDef:
8123     @@@@QName: NO_METHOD_RETURN_ERR
8124     @@@@enDesc:
8125     A <Q::DISLang:Method> resource does not have any
8126     <Q::DISLang:MethodReturn> child.
8127     @@@@XSourceNodeParam:
8128 wakaba 1.22 @@@@XParam:
8129     @@@@@QName:errResource
8130     @@@@@enDesc: The method resource.
8131     @@@@XParam:
8132     @@@@@QName:uri
8133     @@@@@enDesc:
8134     The URI reference of the method.
8135     @@@@XParam:
8136     @@@@@QName:localName
8137     @@@@@enDesc:
8138     The local name of the resource.
8139     @@@@enMufDef:
8140     Method "%p (name => {<Q::DIS:localName>});" does not have
8141     "Return" child
8142 wakaba 1.12 @@@XSubTypeDef:
8143     @@@@QName: NO_ATTR_GET_ERR
8144     @@@@enDesc:
8145     A <Q::DISLang:Attribute> resource does not have any
8146     <Q::DISLang:AttributeGet> child.
8147     @@@@XSourceNodeParam:
8148 wakaba 1.13 @@@XSubTypeDef:
8149     @@@@QName:INTERFACE_CLASS_METHOD_ERR
8150     @@@@enDesc:
8151     An attempt is made to call a static (class) method
8152     from an interface.
8153     @@@@XSourceNodeParam:
8154     @@@@XParam:
8155     @@@@@QName:uri
8156     @@@@@enDesc:
8157     The URI reference of the interface.
8158     @@@@XParam:
8159     @@@@@QName:sourceCode
8160     @@@@@enDesc:
8161     Source code fragment that calls a class method.
8162     @@@@XParam:
8163     @@@@@QName:elementType
8164     @@@@@enDesc:
8165     The element type URI reference of the element
8166     that calls a method.
8167     @@@XSubTypeDef:
8168     @@@@QName: BROKEN_PARAM_SPEC_ERR
8169     @@@@enDesc:
8170     A parameter specification is broken.
8171     @@@@XParam:
8172     @@@@@QName: sourceCode
8173     @@@@@enDesc:
8174     Source code fragment that contains the broken parameter
8175     specification.
8176     @@@@XSourceNodeParam:
8177 wakaba 1.15 @@@@enMufDef:
8178     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8179     suffix => {": });Broken parameter specification
8180 wakaba 1.13 @@@XSubTypeDef:
8181     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
8182     @@@@enDesc:
8183     A preprocessing instruction does not have its element
8184     type.
8185     @@@@XSourceNodeParam:
8186     @@@@XParam:
8187     @@@@@QName:sourceCode
8188     @@@@@enDesc:
8189     Source code fragment.
8190 wakaba 1.16 @@@@enMufDef:
8191     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8192     suffix => {": });Element type name is not specified
8193 wakaba 1.13 @@@XSubTypeDef:
8194 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
8195 wakaba 1.13 @@@@enDesc:
8196 wakaba 1.15 No Perl package name is defined for the resource referred.
8197 wakaba 1.13 @@@@XSourceNodeParam:
8198     @@@@XParam:
8199 wakaba 1.15 @@@@@QName:sourceCode
8200 wakaba 1.13 @@@@@enDesc:
8201     Source code fragment.
8202     @@@@XParam:
8203 wakaba 1.15 @@@@@QName:uri
8204     @@@@@enDesc:
8205     THe URI reference of the resource referred.
8206     @@@@XParam:
8207     @@@@@QName:elementType
8208     @@@@@enDesc:
8209     The element type of Perl preprocessing instruction
8210     in which the resource is referred.
8211     @@@@enMufDef:
8212     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
8213     package name is not defined
8214     @@@XSubTypeDef:
8215     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
8216     @@@@enDesc:
8217     An exception type specification is required.
8218     @@@@XSourceNodeParam:
8219     @@@@XSourceCodeParam:
8220     @@@@XParam:
8221     @@@@@QName:elementType
8222     @@@@@enDesc:
8223     The element type of the preprocessing instruction.
8224     @@@XSubTypeDef:
8225     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
8226     @@@@enDesc:
8227     A code name specification is required.
8228     @@@@XSourceNodeParam:
8229     @@@@XSourceCodeParam:
8230     @@@@XParam:
8231 wakaba 1.13 @@@@@QName:elementType
8232     @@@@@enDesc:
8233 wakaba 1.15 The element type of the preprocessing instruction.
8234 wakaba 1.13 @@@XSubTypeDef:
8235     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
8236     @@@@enDesc:
8237 wakaba 1.15 The specified resource does not have its Perl definition.
8238 wakaba 1.13 @@@@XSourceNodeParam:
8239 wakaba 1.15 @@@@XSourceCodeParam:
8240 wakaba 1.13 @@@@XParam:
8241 wakaba 1.15 @@@@@QName:elementType
8242     @@@@@enDesc:
8243     The element type of the preprocessing instruction.
8244     @@@@XParam:
8245     @@@@@QName:uri
8246 wakaba 1.13 @@@@@enDesc:
8247 wakaba 1.15 The URI reference of the resource referred.
8248 wakaba 1.13 @@@@XParam:
8249     @@@@@QName:localName
8250     @@@@@enDesc:
8251     The local name of the resource referred.
8252 wakaba 1.15 @@@XSubTypeDef:
8253     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
8254     @@@@enDesc:
8255     A preprocessing instruction which is only allowed in
8256     method definitions is used in a code which is not a method.
8257     @@@@XSourceNodeParam:
8258     @@@@XSourceCodeParam:
8259 wakaba 1.13 @@@@XParam:
8260 wakaba 1.15 @@@@@QName:elementType
8261 wakaba 1.13 @@@@@enDesc:
8262 wakaba 1.15 The element type of the preprocessing instruction.
8263 wakaba 1.14 @@@XSubTypeDef:
8264 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
8265 wakaba 1.14 @@@@enDesc:
8266 wakaba 1.15 A <QUOTE::for> specification is required.
8267 wakaba 1.14 @@@@XSourceNodeParam:
8268 wakaba 1.15 @@@@XSourceCodeParam:
8269 wakaba 1.14 @@@@XParam:
8270 wakaba 1.15 @@@@@QName:elementType
8271 wakaba 1.14 @@@@@enDesc:
8272 wakaba 1.15 The element type of the preprocessing instruction.
8273     @@@XSubTypeDef:
8274     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
8275     @@@@enDesc:
8276     An assertion type specification is required.
8277     @@@@XSourceNodeParam:
8278     @@@@XSourceCodeParam:
8279 wakaba 1.14 @@@@XParam:
8280 wakaba 1.15 @@@@@QName:elementType
8281 wakaba 1.14 @@@@@enDesc:
8282 wakaba 1.15 The element type of the preprocessing instruction.
8283     @@@XSubTypeDef:
8284     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
8285     @@@@enDesc:
8286     A preprocessing instruction block occurred with
8287     element type which does not allow it.
8288     @@@@XSourceNodeParam:
8289     @@@@XSourceCodeParam:
8290 wakaba 1.14 @@@@XParam:
8291     @@@@@QName:elementType
8292     @@@@@enDesc:
8293 wakaba 1.15 The element type of the preprocessing instruction.
8294 wakaba 1.18 @@@XSubTypeDef:
8295     @@@@QName: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
8296     @@@@enDesc:
8297     A non-named method parameter following
8298     any named method parameter is occurred.
8299     @@@@XSourceNodeParam:
8300     @@@@XParam:
8301     @@@@@QName:uri
8302     @@@@@enDesc:
8303     The URI reference of the non-named method parameter resource.
8304     @@@@XParam:
8305     @@@@@QName:localName
8306     @@@@@enDesc:
8307     The local name of the non-named method parameter.
8308 wakaba 1.19 @@@XSubTypeDef:
8309     @@@@QName:DISPERL_NO_VALUE_ALLOWED_ERR
8310     @@@@enDesc:
8311     An element node have a value but the definition
8312     of that element type does not allow it.
8313     @@@@XSourceNodeParam:
8314     @@@@XParam:
8315     @@@@@QName:elementType
8316     @@@@@enDesc:
8317     The element type URI reference of the element.
8318     @@@XSubTypeDef:
8319     @@@@QName:NO_CONST_VALUE_ERR
8320     @@@@enDesc:
8321     The source element node for a constant value resource
8322     does not have <Q::dis:Value> attribute.
8323     @@@@XSourceNodeParam:
8324     @@@@XParam:
8325     @@@@@QName:elemntType
8326     @@@@@enDesc:
8327     The element type URI reference of the element from which
8328     a constant value resource is referred.
8329     @@@@XParam:
8330     @@@@@QName:uri
8331     @@@@@enDesc:
8332     The resource URI reference of the constant value resource.
8333     @@@@XParam:
8334     @@@@@QName:localName
8335     @@@@@enDesc:
8336     The local name of the constant value resource.
8337     @@@XSubTypeDef:
8338     @@@@QName:NO_ATTR_SET_ERR
8339     @@@@enDesc:
8340     An attribute setter is referred but the attribute
8341     does not define any setter.
8342     @@@@XSourceNodeParam:
8343     @@@@XParam:
8344     @@@@@QName:errResource
8345     @@@@@enDesc:
8346     The attribute resource.
8347     @@@@XParam:
8348     @@@@@QName:elementType
8349     @@@@@enDesc:
8350     The type of the element by which this attribute
8351     is referred.
8352 wakaba 1.20 @@@XSubTypeDef:
8353     @@@@QName: PERL_SUBROUTINE_ALREADY_DEFINED_ERR
8354     @@@@enDesc:
8355     A resource defines a Perl subroutine whose name is
8356     same as another subroutine.
8357     @@@@XSourceNodeParam:
8358     @@@@XParam:
8359     @@@@@QName:uri
8360     @@@@@enDesc:
8361     The URI reference of the resource that defines the Perl subroutine.
8362     @@@@XParam:
8363     @@@@@QName:
8364     PerlCode:localName
8365     @@@@@enDesc:
8366     The name of the Perl subroutine.
8367     @@@XSubTypeDef:
8368     @@@@QName: PERL_OPERATOR_ALREADY_OVERLOADED_ERR
8369     @@@@enDesc:
8370     A resource is defined to overload a Perl operator which
8371     is already overloaded by another resource.
8372     @@@@XSourceNodeParam:
8373     @@@@XParam:
8374     @@@@@QName:uri
8375     @@@@@enDesc:
8376     The URI reference of the resource that defines the overloading.
8377     @@@@XParam:
8378     @@@@@QName:
8379     PerlCode:operator
8380     @@@@@enDesc:
8381     The operator.
8382     @@@XSubTypeDef:
8383     @@@@QName: PERL_UNUSED_SUBROUTINE_ERR
8384     @@@@enDesc:
8385     A resource defines a Perl subroutine but it is not used.
8386     @@@@XSourceNodeParam:
8387     @@@@XParam:
8388     @@@@@QName:uri
8389     @@@@@enDesc:
8390     The URI reference of the resource.
8391 wakaba 1.22 @@@XSubTypeDef:
8392     @@@@QName: NO_LICENSE_ATTR_ERR
8393     @@@@enDesc:
8394     The <Q::dis:Module> element does not have the
8395     <Q::dis:License> attribute.
8396     @@@@XSourceNodeParam:
8397     @@@@XParam:
8398     @@@@@QName:uri
8399     @@@@@enDesc:
8400     The URI reference of the module.
8401 wakaba 1.25 @@@XSubTypeDef:
8402     @@@@QName: UNSUPPORTED_ROLE_ERR
8403     @@@@enDesc:
8404     A <Q::dis:Role> is not supported.
8405     @@@@XSourceNodeParam:
8406     @@@@XParam:
8407     @@@@@QName:uri
8408     @@@@@enDesc:
8409     The URI reference of the unsupported role.
8410     @@@@enMufDef:
8411     Role <%p (name => {<Q::DIS:uri>});> is not supported
8412 wakaba 1.4 ##DISException
8413 wakaba 1.13
8414     XParamDef:
8415     @QName:expectedType
8416     @Type: ResourceURI
8417     @enDesc:
8418     Expected resource type URI reference.
8419    
8420     XParamDef:
8421     @QName: sourceCode
8422     @Type:
8423     DISLang:String::ManakaiDOM:all
8424     @enDesc:
8425     The source code fragment in which an error occurred.
8426 wakaba 1.5
8427     XParamDef:
8428     @QName: elementType
8429     @Type: ResourceURI
8430     @enDesc:
8431     The name of the element type.
8432    
8433     XParamDef:
8434     @QName: uri
8435     @Type: ResourceURI
8436     @enDesc:
8437     The name of the resource, composed from <Q::namespaceURI>,
8438     <Q::localName> and <Q::for>.
8439    
8440     XParamDef:
8441     @QName: localName
8442     @Type:
8443 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
8444 wakaba 1.5 @enDesc:
8445     The local name of the resource, unique in <Q::namespaceURI> namespace.
8446    
8447     XParamDef:
8448     @QName: namespaceURI
8449     @Type: AnyURI
8450     @enDesc:
8451     The namespace URI reference of the resource name.
8452    
8453     XParamDef:
8454     @QName: for
8455     @Type: ForURI
8456     @enDesc:
8457     The <QUOTE::for> URI reference of the resource.
8458    
8459     ElementTypeBinding:
8460     @Name: XSourceNodeParam
8461     @ElementType:
8462     ManakaiDOM:exceptionOrWarningParameter
8463     @ShadowContent:
8464     @@QName: sourceNode
8465     @@Description:
8466     @@@lang:en
8467     @@@@:
8468     The node in which an error has occurred.
8469 wakaba 1.15
8470     ElementTypeBinding:
8471     @Name: XSourceCodeParam
8472     @ElementType:
8473     ManakaiDOM:exceptionOrWarningParameter
8474     @ShadowContent:
8475     @@QName: sourceCode
8476     @@Description:
8477     @@@lang:en
8478     @@@@:
8479     The source code in which an error has occurred.
8480 wakaba 1.4
8481     ClsDef:
8482     @ClsQName: ManakaiDISExceptionTarget
8483     @enDesc:
8484     Objects that is able to be the target of an exception.
8485     @IntMethod:
8486     @@Operator:
8487     @@@@:
8488     ManakaiDOM:MUErrorHandler
8489     @@@ContentType:
8490     dis:TypeQName
8491     @@Description:
8492     @@@lang:en
8493     @@@@:
8494     This method is a generic error handler; all manakai exceptions
8495     and warnings associated to an object are once reported to this method
8496     and then delivered to appropriate entities.
8497     \
8498     If the error is an exception (such as <X::DOMCore:DOMException> or
8499     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
8500     simply thrown. If the error is only a warning, it is reported
8501     via the <IF::DOMCore:DOMError> interface.
8502     \
8503     See <PerlModule::Message::Util::Error> documentation for more
8504     information on the error reporting mechanism.
8505     \
8506     {NOTE:: This kind of methods are named as <Perl::___report_error>
8507     in the convention of <PerlModule::Message::Util::Error>.
8508     \
8509     }
8510     @@Param:
8511     @@@Name:err
8512     @@@Type:
8513     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
8514     @@@Description:
8515     @@@@lang:en
8516     @@@@@:
8517     An exception object that describes what kind of error it is
8518     and how it should be recovered.
8519     \
8520     {NOTE:: Exception objects in manakai implementation
8521     inherit the class <PerlModule::Message::Util::Error>,
8522     that in turn inherits <PerlModule::Error>.
8523     \
8524     }
8525     @@Return:
8526     @@@PerlDef:
8527     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
8528     ::ManakaiDOM:Perl>)) {
8529     $err->throw;
8530     } else {
8531     \## TODO: Implement warning reporting
8532     warn $err->stringify;
8533     }
8534     ##DISExceptionTarget
8535    
8536     ForDef:
8537     @QName:
8538     DIS:ForIF
8539     ForDef:
8540     @QName:
8541     DIS:ForClass
8542    
8543     ElementTypeBinding:
8544     @Name: IFClsDef
8545     @ElementType:
8546     dis:ResourceDef
8547     @ShadowContent:
8548     @@rdf:type:
8549     @@@@:
8550     dis:MultipleResource
8551     @@@ForCheck: !ForClass !ForIF
8552     @@rdf:type:
8553     @@@@:
8554     ManakaiDOM:IF
8555     @@@ForCheck: ForIF
8556     @@rdf:type:
8557     @@@@:
8558     ManakaiDOM:Class
8559     @@@ForCheck: ForClass
8560     @@resourceFor: ForIF
8561     @@resourceFor:
8562     @@@@: ForClass
8563     @@@ForCheck: ForLatest
8564     @@DOMMain:implementFeature:
8565     @@@@:CoreFeature10
8566     @@@ForCheck: ForClass
8567     @@ForCheck:
8568     ManakaiDOM:Perl
8569 wakaba 1.3
8570     ElementTypeBinding:
8571     @Name: ClsDef
8572     @ElementType:
8573     dis:ResourceDef
8574     @ShadowContent:
8575     @@rdf:type:
8576     ManakaiDOM:Class
8577     @@AliasFor:
8578     @@@@:
8579 wakaba 1.11 ::DIS:ForLatest
8580 wakaba 1.3 @@@For:
8581 wakaba 1.11 !=DIS:ForLatest
8582 wakaba 1.3 @@ForCheck:
8583     ManakaiDOM:Perl
8584     @@DOMMain:implementFeature: CoreFeature10
8585    
8586     ElementTypeBinding:
8587     @Name: ExceptionDef
8588     @ElementType:
8589     dis:ResourceDef
8590     @ShadowContent:
8591     @@rdf:type:
8592     ManakaiDOM:ExceptionClass
8593     @@AliasFor:
8594     @@@@:
8595     ::ForLatest
8596     @@@For:
8597     !=ForLatest
8598     @@ForCheck:
8599     ManakaiDOM:Perl
8600     @@DOMMain:implementFeature: CoreFeature10
8601    
8602     ElementTypeBinding:
8603     @Name: ClsQName
8604     @ElementType:
8605     dis:QName
8606    
8607     ElementTypeBinding:
8608     @Name: ClsISA
8609     @ElementType:
8610     dis:ISA
8611    
8612     ElementTypeBinding:
8613     @Name: Method
8614     @ElementType:
8615     dis:ResourceDef
8616     @ShadowContent:
8617     @@rdf:type:
8618     DISLang:Method
8619    
8620     ElementTypeBinding:
8621     @Name: IntMethod
8622     @ElementType:
8623     dis:ResourceDef
8624     @ShadowContent:
8625     @@rdf:type:
8626     DISLang:Method
8627     @@ManakaiDOM:isForInternal:1
8628    
8629     ElementTypeBinding:
8630     @Name: Attr
8631     @ElementType:
8632     dis:ResourceDef
8633     @ShadowContent:
8634     @@rdf:type:
8635     DISLang:Attribute
8636    
8637     ElementTypeBinding:
8638     @Name: Return
8639     @ElementType:
8640     dis:ResourceDef
8641     @ShadowContent:
8642     @@rdf:type:
8643     DISLang:MethodReturn
8644    
8645     ElementTypeBinding:
8646     @Name: Get
8647     @ElementType:
8648     dis:ResourceDef
8649     @ShadowContent:
8650     @@rdf:type:
8651     DISLang:AttributeGet
8652    
8653     ElementTypeBinding:
8654     @Name: Set
8655     @ElementType:
8656     dis:ResourceDef
8657     @ShadowContent:
8658     @@rdf:type:
8659     DISLang:AttributeSet
8660    
8661     ElementTypeBinding:
8662     @Name: Param
8663     @ElementType:
8664     dis:ResourceDef
8665     @ShadowContent:
8666     @@rdf:type:
8667     DISLang:MethodParameter
8668    
8669     ElementTypeBinding:
8670     @Name: PerlDef
8671     @ElementType:
8672     dis:Def
8673     @ShadowContent:
8674     @@ContentType:
8675     lang:Perl
8676    
8677     ElementTypeBinding:
8678     @Name: disDef
8679     @ElementType:
8680     dis:Def
8681     @ShadowContent:
8682     @@ContentType:
8683     lang:dis
8684    
8685     ElementTypeBinding:
8686     @Name: InCase
8687     @ElementType:
8688     dis:ResourceDef
8689     @ShadowContent:
8690     @@rdf:type:
8691     ManakaiDOM:InCase
8692    
8693     ElementTypeBinding:
8694     @Name: nullCase
8695     @ElementType:
8696     dis:ResourceDef
8697     @ShadowContent:
8698     @@rdf:type:
8699     ManakaiDOM:InCase
8700     @@Value:
8701     @@@is-null:1
8702    
8703     ElementTypeBinding:
8704     @Name: TrueCase
8705     @ElementType:
8706     dis:ResourceDef
8707     @ShadowContent:
8708     @@rdf:type:
8709     ManakaiDOM:InCase
8710     @@Value:true
8711     @@Type:
8712 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8713 wakaba 1.3
8714    
8715     ElementTypeBinding:
8716     @Name: FalseCase
8717     @ElementType:
8718     dis:ResourceDef
8719     @ShadowContent:
8720     @@rdf:type:
8721     ManakaiDOM:InCase
8722     @@Value:false
8723     @@Type:
8724 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8725 wakaba 1.3
8726     ElementTypeBinding:
8727     @Name: enDesc
8728     @ElementType:
8729     dis:Description
8730     @ShadowContent:
8731     @@lang:en
8732    
8733     ElementTypeBinding:
8734     @Name: PropDef
8735     @ElementType:
8736     dis:ResourceDef
8737     @ShadowContent:
8738     @@rdf:type:
8739     rdf:Property
8740     @@AliasFor:
8741     @@@@:
8742     ::ManakaiDOM:all
8743     @@@For:
8744     !=ManakaiDOM:all
8745    
8746     ElementTypeBinding:
8747     @Name: MethodRedef
8748     @ElementType:
8749     dis:ResourceDef
8750     @ShadowContent:
8751     @@rdf:type:
8752     DISLang:Method
8753     @@ManakaiDOM:isRedefining:1
8754    
8755     ElementTypeBinding:
8756     @Name: NamedParam
8757     @ElementType:
8758     dis:ResourceDef
8759     @ShadowContent:
8760     @@rdf:type:
8761     DISLang:MethodParameter
8762     @@DISPerl:isNamedParameter:1
8763    
8764     ElementTypeBinding:
8765     @Name: NodeParam
8766     @ElementType:
8767     dis:ResourceDef
8768     @ShadowContent:
8769     @@rdf:type:
8770     DISLang:MethodParameter
8771     @@DISPerl:isNamedParameter:1
8772     @@Name: node
8773     @@Type: ManakaiDISNode
8774     @@Description:
8775     @@@lang:en
8776     @@@@:
8777     The node in which the name has occurred. It is intended
8778     to be reported when an exception had been raised.
8779     @@ResourceDef:
8780     @@@rdf:type:
8781     ManakaiDOM:InCase
8782     @@@Value:
8783     @@@@is-null:1
8784     @@@Description:
8785     @@@@lang:en
8786     @@@@@:
8787     The source of the name is not a node.
8788    
8789     ElementTypeBinding:
8790     @Name: ForParam
8791     @ElementType:
8792     dis:ResourceDef
8793     @ShadowContent:
8794     @@rdf:type:
8795     DISLang:MethodParameter
8796     @@DISPerl:isNamedParameter:1
8797     @@Name: forArg
8798     @@Type: ForURI
8799     @@Description:
8800     @@@lang:en
8801     @@@@:
8802     The <QUOTE::for> URI reference.
8803     @@ResourceDef:
8804     @@@rdf:type:
8805     ManakaiDOM:InCase
8806     @@@Value:
8807     @@@@is-null:1
8808     @@@Description:
8809     @@@@lang:en
8810     @@@@@:
8811     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
8812    
8813     ElementTypeBinding:
8814     @Name: ForpParam
8815     @ElementType:
8816     dis:ResourceDef
8817     @ShadowContent:
8818     @@rdf:type:
8819     DISLang:MethodParameter
8820     @@DISPerl:isNamedParameter:1
8821     @@Name: forpArg
8822     @@Type: ForURIList
8823     @@Description:
8824     @@@lang:en
8825     @@@@:
8826     An array reference containing additional <QUOTE::for>
8827     constraints (<QUOTE::For+> list).
8828     @@ResourceDef:
8829     @@@rdf:type:
8830     ManakaiDOM:InCase
8831     @@@Value:
8832     @@@@is-null:1
8833     @@@Description:
8834     @@@@lang:en
8835     @@@@@:
8836     Equivalent to the empty array reference.
8837    
8838     ElementTypeBinding:
8839     @Name: MediaTypeParam
8840     @ElementType:
8841     dis:ResourceDef
8842     @ShadowContent:
8843     @@rdf:type:
8844     DISLang:MethodParameter
8845     @@DISPerl:isNamedParameter:1
8846     @@Name: mediaType
8847     @@Type: MediaTypeURI
8848     @@Description:
8849     @@@lang:en
8850     @@@@:
8851     The URI reference identifying a media type.
8852     @@ResourceDef:
8853     @@@rdf:type:
8854     ManakaiDOM:InCase
8855     @@@Value:
8856     @@@@is-null:1
8857     @@@Description:
8858     @@@@lang:en
8859     @@@@@:
8860     No media type specified.
8861    
8862     ElementTypeBinding:
8863     @Name: MediaTypeDefaultParam
8864     @ElementType:
8865     dis:ResourceDef
8866     @ShadowContent:
8867     @@rdf:type:
8868     DISLang:MethodParameter
8869     @@DISPerl:isNamedParameter:1
8870     @@Name: defaultMediaType
8871     @@Type: MediaTypeURI
8872     @@Description:
8873     @@@lang:en
8874     @@@@:
8875     The default media type, i.e. the type used when no explicit
8876     specification is not found in the source tree.
8877     @@ResourceDef:
8878     @@@rdf:type:
8879     ManakaiDOM:InCase
8880     @@@Value:
8881     @@@@is-null:1
8882     @@@Description:
8883     @@@@lang:en
8884     @@@@@:
8885     Defaulted to <Q::DOMMain:any>.
8886    
8887     ElementTypeBinding:
8888     @Name: RaiseException
8889     @ElementType:
8890     ManakaiDOM:raises
8891    
8892     ElementTypeBinding:
8893     @Name: UndeclaredPrefixException
8894     @ElementType:
8895     ManakaiDOM:raises
8896     @ShadowContent:
8897     @@@: UNDECLARED_NS_PREFIX_ERR
8898     @@Description:
8899     @@@lang:en
8900     @@@@:
8901     The implementation has encounted an undeclared namespace prefix.
8902    
8903     ElementTypeBinding:
8904     @Name: NoDBException
8905     @ElementType:
8906     ManakaiDOM:raises
8907     @ShadowContent:
8908     @@@: NO_DB_ASSOCIATED_ERR
8909     @@Description:
8910     @@@lang:en
8911     @@@@:
8912     No <QUOTE::dis> database is associated to this document.
8913    
8914     ElementTypeBinding:
8915     @Name: XConstGroupDef
8916     @ElementType:
8917     dis:ResourceDef
8918     @ShadowContent:
8919     @@rdf:type:
8920     ManakaiDOM:ConstGroup
8921     @@Type:
8922     DOMMain:unsigned-short::ManakaiDOM:all
8923     @@rdfs:subClassOf:
8924     DOMMain:unsigned-short::ManakaiDOM:all
8925    
8926     ElementTypeBinding:
8927     @Name: XConstDef
8928     @ElementType:
8929     dis:ResourceDef
8930     @ShadowContent:
8931     @@rdf:type:
8932     ManakaiDOM:Const
8933    
8934     ElementTypeBinding:
8935     @Name: XSubTypeDef
8936     @ElementType:
8937     dis:ResourceDef
8938     @ShadowContent:
8939     @@rdf:type:
8940     ManakaiDOM:ExceptionOrWarningSubType
8941    
8942     ElementTypeBinding:
8943     @Name: XParam
8944     @ElementType:
8945     ManakaiDOM:exceptionOrWarningParameter
8946    
8947     ElementTypeBinding:
8948     @Name: XParamDef
8949     @ElementType:
8950     dis:ResourceDef
8951     @ShadowContent:
8952     @@rdf:type:
8953     DOMMain:XWParameter
8954 wakaba 1.12 @@For:
8955     =ManakaiDOM:all
8956 wakaba 1.3
8957     ElementTypeBinding:
8958     @Name: enMufDef
8959     @ElementType:
8960     dis:Def
8961     @ShadowContent:
8962     @@ContentType:
8963     lang:muf
8964     @@lang:en
8965 wakaba 1.21
8966     ResourceDef:
8967     @QName:
8968     lang:muf
8969     @rdf:type:
8970     rdfs:Class
8971     @ImplNote:
8972     @@lang:en
8973     @@@:
8974     Should be moved to some other module.
8975 wakaba 1.3

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24