/[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.40 - (hide annotations) (download)
Sat May 28 13:38:45 2005 UTC (20 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.39: +35 -3 lines
disdoc parser implemented (although it's still work in progress)

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24