/[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.42 - (hide annotations) (download)
Mon Aug 15 07:59:41 2005 UTC (19 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.41: +2 -1 lines
lib/Message/Util/DIS/DISDoc.dis: Parsing of lexical types dis:TypeQName and dis:TFQNames implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24