/[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.38 - (hide annotations) (download)
Mon May 23 13:26:55 2005 UTC (20 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.37: +372 -1 lines
lib/Message/Util/DIS.dis: getFeature and roles for module, for, resource, element and database added

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24