/[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.41 - (hide annotations) (download)
Sun May 29 12:56:35 2005 UTC (20 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.40: +16 -8 lines
Node.getFeature implemented; DOMLS SimpleSerializer bugs fixed; dis:TypeQName lextype in disdoc parser implemented; Util/DIS dis:setProp bug fixed

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24