/[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.45 - (hide annotations) (download)
Thu Sep 1 17:07:20 2005 UTC (19 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.44: +5 -1 lines
DISDump datatype & constants & lextype dis:TFQNames implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24