/[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.39 - (hide annotations) (download)
Tue May 24 12:04:01 2005 UTC (20 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.38: +13 -9 lines
More interfaces defined in DISDoc module

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24