/[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.18 - (hide annotations) (download)
Mon Apr 4 15:21:32 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.17: +456 -62 lines
Method parameters and return values 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     manakai <CODE::lib/manakai/dis.pl>
25     @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.18 $Date: 2005/04/03 04:23:06 $
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     @DOMLS:
68     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
69     @DOMMain:
70     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
71     @infoset:
72     http://www.w3.org/2001/04/infoset#
73 wakaba 1.1 @lang:
74     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
75     @license:
76     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
77     @ManakaiDOM:
78     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
79 wakaba 1.5 @Markup:
80     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
81 wakaba 1.3 @MDOMX:
82     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
83 wakaba 1.1 @owl:
84     http://www.w3.org/2002/07/owl#
85     @Perl:
86     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
87     @rdf:
88     http://www.w3.org/1999/02/22-rdf-syntax-ns#
89     @rdfs:
90     http://www.w3.org/2000/01/rdf-schema#
91 wakaba 1.3 @swcfg21:
92     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
93 wakaba 1.1 @TreeCore:\
94     @Util:
95     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
96    
97     ## -- "For" definitions
98    
99     ForDef:
100     @QName:
101     DIS:ForLatest
102     @Description:
103     @@lang:en
104     @@@:
105     For latest version of the <Module::Util:DIS> module implementation
106     @ISA:
107     ManakaiDOM:Perl
108    
109     ## -- Features
110    
111     ElementTypeBinding:
112     @Name: FeatureDef
113     @ElementType:
114     dis:ResourceDef
115     @ShadowContent:
116     @@rdf:type:
117     DOMMain:DOMFeature
118     @@AliasFor:
119     @@@@:
120     ::ManakaiDOM:all
121     @@@For:
122     !=ManakaiDOM:all
123    
124     ElementTypeBinding:
125     @Name: FeatureVerDef
126     @ElementType:
127     dis:ResourceDef
128     @ShadowContent:
129     @@rdf:type:
130     DOMMain:DOMFeature
131    
132     ElementTypeBinding:
133     @Name: featureQName
134     @ElementType:
135     dis:AppName
136     @ShadowContent:
137     @@ContentType:
138     dis:TypeQName
139    
140     FeatureDef:
141     @QName: Core
142     @FeatureVerDef:
143     @@QName: CoreFeature10
144     @@Version: 1.0
145     @@ISA: Core
146     @@FullName:
147     @@@lang:en
148     @@@@:
149     The <QUOTE::dis> object model, version 1.0
150     @@Description:
151     @@@lang:en
152     @@@@:
153     The <QUOTE::dis> object model, version 1.0.
154     @@DOMMain:requireFeature:
155     swcfg21:CoreFeature21
156    
157     ## -- SuikaWikiConfig/2.1 extended classes
158    
159     ClsDef:
160     @ClsQName: ManakaiDISImplementation
161     @ClsISA:
162 wakaba 1.3 swcfg21:ManakaiSWCFGImplementation::swcfg21:ForLatest
163 wakaba 1.1 @Description:
164     @@lang:en
165     @@@:
166     A <QUOTE::dis> implementation object.
167    
168     @Method:
169     @@Name: createDISDocument
170     @@Description:
171     @@@lang:en
172     @@@@:
173     Creates an empty <Class::ManakaiDISDocument> object.
174     @@Return:
175     @@@Type:ManakaiDISDocument
176     @@@Description:
177     @@@@lang:en
178     @@@@@:
179     The newly created <QUOTE::dis> document object.
180     @@@PerlDef:
181 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
182     .createSWCFGDocument>;
183     $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
184     .defaultElementTypeNamespaceURI>
185 wakaba 1.1 (<Q::dis:>);
186    
187     @Method:
188 wakaba 1.2 @@Name: createDISParser
189     @@Description:
190     @@@lang:en
191     @@@@:
192 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
193 wakaba 1.2 @@Return:
194     @@@Type: ManakaiDISParser
195     @@@Description:
196     @@@@lang:en
197     @@@@@:
198 wakaba 1.1 A newly created <QUOTE::dis> parser.
199 wakaba 1.2 @@@PerlDef:
200 wakaba 1.3 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
201     .createSWCFGParser>,
202 wakaba 1.1 <ClassName::ManakaiDISParser>;
203    
204     @Method:
205 wakaba 1.2 @@Name: createDISDatabase
206 wakaba 1.1 @@Description:
207     @@@lang:en
208     @@@@:
209 wakaba 1.2 Creates a new <QUOTE::dis> database.
210 wakaba 1.1 @@Return:
211 wakaba 1.2 @@@Type:ManakaiDISDatabase
212 wakaba 1.4 @@@Description:
213     @@@@lang:en
214     @@@@@:
215 wakaba 1.2 A newly created <QUOTE::dis> parser.
216 wakaba 1.4 @@@PerlDef:
217 wakaba 1.2 $r = bless {
218     forDef => {
219 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
220 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
221     isa => {<Q::ManakaiDOM:all> => 1},
222     revISA => {},
223 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
224 wakaba 1.2 },
225     resDef => {},
226 wakaba 1.9 modDef => {},
227     seq => 0,
228 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
229    
230     @Method:
231     @@Name: tfurisToURI
232     @@Description:
233     @@@lang:en
234     @@@@:
235     Converts a pair of name URI reference and <QUOTE::for> URI reference
236     into a <TYPE::dis:TFQNames>-expanded URI reference.
237     @@Param:
238     @@@Name: typeURI
239     @@@Type: NameURI
240     @@@Description:
241     @@@@lang:en
242     @@@@@:
243     A URI reference to identify a resource.
244     @@@InCase:
245     @@@@Value:
246     @@@@@is-null:1
247     @@@@Description:
248     @@@@@lang:en
249     @@@@@@:
250     Equivalent to <Q::DOMMain:any> (for historical reason).
251     @@Param:
252     @@@Name: forURI
253     @@@Type: ForURI
254     @@@Description:
255     @@@@lang:en
256     @@@@@:
257     A <QUOTE::for> URI reference.
258     @@@InCase:
259     @@@@Value:
260     @@@@@is-null:1
261     @@@@Description:
262     @@@@@lang:en
263     @@@@@@:
264     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
265     @@Return:
266     @@@Type:
267     DISCore:TFURI::ManakaiDOM:all
268     @@@Description:
269     @@@@lang:en
270     @@@@@:
271     The <TYPE::dis:TFQNames>-expanded URI references.
272     @@@PerlDef:
273     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
274     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
275 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
276    
277     @ResourceDef:
278     @@QName: tfurisToURI
279     @@rdf:type:
280     dis2pm:BlockCode
281     @@enDesc:
282     Converts a pair of name URI reference and <QUOTE::for> URI reference
283     into a <TYPE::dis:TFQNames>-expanded URI reference.
284     @@PerlDef:
285     if ($furi eq <Q::ManakaiDOM:all>) {
286     $uri = $turi;
287 wakaba 1.3 } else {
288     ## NOTE: [RFC 3986]
289     ## fragment := *(pchar / "/" / "?")
290     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
291     ## unreserved := ALPHA / DIGIT / [._~-]
292     ## sub-delims := [!$&'()*+,;=]
293     ## NOTE: [XPointer Framework]
294     ## SchemeData := *EscapedData
295     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
296     ## / "(" SchemeData ")"
297     ## NormalChar := UnicodeChar - [()^]
298 wakaba 1.5 my $__turi = $turi;
299     my $__furi = $furi;
300     for my $__uri ($__turi, $__furi) {
301 wakaba 1.4 $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
302 wakaba 1.3 }
303 wakaba 1.4 $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
304 wakaba 1.5 qq<t:tf($__turi,$__furi)>;
305 wakaba 1.3 }
306 wakaba 1.2
307 wakaba 1.5 @ResourceDef:
308 wakaba 1.6 @@QName: tfpurisToURI
309     @@rdf:type:
310     dis2pm:BlockCode
311     @@enDesc:
312     Converts a set of name URI reference and <QUOTE::for> URI reference
313     and <QUOTE::for+> URI references into a URi reference.
314     @@PerlDef:
315     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
316     $uri = $turi;
317     } elsif (@{$forp}) {
318     my $__turi = $turi;
319     my $__furi = $furi;
320     for my $__uri ($__turi, $__furi) {
321     $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
322     }
323     my @__fp;
324     for my $__uri (@{$forp}) {
325     my $__fpuri = $__uri;
326     $__fpuri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}
327     {sprintf '%%%02X', ord $1}ge;
328     push @__fp, $__fpuri;
329     }
330     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
331     qq<t:tfp($__turi,$__furi,>.join (',', @__fp).q<)>;
332     } else {
333     my $__turi = $turi;
334     my $__furi = $furi;
335     for my $__uri ($__turi, $__furi) {
336     $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
337     }
338     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
339     qq<t:tf($__turi,$__furi)>;
340     }
341    
342     @ResourceDef:
343 wakaba 1.5 @@QName: getChildResourceURI
344     @@rdf:type:
345     dis2pm:BlockCode
346     @@enDesc:
347     Gets an anonymous URI reference of a child resource of another
348     resource.
349     @@PerlDef:
350     my $__parent = $parentURI;
351     my $__ln = $localName;
352     for my $__uri ($__parent, $__ln) {
353 wakaba 1.6 $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
354 wakaba 1.5 }
355     $result = q<data:,200411tf#xmlns(t=data:,200411tf%23)>.
356     qq<t:child($__parent,$__ln)>;
357    
358 wakaba 1.8 @IntMethod:
359     @@Name: camelCaseToUnderscoreName
360     @@enDesc:
361     Converts a camelCase name to a underscored_name.
362     @@ManakaiDOM:isStatic:1
363     @@Param:
364     @@@Name: camelName
365     @@@Type:
366 wakaba 1.18 DISLang:String::ManakaiDOM:all
367 wakaba 1.8 @@@enDesc:
368     The source name.
369     @@Return:
370     @@@Type:
371 wakaba 1.18 DISLang:String::ManakaiDOM:all
372 wakaba 1.8 @@@enDesc:
373     The result name.
374     @@@PerlDef:
375     $r = $camelName;
376     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
377     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
378     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
379     $r =~ s/([A-Z])/"_".lc $1/ge;
380     $r =~ s/(?=[0-9](?!$))/_/g;
381 wakaba 1.9
382     @Method:
383     @@Name: plLoadDISDatabase
384     @@enDesc:
385     Loads a database from a file that was saved by
386     <M::ManakaiDISDatabase.plStore>.
387     \
388     {NOTE:: <QUOTE::dis> documents restored from external file
389     would have different <A::ManakaiDISDocument.implementation>
390     than this <Class::ManakaiDISImplementation>, even if
391     it has been created by this implementation
392     and stored in the same session.
393     \
394     }
395     @@Param:
396     @@@Name:fileName
397     @@@Type:
398 wakaba 1.18 DISLang:String::ManakaiDOM:all
399 wakaba 1.9 @@@enDesc:
400     An environment-dependent file name.
401     @@Return:
402     @@@Type: ManakaiDISDatabase
403     @@@SimpleException:
404     @@@PerlDef:
405     use Storable qw/retrieve/;
406     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
407     $r = retrieve $fileName;
408    
409     ## Restores weak references
410     require Scalar::Util;
411     for my $doc (values %{$r->{<Q::DIS:sourceFile>}}) {
412     Scalar::Util::weaken ($doc->{<Q::TreeCore:node>}->{<Q::DIS:db>});
413     }
414     for my $def (values %{$r->{modDef}},
415     values %{$r->{forDef}},
416     values %{$r->{resDef}}) {
417     Scalar::Util::weaken ($def->{db});
418     }
419 wakaba 1.1 ##DISImplementation
420    
421 wakaba 1.9 ElementTypeBinding:
422     @Name: SimpleException
423     @ElementType:
424     dis:Description
425     @ShadowContent:
426     @@lang:en
427     @@@:
428     - Exception of type <PerlModule::Error::Simple>:::
429     I/O error or other error reported by <PerlModule::Storable>.
430    
431     ## TODO: Formal description required for simple exception
432    
433 wakaba 1.1 ClsDef:
434     @ClsQName: ManakaiDISParser
435     @ClsISA:
436 wakaba 1.3 swcfg21:ManakaiSWCFGParser::swcfg21:ForLatest
437 wakaba 1.1 @Description:
438     @@lang:en
439     @@@:
440     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
441     @Method:
442 wakaba 1.3 @@Name: parse
443     @@Description:
444     @@@lang:en
445     @@@@:
446 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
447 wakaba 1.3 @@Param:
448     @@@Name: input
449     @@@Type:
450     DOMLS:LSInput::ManakaiDOM:ManakaiDOM3
451     @@@Description:
452     @@@@lang:en
453     @@@@@:
454 wakaba 1.1 The input source.
455 wakaba 1.3 @@Return:
456     @@@Type: ManakaiDISDocument
457     @@@Description:
458     @@@@lang:en
459     @@@@@:
460 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
461     @@@RaiseException:
462     @@@@@:
463     swcfg21:SWCFG_PARSE_ERR
464     @@@@Description:
465     @@@@@lang:en
466     @@@@@@:
467     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
468     document.
469     @@@PerlDef:
470     __DEEP{
471 wakaba 1.3 $r = $self-><M::swcfg21:ManakaiSWCFGParser
472     ::swcfg21:ForLatest.parse> ($input);
473 wakaba 1.1 }__;
474     if (defined $r) {
475     $r = bless $r, <ClassName::ManakaiDISDocument>;
476 wakaba 1.4 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
477     .defaultElementTypeNamespaceURI>
478     (<Q::dis:>);
479 wakaba 1.1 }
480     ##DISParser
481    
482     ClsDef:
483     @ClsQName: ManakaiDISNode
484     @Description:
485     @@lang:en
486     @@@:
487     <QUOTE::dis> node objects.
488 wakaba 1.7 @ImplNote:
489     @@lang:en
490     @@@:
491     This class does not inherit
492     <Class::swcfg21:ManakaiSWCFGNode::swcfg21:ForLatest>, since
493     inheriting classes such as <Class::ManakaiDISElement> indirectly
494     inherit it.
495 wakaba 1.1
496     @MethodRedef:
497     @@Name:lookupNamespacePrefix
498     @@Description:
499     @@@lang:en
500     @@@@:
501     Looks up the namespace prefix associated to the given
502     namespace URI. The default namespaces are ignored.
503     @@Param:
504     @@@Name:namespaceURI
505 wakaba 1.3 @@@Type: AnyURI
506 wakaba 1.1 @@@Description:
507     @@@@lang:en
508     @@@@@:
509     The namespace URI to look for.
510     @@@InCase:
511     @@@@Value:
512     @@@@@is-null:1
513     @@@@Description:
514     @@@@@lang:en
515     @@@@@@:
516     The <DOM::null> namespace.
517     @@NamedParam:
518     @@@Name: makeNewBinding
519     @@@Type:
520 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
521 wakaba 1.1 @@@Description:
522     @@@@lang:en
523     @@@@@:
524     Whether a new namespace prefix should be bound when
525     no namespace URI has been associated yet.
526     @@@InCase:
527     @@@@Value:true
528     @@@@Description:
529     @@@@@lang:en
530     @@@@@@:
531     New binding is made if no prefix associated.
532     @@@InCase:
533     @@@@Value:false
534     @@@@Description:
535     @@@@@lang:en
536     @@@@@@:
537     Simply returns the <DOM::null> if no prefix associated.
538     @@Return:
539     @@@Type:
540 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
541 wakaba 1.1 @@@Description:
542     @@@@lang:en
543     @@@@@:
544     An associated namespace prefix. If more than one prefix
545     are associated to the namespace URI, the returned prefix
546     is implementation dependent.
547     @@@InCase:
548     @@@@Value:
549     @@@@@is-null:1
550     @@@@Description:
551     @@@@@lang:en
552     @@@@@@:
553     No associated namespace prefix found.
554     @@@PerlDef:
555     $r = null;
556 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
557     .ownerDocument> || $self;
558 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
559 wakaba 1.1 if (defined $namespaceURI) {
560     FIND: {
561     for my $prefix (keys %$binds) {
562     if (defined $binds->{$prefix} and
563     $binds->{$prefix} eq $namespaceURI) {
564     $r = $prefix;
565     last FIND;
566     }
567     }
568 wakaba 1.7
569     ## From module list
570     try {
571     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
572     -><AG::ManakaiDISDocument.disDatabase>;
573     for my $mod_uri (keys %{$db->{modDef}}) {
574     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
575     my $mod_ln = $mod-><AG::ManakaiDISModuleDefinition.localName>;
576     next if exists $binds->{$mod_ln};
577     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
578     .getPropertyText>
579     (<Q::dis:Namespace>, '');
580     if ($ns_uri eq $namespaceURI) {
581     $r = $mod_ln;
582     last FIND;
583     }
584     }
585     } catch <Class::ManakaiDISException> with {
586     my $err = shift;
587     $err->throw
588     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
589     };
590    
591 wakaba 1.1 last FIND unless $makeNewBinding;
592     ## Not found
593     if ($namespaceURI =~ /(\w+)$/) {
594     my $prefix = $1;
595     unless (exists $binds->{$prefix}) {
596     $binds->{$prefix} = $namespaceURI;
597     $r = $prefix;
598     last FIND;
599     }
600     }
601     my $i = 1;
602     {
603     unless (exists $binds->{'ns'.$i}) {
604     $binds->{$r = 'ns'.$i} = $namespaceURI;
605     last FIND;
606     }
607     $i++;
608     redo;
609     }
610     } # FIND
611     } else { ## Null namespace
612     FIND: {
613     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
614     $r = 'nu'.'ll';
615     last FIND;
616     }
617     for my $prefix (keys %$binds) {
618     if (not defined $prefix) {
619     $r = $prefix;
620     last FIND;
621     }
622     }
623     last FIND unless $makeNewBinding;
624     ## Not found
625     my $i = '';
626     {
627     unless (exists $binds->{'nu'.'ll'.$i}) {
628     $binds->{$r = 'nu'.'ll'.$i} = null;
629     last FIND;
630     }
631     $i++;
632     redo;
633     }
634     }
635     }
636    
637     @MethodRedef:
638     @@Name:lookupNamespaceURI
639     @@Description:
640     @@@lang:en
641     @@@@:
642     Looks up the namespace URI associated to the given prefix.
643     @@Param:
644     @@@Name:prefix
645     @@@Type:
646 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
647 wakaba 1.1 @@@Description:
648     @@@@lang:en
649     @@@@@:
650     The namespace URI to look for.
651     @@NamedParam:
652     @@@Name: makeNewBinding
653     @@@Type:
654 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
655 wakaba 1.1 @@@Description:
656     @@@@lang:en
657     @@@@@:
658     Whether a new binding should be created if no namespace URI
659     is associated with the <P::prefix> or not.
660     @@@InCase:
661     @@@@Value:true
662     @@@@Description:
663     @@@@@lang:en
664     @@@@@@:
665     A new binding to the temporary namespace URI
666     exactly same as <P::prefix> is created
667     if no binding found.
668     @@@InCase:
669     @@@@Value:false
670     @@@@Description:
671     @@@@@lang:en
672     @@@@@@:
673     No new binding is created if no binding found. Note that
674     even if no association newly created, this method
675     returns the <DOM::null> value.
676 wakaba 1.12 @@NamedParam:
677     @@@Name: raisePrefixException
678     @@@Type:
679 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
680 wakaba 1.12 @@@enDesc:
681     Whehter an exception should be thrown if <P::prefix>
682     is not declared or not.
683 wakaba 1.1 @@Return:
684 wakaba 1.3 @@@Type: AnyURI
685 wakaba 1.1 @@@Description:
686     @@@@lang:en
687     @@@@@:The associated namespace URI.
688     @@@InCase:
689     @@@@Value:
690     @@@@@is-null:1
691     @@@@Description:
692     @@@@@lang:en
693     @@@@@@:
694 wakaba 1.3 No namespace URI is associated to the prefix or
695 wakaba 1.1 the <DOM::null> namespace is associated.
696 wakaba 1.12 @@@UndeclaredPrefixException:
697 wakaba 1.1 @@@PerlDef:
698 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
699     .ownerDocument> || $self;
700 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
701 wakaba 1.1 if (exists $binds->{$prefix}) {
702     $r = $binds->{$prefix};
703     } else {
704 wakaba 1.7 ## From module list
705     FIND: {
706     try {
707     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
708     -><AG::ManakaiDISDocument.disDatabase>;
709     for my $mod_uri (keys %{$db->{modDef}}) {
710     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
711     if ($mod-><AG::ManakaiDISModuleDefinition.localName>
712     eq $prefix) {
713     $r = $mod-><M::ManakaiDISPropertyAccessor
714     .getPropertyText>
715     (<Q::dis:Namespace>, null);
716     last FIND;
717     }
718     }
719     } catch <Class::ManakaiDISException> with {
720     my $err = shift;
721     $err->throw
722     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
723     };
724     if ($makeNewBinding) {
725     $r = $binds->{$prefix} = $prefix;
726 wakaba 1.12 } elsif ($raisePrefixException) {
727     __EXCEPTION{DIS:UNDECLARED_NS_PREFIX_ERR::
728     infoset:prefix => {$prefix},
729     MDOMX:param-name => 'prefix',
730     DIS:sourceNode => {$self},
731     }__;
732 wakaba 1.7 } else {
733     $r = null;
734     }
735     } # FIND
736 wakaba 1.1 }
737    
738     @IntMethod:
739     @@Name:getNodeReference
740     @@Description:
741     @@@lang:en
742     @@@@:
743     Returns a new reference to the node object.
744     @@ManakaiDOM:isStatic:1
745     @@Param:
746     @@@Name:object
747     @@@Type:
748     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
749     @@@Description:
750     @@@@lang:en
751     @@@@@:
752     The node object to be referred.
753     @@Return:
754     @@@Type: ManakaiDISNode
755     @@@Description:
756     @@@@lang:en
757     @@@@@:
758     A newly created reference.
759     @@@PerlDef:
760     my $class;
761 wakaba 1.5 if ($object->{<Q::swcfg21:nodeType>} eq '#element') {
762 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
763 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#comment') {
764 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
765 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#document') {
766 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
767 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#fragment') {
768 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
769     } else {
770     __ASSERT{DISPerl:invariant::
771 wakaba 1.5 msg => {qq[Node type: "$object->{<Q::swcfg21:nodeType>}" ].
772 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
773     }__;
774     }
775     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
776     .newReference> ($class);
777    
778 wakaba 1.2 @Attr:
779     @@Name:ownerDISDocument
780     @@Description:
781     @@@lang:en
782     @@@@:
783     The <QUOTE::dis> document object associated with this node.
784     @@Get:
785 wakaba 1.3 @@@Type:ManakaiDISDocument
786 wakaba 1.2 @@@Description:
787     @@@@lang:en
788     @@@@@:
789     The document object associated with this node.
790     @@@InCase:
791     @@@@Value:
792     @@@@@is-null:1
793     @@@@Description:
794     @@@@@lang:en
795     @@@@@@:
796     This node is a document node.
797     @@@PerlDef:
798     $r = <ClassM::ManakaiDISNode.getNodeReference>
799     ($self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>})
800     if $self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>};
801 wakaba 1.1 ##DISNode
802    
803     ClsDef:
804     @ClsQName: ManakaiDISElement
805 wakaba 1.7 @ClsISA: ManakaiDISNode
806 wakaba 1.1 @ClsISA:
807 wakaba 1.3 swcfg21:ManakaiSWCFGElement::swcfg21:ForLatest
808 wakaba 1.1 @Description:
809     @@lang:en
810     @@@:
811     <QUOTE::dis> element node objects.
812    
813     @Method:
814     @@Name: forMatch
815     @@Description:
816     @@@lang:en
817     @@@@:
818     Tests whether this element is for a <QUOTE::for> or not.
819     @@Param:
820     @@@Name: forArg
821     @@@Type: ForURI
822     @@@Description:
823     @@@@lang:en
824     @@@@@:
825     The <QUOTE::For> URI reference to test against.
826     @@Param:
827     @@@Name: forpArg
828     @@@Type: ForURIList
829     @@@Description:
830     @@@@lang:en
831     @@@@@:
832     The <QUOTE::For+> URI references to test against.
833     @@@InCase:
834     @@@@Value:
835     @@@@@is-null:1
836     @@@@Description:
837     @@@@@lang:en
838     @@@@@@:
839     No additional <QUOTE::For> URI reference.
840 wakaba 1.3 Equivalent to an empty array reference.
841 wakaba 1.1 @@Return:
842     @@@Type:
843 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
844 wakaba 1.1 @@@Description:
845     @@@@lang:en
846     @@@@@:
847     Whether this element is for <P::forArg> and <P::forpArg> or not.
848 wakaba 1.2 @@@UndeclaredPrefixException:
849     @@@NoDBException:
850     @@@PerlDef:
851 wakaba 1.3 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
852     $forpArg ||= [];
853 wakaba 1.2
854     FORMATCH: {
855     __DEEP{
856 wakaba 1.10 my $for_res = $self-><AG::ManakaiDISNode.ownerDISDocument>
857     -><AG::ManakaiDISDocument.disDatabase>
858     -><M::ManakaiDISDatabase.getFor> ($forArg);
859     my $forp_res = [map {
860     $self-><AG::ManakaiDISNode.ownerDISDocument>
861     -><AG::ManakaiDISDocument.disDatabase>
862     -><M::ManakaiDISDatabase.getFor> ($_)
863     } @{$forpArg}];
864    
865     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
866 wakaba 1.2 for my $ce (@ce) {
867 wakaba 1.3 my $et = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
868     .expandedURI>;
869 wakaba 1.2 if ($et eq <Q::dis:ForCheck>) {
870 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
871     ::swcfg21:ForLatest.value>];
872 wakaba 1.9 FCs: for my $f (@$fors) {
873 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
874 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
875 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
876     -><AG::ManakaiDISDocument.disDatabase>
877     -><M::ManakaiDISDatabase.getFor> ($uri);
878 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
879 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
880     if ($arg_res eq $for) {
881 wakaba 1.2 $r = false;
882     last FORMATCH;
883     }
884     }
885     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
886 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
887 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
888     -><AG::ManakaiDISDocument.disDatabase>
889     -><M::ManakaiDISDatabase.getFor> ($uri);
890 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
891 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
892     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
893 wakaba 1.2 $r = false;
894     last FORMATCH;
895     }
896     }
897     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
898 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
899 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
900     -><AG::ManakaiDISDocument.disDatabase>
901     -><M::ManakaiDISDatabase.getFor> ($uri);
902 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
903 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
904     if ($arg_res eq $for) {
905 wakaba 1.2 next FCs;
906     }
907     }
908     $r = false;
909     last FORMATCH;
910     } else { ## -- ISA
911 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
912 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
913     -><AG::ManakaiDISDocument.disDatabase>
914     -><M::ManakaiDISDatabase.getFor> ($uri);
915 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
916 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
917     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
918 wakaba 1.2 next FCs;
919     }
920     }
921     $r = false;
922     last FORMATCH;
923     }
924     } # FCs
925     } # dis:ForCheck
926     } # children
927    
928     my $has_for = false;
929     for my $ce (@ce) {
930 wakaba 1.11 if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
931 wakaba 1.3 .expandedURI> eq
932 wakaba 1.2 <Q::dis:For>) {
933 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
934     ::swcfg21:ForLatest.value>];
935 wakaba 1.2 my $ok = true;
936     $has_for = true;
937 wakaba 1.9 AFOR: for my $f (@$fors) {
938 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
939 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
940 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
941     -><AG::ManakaiDISDocument.disDatabase>
942     -><M::ManakaiDISDatabase.getFor> ($uri);
943 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
944 wakaba 1.10 if ($for eq $for_res) {
945 wakaba 1.2 $ok = false;
946     last AFOR;
947     }
948     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
949 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
950 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
951     -><AG::ManakaiDISDocument.disDatabase>
952     -><M::ManakaiDISDatabase.getFor> ($uri);
953 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
954 wakaba 1.10 if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
955 wakaba 1.2 $ok = false;
956     last AFOR;
957     }
958     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
959 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
960 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
961     -><AG::ManakaiDISDocument.disDatabase>
962     -><M::ManakaiDISDatabase.getFor> ($uri);
963 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
964 wakaba 1.10 unless ($for eq $for_res) {
965 wakaba 1.2 $ok = false;
966     last AFOR;
967     }
968     } else { ## -- ISA
969 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
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 unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
975 wakaba 1.2 $ok = false;
976     last AFOR;
977     }
978     }
979     } # AFOR
980 wakaba 1.3 if ($ok) {
981     $r = true;
982     last FORMATCH;
983     }
984 wakaba 1.2 } # dis:For
985     } # $ce
986     $r = $has_for ? false : true;
987     }__;
988     } # FORMATCH
989 wakaba 1.1
990     @Method:
991     @@Name: mediaTypeMatch
992     @@Description:
993     @@@lang:en
994     @@@@:
995     Tests whether the content media type of this element matches to
996     a type or not.
997     @@Param:
998     @@@Name: mediaType
999     @@@Type: MediaTypeURI
1000     @@@Description:
1001     @@@@lang:en
1002     @@@@@:
1003     A media type URI reference to test against.
1004     @@Param:
1005 wakaba 1.3 @@@Name: defaultMediaType
1006 wakaba 1.1 @@@Type: MediaTypeURI
1007     @@@Description:
1008     @@@@lang:en
1009     @@@@@:
1010     The default media type for this element.
1011     @@@InCase:
1012     @@@@Value:
1013     @@@@@is-null:1
1014     @@@@Description:
1015     @@@@@lang:en
1016     @@@@@@:
1017     No default type provided. All <P::mediaType> will match.
1018 wakaba 1.12 @@ForParam:
1019     @@ForpParam:
1020 wakaba 1.1 @@Return:
1021     @@@Type:
1022 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1023 wakaba 1.1 @@@Description:
1024     @@@@lang:en
1025     @@@@@:
1026     Whether this element is of <P::mediaType> or not.
1027 wakaba 1.2 @@@PerlDef:
1028     if (defined $mediaType) {
1029     __DEEP{
1030     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1031 wakaba 1.12 (<Q::dis:ContentType>, for_arg => $forArg,
1032     forp_arg => $forpArg);
1033 wakaba 1.2 my $ct;
1034     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1035     $ct = $defaultMediaType unless defined $ct;
1036     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1037     -><AG::ManakaiDISDocument.disDatabase>
1038     -><M::ManakaiDISDatabase.getResource> ($ct);
1039     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
1040 wakaba 1.7 unless ($res-><M::ManakaiDISResourceDefinition
1041 wakaba 1.10 .isSubsetOfURI> ($mediaType)) {
1042 wakaba 1.2 $r = false;
1043     } else {
1044     $r = true;
1045     }
1046     }__;
1047     } else {
1048     $r = true;
1049     }
1050 wakaba 1.1
1051     @Method:
1052 wakaba 1.10 @@Name:mediaTypeURI
1053     @@enDesc:
1054     The URI reference of the media type of this element.
1055     @@Type: MediaTypeURI
1056     @@NamedParam:
1057     @@@Name:defaultMediaType
1058     @@@Type:MediaTypeURI
1059     @@@enDesc:
1060     The default media type URI reference.
1061     @@@nullCase:
1062     @@@@enDesc:
1063     No default is specified.
1064     @@ForParam:
1065     @@ForpParam:
1066     @@Return:
1067     @@@enDesc:
1068     The media type URI reference of this element.
1069     @@@nullCase:
1070     @@@@enDesc:
1071     This element has no media type information and
1072     <P::defaultMediaType> parameter is not provided.
1073     @@@UndeclaredPrefixException:
1074     @@@PerlDef:
1075     __DEEP{
1076     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1077     (<Q::dis:ContentType>, for_arg => $forArg,
1078     forp_arg => $forpArg);
1079     $r = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1080     }__;
1081    
1082     @Method:
1083 wakaba 1.1 @@Name: prefixToURI
1084     @@Description:
1085     @@@lang:en
1086     @@@@:
1087     Converts a namespace prefix into associated URI reference.
1088     @@Param:
1089     @@@Name: prefix
1090     @@@Type:
1091 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
1092 wakaba 1.1 @@@Description:
1093     @@@@lang:en
1094     @@@@@:
1095     A namespace prefix to look for.
1096     @@@InCase:
1097     @@@@Value:
1098     @@@@@is-null:1
1099     @@@@Description:
1100     @@@@@lang:en
1101     @@@@@@:
1102     Returns the default namespace URI.
1103     @@NodeParam:
1104     @@Return:
1105 wakaba 1.3 @@@Type: AnyURI
1106 wakaba 1.1 @@@Description:
1107     @@@@lang:en
1108     @@@@@: The URI references associated.
1109     @@@UndeclaredPrefixException:
1110     @@@PerlDef:
1111 wakaba 1.3 if (defined $prefix) {
1112 wakaba 1.1 __DEEP{
1113 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1114     .lookupNamespaceURI> ($prefix);
1115 wakaba 1.1 }__;
1116     unless (defined $r) {
1117     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
1118     infoset:prefix => {$prefix},
1119     MDOMX:param-name => 'prefix',
1120     DIS:sourceNode => {$node},
1121     }__;
1122     }
1123 wakaba 1.7 } else { ## Default namespace
1124     __DEEP{
1125     $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
1126     -><AG::ManakaiDISDocument.moduleElement>
1127     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
1128     }__;
1129 wakaba 1.1 }
1130    
1131     @Method:
1132     @@QName: qnameToURI
1133     @@Description:
1134     @@@lang:en
1135     @@@@:
1136     Converts a qualified name (<TYPE::dis:TypeQName>) to
1137     an expanded URI reference.
1138     @@Param:
1139     @@@Name: qname
1140     @@@Type:
1141 wakaba 1.18 dis:TypeQName::ManakaiDOM:all
1142 wakaba 1.1 @@@Description:
1143     @@@@lang:en
1144     @@@@@:
1145     A qualified name.
1146     @@NodeParam:
1147 wakaba 1.13 @@NamedParam:
1148     @@@Name: defaultNamespaceURI
1149     @@@Type: AnyURI
1150     @@@enDesc:
1151     Default namespace URI reference.
1152     @@@nullCase:
1153     @@@@enDesc:
1154     The default namespace is the namespace defined by the module
1155     to which this resource belongs.
1156 wakaba 1.1 @@Return:
1157     @@@Type: AnyURI
1158     @@@Description:
1159     @@@@lang:en
1160     @@@@@:
1161     The expanded URI reference.
1162     @@@UndeclaredPrefixException:
1163     @@@PerlDef:
1164     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1165 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1166 wakaba 1.1 __DEEP{
1167     if (defined $lname) {
1168     $r = $self-><M::ManakaiDISElement.prefixToURI> ($prefix) . $lname;
1169     } else { ## In default namespace
1170 wakaba 1.13 if (defined $defaultNamespaceURI) {
1171     $r = $defaultNamespaceURI . $prefix;
1172     } else {
1173     $r = $self-><M::ManakaiDISElement.prefixToURI> (null) . $prefix;
1174     }
1175 wakaba 1.1 }
1176 wakaba 1.4 }__;
1177 wakaba 1.1
1178     @Method:
1179     @@QName: qnameToPair
1180     @@Description:
1181     @@@lang:en
1182     @@@@:
1183     Converts a qualified name (<TYPE::dis:TypeQName>) to
1184     a pair of namespace URI and local name.
1185     @@Param:
1186     @@@Name: qname
1187     @@@Type:
1188 wakaba 1.18 dis:TypeQName::ManakaiDOM:all
1189 wakaba 1.1 @@@Description:
1190     @@@@lang:en
1191     @@@@@:
1192     A qualified name.
1193     @@NodeParam:
1194     @@Return:
1195     @@@Type:
1196 wakaba 1.18 Perl:ARRAY::ManakaiDOM:all
1197 wakaba 1.1 @@@Description:
1198     @@@@lang:en
1199     @@@@@:
1200     A list of namespace URI and local name.
1201     @@@UndeclaredPrefixException:
1202     @@@PerlDef:
1203     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1204 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1205 wakaba 1.1 __DEEP{
1206     if (defined $lname) {
1207     $r = [$self-><M::ManakaiDISElement.prefixToURI> ($prefix), $lname];
1208     } else { ## In default namespace
1209     $r = [$self-><M::ManakaiDISElement.prefixToURI> (null), $prefix];
1210     }
1211 wakaba 1.4 }__;
1212 wakaba 1.1
1213     @Method:
1214 wakaba 1.3 @@Name: tfqnamesToURI
1215 wakaba 1.1 @@Description:
1216     @@@lang:en
1217     @@@@:
1218 wakaba 1.3 Converts a <TYPE::dis:TFQNames>
1219 wakaba 1.1 into an expanded URI reference.
1220     @@Param:
1221     @@@Name: tfqnames
1222     @@@Type:
1223 wakaba 1.18 dis:TFQNames::ManakaiDOM:all
1224 wakaba 1.1 @@@Description:
1225     @@@@lang:en
1226     @@@@@:
1227 wakaba 1.3 A <TYPE::dis:TFQNames> to identify a resource.
1228 wakaba 1.1 @@Param:
1229     @@@Name: defaultTypeURI
1230     @@@Type: NameURI
1231     @@@Description:
1232     @@@@lang:en
1233     @@@@@:
1234     A name URI reference used if it is missing from
1235     <P::tfqnames>.
1236     @@@InCase:
1237     @@@@Value:
1238     @@@@@is-null:1
1239     @@@@Description:
1240     @@@@@lang:en
1241     @@@@@@:
1242     Equivalent to <Q::DOMMain:any>.
1243     @@Param:
1244     @@@Name: defaultForURI
1245     @@@Type: ForURI
1246     @@@Description:
1247     @@@@lang:en
1248     @@@@@:
1249     A <QUOTE::for> URI reference used if it is missing from
1250     <P::tfqnames>.
1251     @@@InCase:
1252     @@@@Value:
1253     @@@@@is-null:1
1254     @@@@Description:
1255     @@@@@lang:en
1256     @@@@@@:
1257     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1258     @@NodeParam:
1259     @@Return:
1260     @@@Type:
1261 wakaba 1.3 DISCore:TFURI::ManakaiDOM:all
1262 wakaba 1.1 @@@Description:
1263     @@@@lang:en
1264     @@@@@:
1265 wakaba 1.3 The <TYPE::dis:TFQNames>-expanded URI references.
1266 wakaba 1.1 @@@UndeclaredPrefixException:
1267     @@@PerlDef:
1268 wakaba 1.15 my ($typeq, $forq) = split /\s*[:|][:|]\s*/, $tfqnames, 2;
1269 wakaba 1.1 my ($typeURI, $forURI);
1270     if (defined $forq) {
1271     __DEEP{
1272     $typeURI = $typeq eq ''
1273     ? defined $defaultTypeURI ? $defaultTypeURI
1274     : <Q::DOMMain:any>
1275     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1276     }__;
1277     if (length $forq) {
1278     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
1279     } else {
1280     $forURI = <Q::ManakaiDOM:all>;
1281     }
1282     } else { ## "For" omitted
1283     __DEEP{
1284     $typeURI = $typeq eq ''
1285     ? defined $defaultTypeURI ? $defaultTypeURI
1286     : <Q::DOMMain:any>
1287     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1288     }__;
1289 wakaba 1.3 $forURI = defined $defaultForURI ? $defaultForURI
1290     : <Q::ManakaiDOM:all>;
1291 wakaba 1.1 }
1292 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
1293 wakaba 1.2
1294     @Method:
1295     @@Name: disGetAttribute
1296     @@enDesc:
1297     Gets an attribute node.
1298     @@Param:
1299     @@@Name: attrName
1300     @@@Type: AnyURI
1301     @@@enDesc:
1302     The name expanded URI of the node to retrieve.
1303     @@ForParam:
1304     @@ForpParam:
1305     @@MediaTypeParam:
1306     @@MediaTypeDefaultParam:
1307     @@Return:
1308     @@@Type: ManakaiDISElement
1309     @@@enDesc:
1310     The attribute (property) element node.
1311     @@@nullCase:
1312     @@@@enDesc:
1313     No attribute node found.
1314     @@@PerlDef:
1315 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1316     (for_arg => $forArg, forp_arg => $forpArg)}) {
1317 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1318     .expandedURI> eq $attrName and
1319 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1320     ($mediaType, $defaultMediaType,
1321     for_arg => $forArg, forp_arg => $forpArg)) {
1322 wakaba 1.2 $r = $c;
1323     last;
1324     }
1325     }
1326    
1327     @Method:
1328     @@Name: disGetAttributeList
1329     @@enDesc:
1330     Gets attribute nodes.
1331 wakaba 1.3 @@Param:
1332     @@@Name: attrName
1333     @@@Type: AnyURI
1334     @@@enDesc:
1335     The name expanded URI of the node to retrieve.
1336 wakaba 1.2 @@ForParam:
1337     @@ForpParam:
1338     @@MediaTypeParam:
1339     @@MediaTypeDefaultParam:
1340     @@Return:
1341     @@@Type: ManakaiDISElementList
1342     @@@enDesc:
1343     The attribute (property) element nodes.
1344     @@@PerlDef:
1345     $r = bless [], <ClassName::ManakaiDISElementList>;
1346 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1347     (for_arg => $forArg, forp_arg => $forpArg)}) {
1348 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1349     .expandedURI> eq $attrName and
1350 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1351     ($mediaType, $defaultMediaType,
1352     for_arg => $forArg, forp_arg => $forpArg)) {
1353 wakaba 1.2 push @$r, $c;
1354     }
1355     }
1356    
1357 wakaba 1.4 @Method:
1358 wakaba 1.2 @@Name: disChildElements
1359     @@enDesc:
1360 wakaba 1.10 A list of child elements, with <QUOTE::for> check.
1361 wakaba 1.4 @@ForParam:
1362     @@ForpParam:
1363     @@Return:
1364     @@@Type: ManakaiDISElementList
1365 wakaba 1.2 @@@enDesc:
1366     The current snapshot of child nodes.
1367     @@@PerlDef:
1368 wakaba 1.4 $r = bless [], <ClassName::ManakaiDISElementList>;
1369     __DEEP{
1370     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1371     .childNodes>}) {
1372     ## $cn is an #element.
1373     my $dn = $cn->{<Q::TreeCore:node>}
1374     -><M::ManakaiDOM:ManakaiDOMNodeObject
1375     ::ManakaiDOM:Perl.newReference>
1376     (<ClassName::ManakaiDISElement>);
1377     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1378     push @$r, $dn;
1379     }
1380     }__;
1381 wakaba 1.5
1382 wakaba 1.10 @Method:
1383     @@Name: disAllChildElements
1384     @@enDesc:
1385     A list of child elements, without <QUOTE::for> check.
1386     @@Return:
1387     @@@Type: ManakaiDISElementList
1388     @@@enDesc:
1389     The current snapshot of child nodes.
1390     @@@PerlDef:
1391     $r = bless [], <ClassName::ManakaiDISElementList>;
1392     __DEEP{
1393     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1394     .childNodes>}) {
1395     ## $cn is an #element.
1396     my $dn = $cn->{<Q::TreeCore:node>}
1397     -><M::ManakaiDOM:ManakaiDOMNodeObject
1398     ::ManakaiDOM:Perl.newReference>
1399     (<ClassName::ManakaiDISElement>);
1400     push @$r, $dn;
1401     }
1402     }__;
1403    
1404 wakaba 1.2 @Attr:
1405     @@Name: qnameValueURI
1406     @@enDesc:
1407     The element value (written as <TYPE::dis:TypeQName>), as URI reference.
1408     \
1409     {NOTE:: What should be if list value?
1410     \
1411     }
1412     @@Get:
1413     @@@Type:AnyURI
1414     @@@nullCase:
1415     @@@@enDesc:
1416     No value.
1417     @@@UndeclaredPrefixException:
1418 wakaba 1.3 @@@PerlDef:
1419 wakaba 1.4 __DEEP{
1420 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1421 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1422 wakaba 1.14 $r = $self-><M::ManakaiDISElement.qnameToURI> ($v, node => $self);
1423 wakaba 1.4 } else {
1424     $r = null;
1425     }
1426     }__;
1427    
1428     @Attr:
1429     @@Name: qnameValueLocalName
1430     @@enDesc:
1431     The local name part of the element value (assumed as
1432     written as <TYPE::dis:TypeQName>).
1433     \
1434     {NOTE:: What should be if list value?
1435     \
1436     }
1437     @@Get:
1438     @@@Type:
1439 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
1440 wakaba 1.4 @@@nullCase:
1441     @@@@enDesc:
1442     No value.
1443     @@@PerlDef:
1444     __DEEP{
1445 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1446 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1447 wakaba 1.15 my ($n, $v) = split /\s*[:|]\s*/, $v, 2;
1448 wakaba 1.4 $r = defined $v ? $v : $n;
1449     } else {
1450     $r = null;
1451     }
1452     }__;
1453    
1454     @Attr:
1455     @@Name: qnameValueNamespaceURI
1456     @@enDesc:
1457     The namespace URI of the element value (assumed as written
1458     in <TYPE::dis:TypeQName>).
1459     \
1460     {NOTE:: What should be if list value?
1461     \
1462     }
1463     @@Get:
1464     @@@Type:AnyURI
1465     @@@nullCase:
1466     @@@@enDesc:
1467     No value.
1468     @@@UndeclaredPrefixException:
1469     @@@PerlDef:
1470     __DEEP{
1471 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1472 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1473 wakaba 1.15 my ($p, $v) = split /\s*[:|]\s*/, $v, 2;
1474 wakaba 1.14 $r = $self-><M::ManakaiDISElement.prefixToURI>
1475 wakaba 1.4 (defined $v ? $p : null);
1476     } else {
1477     $r = null;
1478     }
1479     }__;
1480 wakaba 1.2
1481 wakaba 1.6 @Method:
1482 wakaba 1.3 @@Name: tfqnamesValueURI
1483 wakaba 1.2 @@enDesc:
1484 wakaba 1.3 The element value (written as <TYPE::dis:TFQNames>),
1485 wakaba 1.2 as URI reference.
1486     \
1487     {NOTE:: What should be if list value?
1488     \
1489     }
1490 wakaba 1.6 @@Param:
1491     @@@Name: defaultTypeURI
1492     @@@Type: NameURI
1493     @@@Description:
1494     @@@@lang:en
1495     @@@@@:
1496     A name URI reference used if it is missing from
1497     <P::tfqnames>.
1498     @@@InCase:
1499     @@@@Value:
1500     @@@@@is-null:1
1501     @@@@Description:
1502     @@@@@lang:en
1503     @@@@@@:
1504     Equivalent to <Q::DOMMain:any>.
1505     @@Param:
1506     @@@Name: defaultForURI
1507     @@@Type: ForURI
1508     @@@Description:
1509     @@@@lang:en
1510     @@@@@:
1511     A <QUOTE::for> URI reference used if it is missing from
1512     <P::tfqnames>.
1513     @@@InCase:
1514     @@@@Value:
1515     @@@@@is-null:1
1516     @@@@Description:
1517     @@@@@lang:en
1518     @@@@@@:
1519     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1520     @@Return:
1521 wakaba 1.2 @@@Type:ResourceURI
1522     @@@nullCase:
1523     @@@@enDesc:
1524     No value.
1525     @@@UndeclaredPrefixException:
1526 wakaba 1.3 @@@PerlDef:
1527 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1528 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1529     __DEEP{
1530 wakaba 1.14 $r = $self-><M::ManakaiDISElement.tfqnamesToURI>
1531 wakaba 1.6 ($v, $defaultTypeURI, $defaultForURI);
1532 wakaba 1.2 }__;
1533     } else {
1534     $r = null;
1535     }
1536 wakaba 1.7
1537     @Method:
1538     @@Name: elementTypeMatch
1539     @@enDesc:
1540     Returns whether the element type of this element matches
1541     with another element type (either the same element type or
1542     this type is a subtype of another type).
1543     @@Param:
1544     @@@Name: etype
1545     @@@Type: ResourceURI
1546     @@@enDesc:
1547     An element type name URI reference to test.
1548     @@Return:
1549     @@@Type:
1550 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1551 wakaba 1.7 @@@TrueCase:
1552     @@@@enDesc:
1553     Either the element type expanded URI reference of this element is
1554     same as <P::etype> or it is a sub-element type of <P::etype>.
1555     @@@FalseCase:
1556     @@@@enDesc:
1557     This element is not of <P::etype>.
1558     @@@NoDBException:
1559     @@@PerlDef:
1560     __DEEP{
1561 wakaba 1.14 my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1562 wakaba 1.7 .expandedURI>;
1563     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1564     -><AG::ManakaiDISDocument.disDatabase>
1565     -><M::ManakaiDISDatabase.getResource> ($et);
1566     $r = $rdef-><M::ManakaiDISResourceDefinition.isSubsetOfURI> ($etype);
1567     }__;
1568    
1569     @Attr:
1570     @@Name: isResourceElement
1571     @@enDesc:
1572     Whether this element defines a resource or not.
1573     \
1574     {NOTE:: An element defines a resource if its element type is
1575     <Q::dis:ResourceDef> or its subtype.
1576     \
1577     }
1578     @@Get:
1579     @@@Type:
1580 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1581 wakaba 1.7 @@@TrueCase:
1582     @@@@enDesc:
1583     This element defines a resource.
1584     @@@FalseCase:
1585     @@@@enDesc:
1586     This element does not define any resource.
1587     @@@NoDBException:
1588     @@@PerlDef:
1589     __DEEP{
1590     $r = $self-><M::ManakaiDISElement.elementTypeMatch>
1591     (<Q::dis:ResourceDef>);
1592     }__;
1593    
1594     @Attr:
1595     @@Name: isPropertyElement
1596     @@enDesc:
1597     Whether this element is a property or not.
1598     \
1599     {NOTE:: An element is a property if its element type is
1600     <Q::rdf:type> or if its element type's <Q::rdf:type>
1601     property is <Q::rdf:Property> or is <Q::dis:subsetOf>
1602     <Q::rdf:Property>.
1603     \
1604     }
1605     @@Get:
1606     @@@Type:
1607 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
1608 wakaba 1.7 @@@TrueCase:
1609     @@@@enDesc:
1610     This element is a property.
1611     @@@FalseCase:
1612     @@@@enDesc:
1613     This element is not a property.
1614     @@@NoDBException:
1615     @@@PerlDef:
1616     __DEEP{
1617     my $xn = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1618     .expandedURI>;
1619     if ($xn eq <Q::rdf:type>) {
1620     $r = true;
1621     } else {
1622     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1623     -><AG::ManakaiDISDocument.disDatabase>
1624     -><M::ManakaiDISDatabase.getResource> ($xn);
1625     $r = $rdef-><M::ManakaiDISResourceDefinition.isTypeURI>
1626     (<Q::rdf:Resource>);
1627     }
1628     }__;
1629 wakaba 1.18
1630     @Attr:
1631     @@Name: plImplementation
1632     @@enDesc:
1633     The <Class::PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl>
1634     object.
1635     @@Type:
1636     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
1637     @@Get:
1638     @@@nullCase:
1639     @@@@enDesc:
1640     There is no implementation that supports the feature
1641     <Feature::Util:PerlCode> version <FeatureVer:1.0>.
1642     @@@PerlDef:
1643     $r = ($self-><AG::SWCFGNode.ownerDocument> or
1644     $self)-><AG::SWCFGDoc.implementation>
1645     -><M::DOMMinImpl.getFeature>
1646     (<Q::Util:PerlCode> => '1.0');
1647    
1648     @Method:
1649     @@Name: plValueCodeFragment
1650     @@enDesc:
1651     A Perl code fragment for value attribute.
1652     @@Param:
1653     @@@Name: attrURI
1654     @@@Type: AnyURI
1655     @@@enDesc:
1656     The URI reference name of an attribute.
1657     @@Param:
1658     @@@Name: disDatabase
1659     @@@Type: ManakaiDISDatabase
1660     @@@enDesc:
1661     The <QUOTE::dis> database against which a value is evaluated.
1662     @@ForParam:
1663     @@ForpParam:
1664     @@NamedParam:
1665     @@@Name:dataTypeURI
1666     @@@Type:
1667     ResourceURI
1668     @@@enDesc:
1669     The URI reference of a data type. It is used to convert
1670     untyped value and to define default value if <P::useDefaultValue>
1671     is set to <DOM::true>.
1672     @@@nullCase:
1673     @@@@enDesc:
1674     No data type. If the value is untyped, it is treated
1675     as if <Q::DISCore:String>.
1676     @@NamedParam:
1677     @@@Name:useDefaultValue
1678     @@@Type:
1679     DOMMain:boolean::ManakaiDOM:all
1680     @@@enDesc:
1681     Whether some default value should be provided if possible or not.
1682     @@Type:
1683     MPLCodeFragment
1684     @@Return:
1685     @@@enDesc:
1686     Perl code fragment object for value attribute.
1687     @@@nullCase:
1688     @@@@enDesc:
1689     There is no <P::attrURI> attribute.
1690     @@@UndeclaredPrefixException:
1691     @@@RaiseException:
1692     @@@@@:NO_PERL_CODE_IMPL_ERR
1693     @@@@enDesc:
1694     There is no implementation that implements
1695     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
1696     @@@PerlDef:
1697     __DEEP{
1698     my $dataType;
1699     my $vnode = $self-><M::ManakaiDISElement.disGetAttribute>
1700     ($attrURI,
1701     for_arg => $forArg,
1702     forp_arg => $forpArg);
1703     my $plimpl = $self-><AG::ManakaiDISElement.plImplementation>;
1704     if ($vnode) {
1705     unless ($plimpl) {
1706     __UNDEEP{__EXCEPTION{NO_PERL_CODE_IMPL_ERR}__}__;
1707     }
1708     my $isnull = $vnode-><M::ManakaiDISElement.disGetAttribute>
1709     (<Q::dis:is-null>,
1710     for_arg => $forArg,
1711     forp_arg => $forpArg);
1712     if ($isnull and $isnull-><M::SWCFGNode.value>) {
1713     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('null');
1714     } else {
1715     my $vnode_type_uri = $vnode-><M::ManakaiDISElement.mediaTypeURI>;
1716     my $vnode_value = $vnode-><M::SWCFGNode.value>;
1717     if ($vnode_type_uri) {
1718     my $vnode_type =$disDatabase-><M::ManakaiDISDatabase.getResource>
1719     ($vnode_type_uri);
1720     if ($vnode_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1721     (<Q::dis:Boolean>)) {
1722     $r = $plimpl-><M::MPLImpl.createPerlAtom>
1723     ($vnode_value ? true : false);
1724     } elsif ($vnode_type-><M::ManakaiDISResourceDefinition
1725     .isSubsetOfURI>
1726     (<Q::dis:TypeQName>)) {
1727     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1728     ($self-><M::ManakaiDISElement
1729     .qnameToURI> ($vnode_value,
1730     node => $vnode));
1731     } else { ## DISCore:String or some
1732     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1733     ($vnode_value);
1734     }
1735     } elsif ($dataTypeURI) {
1736     # if () {
1737     #} else { ## DOMMain:DOMString or some
1738     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1739     ($vnode_value);
1740     #}
1741     } else { ## Untyped
1742     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>($vnode_value);
1743     }
1744     }
1745     } # has value
1746    
1747     if (not $r and $useDefaultValue) {
1748     $dataType ||= $disDatabase-><M::ManakaiDISDatabase.getResource>
1749     ($dataTypeURI);
1750     if ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1751     (<Q::DISLang:String>)) {
1752     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral> ('');
1753     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1754     (<Q::DOMMain:boolean>) or
1755     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1756     (<Q::DOMMain:unsigned-long>) or
1757     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1758     (<Q::DOMMain:unsigned-short>) or
1759     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1760     (<Q::DOMMain:long>) or
1761     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1762     (<Q::DOMMain:short>)) {
1763     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('0');
1764     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1765     (<Q::Perl:ARRAY>)) {
1766     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('[]');
1767     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1768     (<Q::Perl:hash>)) {
1769     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('{}');
1770     }
1771     }
1772     }__;
1773 wakaba 1.1 ##DISElement
1774    
1775     ClsDef:
1776 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
1777     @ClsISA: ManakaiDISElement
1778     @enDesc:
1779     The <Q::dis:Module> elements.
1780    
1781     @Attr:
1782     @@Name: requireElement
1783     @@enDesc:
1784     The <Q::dis:Require> child element. The element is
1785     newly created if not exist.
1786     @@Type: ManakaiDISElement
1787     @@Get:
1788     @@@PerlDef:
1789     __DEEP{
1790     $r = $self-><M::swcfg21:SWCFGNode
1791     ::swcfg21:ForLatest.getAttributeNS>
1792     (<Q::dis:>, 'Require', make_new_node => true);
1793     }__;
1794    
1795     @Attr:
1796     @@Name: defaultForURI
1797     @@enDesc:
1798     The value of <Q::dis:DefaultFor> attribute.
1799     @@Type: ForURI
1800     @@Get:
1801     @@@enDesc:
1802     The value of <Q::dis:DefaultFor> child element. If missing,
1803     <Q::ManakaiDOM:all> is returned.
1804     @@@PerlDef:
1805     __DEEP{
1806     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1807     .getAttributeNS>
1808     (<Q::dis:>, 'DefaultFor');
1809     if ($df) {
1810     $r = $df-><AG::ManakaiDISElement.qnameValueURI>
1811     || <Q::ManakaiDOM:all>;
1812     } else {
1813     $r = <Q::ManakaiDOM:all>;
1814     }
1815     }__;
1816     @@Set:
1817     @@@PerlDef:
1818     __DEEP{
1819     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1820     (<Q::dis:>, 'DefaultFor' => $given);
1821     }__;
1822 wakaba 1.7
1823     @Attr:
1824     @@Name: definingNamespaceURI
1825     @@enDesc:
1826     The value of <Q::dis:NamespaceURI> attribute, i.e.
1827     the URI reference of the namespace that this module primary
1828     defines.
1829     \
1830     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
1831     \
1832     }
1833     @@Type: AnyURI
1834     @@Get:
1835     @@@PerlDef:
1836     __DEEP{
1837     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1838     .getAttributeNS>
1839     (<Q::dis:>, 'Namespace');
1840     if ($df) {
1841 wakaba 1.14 $r = $df-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1842 wakaba 1.7 } else {
1843     __ASSERT{DISPerl:invariant::
1844     msg => {qq["dis:Namespace" attribute not found]},
1845     }__;
1846     }
1847     }__;
1848     @@Set:
1849     @@@PerlDef:
1850     __DEEP{
1851     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1852     (<Q::dis:>, 'Namespace' => $given);
1853     }__;
1854 wakaba 1.4 ##DISModuleElement
1855    
1856     ClsDef:
1857 wakaba 1.2 @ClsQName: ManakaiDISElementList
1858     @enDesc:
1859     @@lang:en
1860     @@@:
1861     Lists of elements.
1862     \
1863     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
1864     later changes to the tree does not affect this type of objects.
1865     \
1866     }
1867     ##DISElementList
1868    
1869     ClsDef:
1870 wakaba 1.1 @ClsQName: ManakaiDISComment
1871 wakaba 1.7 @ClsISA: ManakaiDISNode
1872 wakaba 1.1 @ClsISA:
1873 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
1874 wakaba 1.1 @Description:
1875     @@lang:en
1876     @@@:
1877     <QUOTE::dis> comment node objects.
1878     ##DISComment
1879    
1880     ClsDef:
1881     @ClsQName: ManakaiDISDocumentFragment
1882 wakaba 1.7 @ClsISA: ManakaiDISNode
1883 wakaba 1.1 @ClsISA:
1884 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
1885 wakaba 1.1 @Description:
1886     @@lang:en
1887     @@@:
1888     <QUOTE::dis> document fragment node objects.
1889     ##DISDocumentFragment
1890    
1891     ClsDef:
1892     @ClsQName: ManakaiDISDocument
1893 wakaba 1.7 @ClsISA: ManakaiDISNode
1894 wakaba 1.1 @ClsISA:
1895 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
1896 wakaba 1.1 @Description:
1897     @@lang:en
1898     @@@:
1899     <QUOTE::dis> document node objects.
1900 wakaba 1.2
1901     @Attr:
1902 wakaba 1.4 @@Name: moduleElement
1903     @@enDesc:
1904     The <Q::dis:Module> element in this document. The element is
1905     newly created if not exist.
1906     @@Type: ManakaiDISModuleElement
1907     @@Get:
1908     @@@PerlDef:
1909     __DEEP{
1910     $r = $self-><M::swcfg21:SWCFGNode
1911     ::swcfg21:ForLatest.getAttributeNS>
1912     (<Q::dis:>, 'Module', make_new_node => true);
1913     }__;
1914     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
1915    
1916     @Attr:
1917 wakaba 1.2 @@Name: disDatabase
1918     @@enDesc:
1919     Associated <QUOTE::dis> database.
1920    
1921     @@Type: ManakaiDISDatabase
1922     @@Get:
1923     @@@NoDBException:
1924     @@@PerlDef:
1925     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
1926 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
1927 wakaba 1.2 } else {
1928     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
1929     }
1930     @@Set:
1931     @@@PerlDef:
1932     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
1933     require Scalar::Util;
1934     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
1935 wakaba 1.5
1936     @Method:
1937     @@Name: disChildElements
1938     @@enDesc:
1939 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
1940 wakaba 1.5 @@ForParam:
1941     @@ForpParam:
1942     @@Return:
1943     @@@Type: ManakaiDISElementList
1944     @@@enDesc:
1945     The current snapshot of child nodes.
1946     @@@PerlDef:
1947     $r = bless [], <ClassName::ManakaiDISElementList>;
1948     __DEEP{
1949     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1950     .childNodes>}) {
1951     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1952     .nodeType> eq '#element';
1953     my $dn = $cn->{<Q::TreeCore:node>}
1954     -><M::ManakaiDOM:ManakaiDOMNodeObject
1955     ::ManakaiDOM:Perl.newReference>
1956     (<ClassName::ManakaiDISElement>);
1957     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1958     push @$r, $dn;
1959     }
1960     }__;
1961 wakaba 1.10
1962     @Method:
1963     @@Name: disAllChildElements
1964     @@enDesc:
1965     A list of child elements, without <QUOTE::for> checks.
1966     @@Return:
1967     @@@Type: ManakaiDISElementList
1968     @@@enDesc:
1969     The current snapshot of child nodes.
1970     @@@PerlDef:
1971     $r = bless [], <ClassName::ManakaiDISElementList>;
1972     __DEEP{
1973     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1974     .childNodes>}) {
1975     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1976     .nodeType> eq '#element';
1977     my $dn = $cn->{<Q::TreeCore:node>}
1978     -><M::ManakaiDOM:ManakaiDOMNodeObject
1979     ::ManakaiDOM:Perl.newReference>
1980     (<ClassName::ManakaiDISElement>);
1981     push @$r, $dn;
1982     }
1983     }__;
1984 wakaba 1.1 ##DISDocument
1985 wakaba 1.2
1986     PropDef:
1987     @QName: db
1988     @enDesc:
1989     Associated <QUOTE::dis> database.
1990     @rdfs:domain: ManakaiDISDocument
1991     @rdfs:range: ManakaiDISDatabase
1992    
1993     ## -- Definition object database
1994    
1995     ClsDef:
1996     @ClsQName: ManakaiDISDatabase
1997     @enDesc:
1998     Resource database created from <QUOTE::dis> source data.
1999 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2000 wakaba 1.2
2001     @Method:
2002     @@Name: getModule
2003     @@Description:
2004     @@@lang:en
2005     @@@@:
2006     Returns a <QUOTE::dis> module definition.
2007     @@Param:
2008 wakaba 1.9 @@@Name: moduleURI
2009 wakaba 1.2 @@@Type: ModuleURI
2010     @@@Description:
2011     @@@@lang:en
2012     @@@@@:
2013     A <QUOTE::dis> module URI reference.
2014 wakaba 1.9 @@ForParam:
2015 wakaba 1.2 @@Return:
2016     @@@Type: ManakaiDISModuleDefinition
2017     @@@Description:
2018     @@@@lang:en
2019     @@@@@:
2020     The module definition.
2021     @@@PerlDef:
2022 wakaba 1.9 my $modURI;
2023     if (defined $forArg) {
2024     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
2025     $uri => $modURI}__;
2026     } else {
2027     $modURI = $moduleURI;
2028     }
2029 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
2030     $r = $self->{modDef}->{$modURI};
2031     } else {
2032     $r = $self->{modDef}->{$modURI}
2033     = bless {
2034     uri => $modURI,
2035     db => $self,
2036     for => <Q::ManakaiDOM:all>,
2037     forp => [],
2038     }, <ClassName::ManakaiDISModuleDefinition>;
2039     require Scalar::Util;
2040     Scalar::Util::weaken ($r->{db});
2041     }
2042    
2043     @Method:
2044     @@Name: getFor
2045     @@Description:
2046     @@@lang:en
2047     @@@@:
2048     Returns a <QUOTE::for> definition object.
2049     @@Param:
2050     @@@Name: forURI
2051     @@@Type: ForURI
2052     @@@Description:
2053     @@@@lang:en
2054     @@@@@:
2055     A <QUOTE::for> URI reference.
2056     @@@InCase:
2057     @@@@Value:
2058     @@@@@is-null:1
2059     @@@@Description:
2060     @@@@@lang:en
2061     @@@@@@:
2062     Defaulted to <Q::ManakaiDOM:all>.
2063     @@Return:
2064     @@@Type: ManakaiDISForDefinition
2065     @@@PerlDef:
2066     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
2067     if (defined $self->{forDef}->{$forURI}) {
2068     $r = $self->{forDef}->{$forURI};
2069     } else {
2070     $r = $self->{forDef}->{$forURI}
2071     = bless {
2072     uri => $forURI,
2073     isa => {<Q::ManakaiDOM:all> => true},
2074     revISA => {},
2075     db => $self,
2076     }, <ClassName::ManakaiDISForDefinition>;
2077     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
2078     require Scalar::Util;
2079     Scalar::Util::weaken ($r->{db});
2080     }
2081    
2082     @Method:
2083     @@Name: getResource
2084     @@Description:
2085     @@@lang:en
2086     @@@@:
2087     Returns a <QUOTE::dis> resource definition.
2088     @@Param:
2089 wakaba 1.9 @@@Name: resourceURI
2090 wakaba 1.2 @@@Type: ResourceURI
2091     @@@Description:
2092     @@@@lang:en
2093     @@@@@:
2094     A <QUOTE::dis> resource URI reference.
2095 wakaba 1.3 @@@nullCase:
2096 wakaba 1.2 @@@@Description:
2097     @@@@@lang:en
2098     @@@@@@:
2099     Defaulted to <Q::DOMMain:any>.
2100 wakaba 1.9 @@ForParam:
2101 wakaba 1.2 @@Return:
2102     @@@Type: ManakaiDISResourceDefinition
2103     @@@Description:
2104     @@@@lang:en
2105     @@@@@:
2106     The resource definition.
2107     @@@PerlDef:
2108 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
2109     my $resURI;
2110     if (defined $forArg) {
2111     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
2112     $uri => $resURI}__;
2113     } else {
2114     $resURI = $resourceURI;
2115     }
2116 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
2117     $r = $self->{resDef}->{$resURI};
2118     } else {
2119     $r = $self->{resDef}->{$resURI}
2120     = bless {
2121     uri => $resURI,
2122 wakaba 1.6 aliasURI => {$resURI => true},
2123 wakaba 1.2 subOf => {},
2124     supOf => {},
2125     db => $self,
2126     for => <Q::ManakaiDOM:all>,
2127     forp => [],
2128 wakaba 1.9 seq => -1,
2129 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
2130     require Scalar::Util;
2131     Scalar::Util::weaken ($r->{db});
2132     }
2133 wakaba 1.3
2134     @Method:
2135     @@Name: getSourceFile
2136     @@enDesc:
2137     Gets <QUOTE::dis> source document.
2138     @@Param:
2139     @@@Name: fileName
2140     @@@Type: FileURI
2141     @@@enDesc:
2142     A URI reference identifying a file.
2143     @@Return:
2144     @@@Type: ManakaiDISDocument
2145     @@@enDesc:
2146     The <QUOTE::dis> source document.
2147     @@@nullCase:
2148     @@@@enDesc:
2149     No document associated with that <P::fileName>.
2150     @@@PerlDef:
2151     $r = $self->{<Q::sourceFile>}->{$fileName};
2152     @Method:
2153     @@Name: setSourceFile
2154     @@enDesc:
2155     Puts <QUOTE::dis> source document object.
2156     @@Param:
2157     @@@Name: fileName
2158     @@@Type: FileURI
2159     @@@enDesc:
2160 wakaba 1.4 A URI reference identifying a file. If there is already a
2161 wakaba 1.3 source document, then the association has been updated.
2162     @@Param:
2163     @@@Name: doc
2164     @@@Type: ManakaiDISDocument
2165     @@@enDesc:
2166     The document object to set.
2167     @@Return:
2168     @@@PerlDef:
2169     $self->{<Q::sourceFile>}->{$fileName} = $doc;
2170 wakaba 1.4
2171     @Method:
2172     @@Name: loadModule
2173     @@enDesc:
2174     Loads definitions from a <QUOTE::dis> document.
2175     @@Param:
2176     @@@Name: doc
2177     @@@Type:ManakaiDISDocument
2178     @@@enDesc:
2179     The source <QUOTE::dis> document object. Its
2180     <A::ManakaiDISDocument.disDatabase> must be this database.
2181     @@Param:
2182     @@@Name: resolver
2183     @@@Type: DISModuleResolver
2184     @@@enDesc:
2185     The resolver to convert module name into <QUOTE::dis> document object.
2186     @@ForParam:
2187     @@Return:
2188     @@@RaiseException:
2189     @@@@@: NO_MODULE_QNAME_ERR
2190     @@@@enDesc:
2191     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2192     @@@RaiseException:
2193     @@@@@: UNABLE_TO_GET_MODULE_ERR
2194     @@@@enDesc:
2195     The implementation is unable to get a module source.
2196 wakaba 1.5 @@@ForDefDupException:
2197     @@@ForDefNoQNameException:
2198     @@@ResDefDupException:
2199     @@@ElementNotAllowedException:
2200 wakaba 1.7 @@@RaiseException:
2201     @@@@@:NO_REQUIRED_ATTR_ERR
2202     @@@@enDesc:
2203     The <Q::dis:Module> element does not have
2204     <Q::dis:Namespace> attribute.
2205 wakaba 1.4 @@@PerlDef:
2206     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2207     if ref $resolver eq 'CODE';
2208     ## -- Module Name, URI
2209     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2210     my $mod_node;
2211     my $mod_name_node;
2212     __DEEP{
2213     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2214     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2215     ::swcfg21:ForLatest.getAttributeNS>
2216     (<Q::dis:>, 'QName');
2217     unless ($mod_name_node) {
2218     __UNDEEP{
2219     __EXCEPTION{NO_MODULE_QNAME_ERR::
2220     DIS:sourceNode => {$mod_node},
2221     }__;
2222     }__;
2223     }
2224 wakaba 1.5 my $mod_name_uri = $mod_name_node
2225     -><AG::ManakaiDISElement.qnameValueURI>;
2226 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2227     ($mod_name_uri, for_arg => $forArg);
2228 wakaba 1.4
2229 wakaba 1.14 unless ($mod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2230 wakaba 1.4 ## -- Initializes Module Definition Object
2231     $mod->{nameURI} = $mod_name_uri;
2232     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2233     .qnameValueLocalName>;
2234     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2235     .qnameValueNamespaceURI>;
2236     $mod->{for} = $forArg;
2237     $mod->{src} = $mod_node;
2238 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2239 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2240 wakaba 1.5 ($mod->{nameURI} => $doc);
2241    
2242 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2243     = $mod->{src}
2244     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2245     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2246     (<Q::swcfg21:fileName>);
2247 wakaba 1.5
2248 wakaba 1.12 ## -- Loads "for" definition
2249     my $root_elements
2250     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2251     if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2252     for my $el (@$root_elements) {
2253 wakaba 1.14 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2254 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2255     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2256     }
2257     }
2258    
2259 wakaba 1.5 ## -- Loads "for all"
2260 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2261     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2262 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2263     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2264 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2265     $mod->{localName}, <Q::ManakaiDOM:all>);
2266 wakaba 1.5 unless ($rdoc) {
2267     __UNDEEP{
2268     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2269 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2270 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2271     DIS:localName => {$mod->{localName}},
2272 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2273 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2274     }__;
2275     }__;
2276     }
2277     $self-><M::ManakaiDISDatabase.loadModule>
2278 wakaba 1.9 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>);
2279 wakaba 1.5 } # Unless "for all" loaded
2280 wakaba 1.4
2281     ## -- Loads Required Modules
2282 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2283 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2284     .requireElement>;
2285 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2286     .disAllChildElements>}) {
2287 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2288     .expandedURI> eq <Q::dis:Module>;
2289     my ($uri, $nuri, $ln, $for);
2290 wakaba 1.14 my $mqn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2291 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'QName');
2292     if ($mqn) {
2293 wakaba 1.14 my $mqv = $mqn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2294 wakaba 1.4 .value>;
2295 wakaba 1.14 my $mqp = $mqn-><M::ManakaiDISElement.qnameToPair>
2296 wakaba 1.4 ($mqv, node => $mqn);
2297     ($nuri, $ln) = @$mqp;
2298     } else {
2299 wakaba 1.14 my $mn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2300 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'Name');
2301     if ($mn) {
2302     $nuri = $mod->{namespaceURI};
2303 wakaba 1.14 $ln = $mn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2304 wakaba 1.4 } else {
2305     $nuri = $mod->{namespaceURI};
2306     $ln = $mod->{localName};
2307     }
2308     }
2309 wakaba 1.14 my $wfn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2310 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'WithFor');
2311     if ($wfn) {
2312     $for = $wfn-><AG::ManakaiDISElement.qnameValueURI>;
2313     } else {
2314     $for = $mod->{for};
2315     }
2316 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2317     ($nuri . $ln, for_arg => $for);
2318 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2319     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2320 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2321 wakaba 1.4 unless ($rdoc) {
2322     __UNDEEP{
2323     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2324 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2325 wakaba 1.4 DIS:namespaceURI => {$nuri},
2326     DIS:localName => {$ln},
2327     DIS:for => {$for},
2328     DIS:sourceNode => {$rm},
2329     }__;
2330     }__;
2331     }
2332     $self-><M::ManakaiDISDatabase.loadModule>
2333     ($rdoc, $resolver, for_arg => $for);
2334     }
2335     } # Child Module elements
2336    
2337 wakaba 1.12 ## -- Loads child resources
2338 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2339     (for_arg => $forArg);
2340 wakaba 1.5 for my $el (@$root_elements) {
2341 wakaba 1.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2342 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2343 wakaba 1.9 ($mod, null, null, $el,
2344 wakaba 1.7 for_arg => $forArg);
2345     } else {
2346 wakaba 1.14 my $et = $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2347 wakaba 1.7 .expandedURI>;
2348     if ({
2349 wakaba 1.5 <Q::dis:ForDef> => 1,
2350     <Q::dis:Module> => 1,
2351     <Q::dis:ImplNote> => 1,
2352 wakaba 1.7 }->{$et}) {
2353     #
2354     } else {
2355     __UNDEEP{
2356     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2357     DIS:elementType => {$et},
2358     DIS:sourceNode => {$el},
2359     DIS:uri => {$mod->{uri}},
2360     }__;
2361 wakaba 1.5 }__;
2362 wakaba 1.7 }
2363     } # element types
2364     }
2365    
2366     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2367     .getAttributeNS>
2368     (<Q::dis:>, 'Namespace');
2369 wakaba 1.14 unless ($dn and defined $dn-><M::swcfg21:SWCFGNode
2370     ::swcfg21:ForLatest.value>) {
2371 wakaba 1.7 __UNDEEP{
2372     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2373     DIS:elementType => {<Q::dis:Namespace>},
2374     DIS:sourceNode => {$mod_node},
2375 wakaba 1.5 }__;
2376 wakaba 1.7 }__;
2377 wakaba 1.5 }
2378     } # Unless this module loaded
2379     }__; # Deep
2380    
2381     @Method:
2382     @@Name: loadFor
2383     @@enDesc:
2384     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2385     @@Param:
2386     @@@Name: mod
2387     @@@Type: ManakaiDISModuleDefinition
2388     @@@enDesc:
2389     The module in which the <QUOTE::for> to load is defined.
2390     @@Param:
2391     @@@Name: el
2392     @@@Type:ManakaiDISElement
2393     @@@enDesc:
2394     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2395     @@Return:
2396     @@@ForDefDupException:
2397     @@@ForDefNoQNameException:
2398     @@@ElementNotAllowedException:
2399     @@@PerlDef:
2400     __DEEP{
2401     my $qn_node = $el-><M::swcfg21:SWCFGNode
2402     ::swcfg21:ForLatest.getAttributeNS>
2403     (<Q::dis:>, 'QName');
2404     unless ($qn_node) {
2405     __UNDEEP{
2406     __EXCEPTION{NO_FOR_QNAME_ERR::
2407     DIS:sourceNode => {$qn_node},
2408     }__;
2409     }__;
2410     }
2411     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2412     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2413    
2414 wakaba 1.14 unless ($for-><AG::ManakaiDISForDefinition.isDefined>) {
2415 wakaba 1.10 ## -- Initializes "For" Definition Object
2416 wakaba 1.5 $for->{src} = $el;
2417     $for->{<Q::isDefined>} = true;
2418     $for->{<Q::definingModule>} = $mod->{uri};
2419    
2420 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2421 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2422     .expandedURI>;
2423     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2424     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2425 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2426 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2427 wakaba 1.14 $sfor-><AS::ManakaiDISForDefinition.isReferred> ($ce);
2428 wakaba 1.5 ## TODO: warn if dis:Implement
2429     } elsif ({
2430     <Q::dis:Description> => 1,
2431     <Q::dis:ImplNote> => 1,
2432     <Q::dis:FullName> => 1,
2433     <Q::dis:QName> => 1,
2434     }->{$xn}) {
2435     #
2436     } else {
2437     __UNDEEP{
2438     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2439     DIS:elementType => {$xn},
2440     DIS:sourceNode => {$ce},
2441     DIS:uri => {$mod->{uri}},
2442     }__;
2443     }__;
2444     }
2445     }
2446     } else {
2447     __UNDEEP{
2448     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2449     DIS:sourceNode => {$el},
2450     DIS:anotherSourceNode => {$for->{src}},
2451     }__;
2452     }__;
2453     } # isDefine?
2454     }__; # DEEP
2455    
2456     @Method:
2457     @@Name: loadResource
2458     @@enDesc:
2459     Loads definition of a <QUOTE::dis> resource from a
2460     <Q::dis:ResourceDef> element.
2461     @@Param:
2462     @@@Name: mod
2463     @@@Type: ManakaiDISModuleDefinition
2464     @@@enDesc:
2465     The module in which the resource to load is defined.
2466     @@Param:
2467     @@@Name: parentResource
2468     @@@Type: ManakaiDISResourceDefinition
2469     @@@enDesc:
2470 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2471 wakaba 1.5 @@@nullCase:
2472     @@@@enDesc:
2473     The resource to load is a root resource, i.e. <P::el> is
2474     a direct child of the document node.
2475     @@Param:
2476 wakaba 1.7 @@@Name: dynParent
2477 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2478 wakaba 1.7 @@@enDesc:
2479     The dynamic parent resource of the resource to load.
2480 wakaba 1.9 @@@nullCase:
2481 wakaba 1.7 @@@@enDesc:
2482 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2483     a direct child of the document node.
2484 wakaba 1.7 @@Param:
2485 wakaba 1.5 @@@Name: el
2486     @@@Type:ManakaiDISElement
2487     @@@enDesc:
2488     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2489     @@ForParam:
2490     @@ForpParam:
2491     @@Return:
2492     @@@ResDefDupException:
2493     @@@ElementNotAllowedException:
2494     @@@PerlDef:
2495     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2496     $forpArg ||= [];
2497     __DEEP{
2498 wakaba 1.6 ## -- Node names
2499    
2500     ## Unique resource identifier generated from node id
2501     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
2502     my $node_uri;
2503     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
2504     $forp => $forpArg, $uri => $node_uri}__;
2505    
2506     ## User defined resource identifiers
2507 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
2508     (<Q::dis:QName>, for_arg => $forArg,
2509     forp_arg => $forpArg);
2510     my $res;
2511     if ($qn_node) {
2512     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2513 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2514     ($qn_uri, for_arg => $forArg);
2515 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2516 wakaba 1.5 __UNDEEP{
2517     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2518 wakaba 1.9 DIS:uri => {$res->{uri}},
2519 wakaba 1.5 DIS:sourceNode => {$qn_node},
2520     DIS:anotherSourceNode => {$res->{src}},
2521     }__;
2522 wakaba 1.6 }__;
2523 wakaba 1.5 }
2524     $res->{nameURI} = $qn_uri;
2525     $res->{localName} = $qn_node-><AG::ManakaiDISElement
2526     .qnameValueLocalName>;
2527     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
2528     .qnameValueNamespaceURI>;
2529     } else { ## Anonymous or local
2530     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
2531     (<Q::dis:Name>, for_arg => $forArg,
2532     forp_arg => $forpArg);
2533     if ($n_node) {
2534     if ($parentResource) {
2535     my $puri = $parentResource->{uri};
2536     my $ru;
2537 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2538     ::swcfg21:ForLatest.value>;
2539 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
2540     $localName => $ln,
2541     $result => $ru}__;
2542 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2543     ($ru, for_arg => $forArg);
2544 wakaba 1.5 $res->{nameURI} = $ru;
2545 wakaba 1.14 $res->{localName} = $n_node-><M::swcfg21:SWCFGNode
2546     ::swcfg21:ForLatest.value>;
2547 wakaba 1.5 $res->{<Q::isAnon>} = true;
2548     } else { ## Root local name resource
2549 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2550 wakaba 1.7 ::swcfg21:ForLatest.value>;
2551     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2552     .getPropertyText>
2553     (<Q::dis:Namespace>, null);
2554     my $qn_uri = $ns_uri . $ln;
2555 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2556     ($qn_uri, for_arg => $forArg);
2557 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2558 wakaba 1.6 __UNDEEP{
2559     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2560 wakaba 1.9 DIS:uri => {$res->{uri}},
2561 wakaba 1.6 DIS:sourceNode => {$n_node},
2562     DIS:anotherSourceNode => {$res->{src}},
2563     }__;
2564     }__;
2565     }
2566     $res->{nameURI} = $qn_uri;
2567 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2568     $res->{localName} = $ln;
2569 wakaba 1.5 }
2570     } else {
2571 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2572 wakaba 1.5 $res->{<Q::isAnon>} = true;
2573     }
2574 wakaba 1.6 } # anon
2575 wakaba 1.5 $res->{for} = $forArg;
2576     $res->{forp} = $forpArg;
2577     $res->{src} = $el;
2578     $res->{<Q::definingModule>} = $mod->{uri};
2579 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2580     (<Q::DIS:resource>, $res);
2581 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2582     = $parentResource ? $parentResource->{uri} : null;
2583     $res->{<Q::dynamicParentResource>}
2584 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2585     unless ($res->{uri} eq $node_uri) {
2586     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2587     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2588     }
2589 wakaba 1.7 $res->{<Q::isDefined>} = true;
2590 wakaba 1.9 $res->{seq} = $self->{seq}++;
2591    
2592 wakaba 1.6 ## -- Alias
2593     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2594     (<Q::dis:AliasFor>, for_arg => $forArg,
2595     forp_arg => $forpArg);
2596     if ($al_node) {
2597     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2598     ($node_id, $forArg);
2599     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2600     ($canon_uri);
2601 wakaba 1.14 $canon_res-><AS::ManakaiDISResourceDefinition.isReferred> ($al_node);
2602 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
2603     ($res, node => $al_node);
2604 wakaba 1.6 $res = $canon_res;
2605     }
2606 wakaba 1.5
2607 wakaba 1.11 ## -- Registers as child
2608     $parentResource-><M::ManakaiDISPropertyAccessor
2609     .addPropertyResourceList>
2610     (<Q::DIS:childResource>, $res)
2611     if $parentResource;
2612     $dynParent-><M::ManakaiDISPropertyAccessor
2613     .addPropertyResourceList>
2614     (<Q::DIS:dynamicChildResource>, $res)
2615     if $dynParent;
2616    
2617 wakaba 1.7 my $is_multires = false;
2618     my @props;
2619     my @cres;
2620 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2621     (for_arg => $forArg, forp_arg => $forpArg)};
2622 wakaba 1.7 while (@ce0) {
2623     my $ce = shift @ce0;
2624     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2625     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2626     $res->{<Q::rdf:type>}->{$type_uri} = true;
2627     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2628 wakaba 1.14 $type-><AS::ManakaiDISResourceDefinition.isReferred> ($ce);
2629 wakaba 1.7 if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2630     (<Q::dis:MultipleResource>)) {
2631     $is_multires = true;
2632     }
2633     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2634     (<Q::dis:subsetOf>)) {
2635     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2636     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2637     ($node_id, $forArg));
2638     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2639 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
2640 wakaba 1.7 push @cres, $ce;
2641     } else {
2642     ## Property and invalid element is not checked, since not
2643     ## all property definitions has loaded at this stage.
2644     push @props, $ce;
2645     }
2646     } # @ce0
2647    
2648     ## -- Child resources
2649     unless ($is_multires) {
2650     for my $re (@cres) {
2651     unless ($al_node) {
2652     $self-><M::ManakaiDISDatabase.loadResource>
2653     ($mod, $res, $res, $re,
2654     for_arg => $forArg, forp_arg => $forpArg);
2655 wakaba 1.5 } else {
2656 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
2657     (<Q::dis:aliasChild>, for_arg => $forArg,
2658     forp_arg => $forpArg);
2659     if ($ac and $ac-><M::swcfg21:SWCFGNode
2660     ::swcfg21:ForLatest.value>) {
2661     $self-><M::ManakaiDISDatabase.loadResource>
2662     ($mod, $res, $res, $re,
2663     for_arg => $forArg, forp_arg => $forpArg);
2664     }
2665 wakaba 1.4 }
2666     }
2667 wakaba 1.7 }
2668 wakaba 1.5
2669 wakaba 1.7 ## -- Multiple representations
2670     if ($is_multires) {
2671     for my $pe (@props) {
2672     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
2673 wakaba 1.10 (<Q::dis:resourceFor>)) {
2674 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
2675 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2676 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($pe);
2677 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2678     ($mod, $parentResource, $res, $el,
2679     for_arg => $forArg,
2680     forp_arg => [@{$forpArg}, $for_uri]);
2681     }
2682     }
2683     }
2684 wakaba 1.5 }__; # DEEP
2685 wakaba 1.8
2686     @Method:
2687     @@Name: checkUndefinedResource
2688     @@enDesc:
2689     Checks whether there is referred but undefined resource or not.
2690     @@Return:
2691     @@@RaiseException:
2692     @@@@@: FOR_NOT_DEFINED_ERR
2693     @@@@enDesc:
2694     There is a <QUOTE::for> that is referred but not defined.
2695     @@@RaiseException:
2696     @@@@@: RESOURCE_NOT_DEFINED_ERR
2697     @@@@enDesc:
2698     There is a resource that is referred but not defined.
2699     @@@PerlDef:
2700     for my $fd (values %{$self->{forDef}}) {
2701     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
2702     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
2703     __EXCEPTION{FOR_NOT_DEFINED_ERR::
2704     DIS:uri => {$fd->{uri}},
2705     DIS:sourceNode => {$ref},
2706     }__;
2707     }
2708     }
2709     for my $fd (values %{$self->{resDef}}) {
2710     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
2711     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
2712     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2713     DIS:uri => {$fd->{uri}},
2714     DIS:sourceNode => {$ref},
2715     }__;
2716     }
2717     }
2718 wakaba 1.5
2719 wakaba 1.9
2720     @Method:
2721     @@Name: plStore
2722     @@enDesc:
2723     Saves this database to an external file.
2724     \
2725     {NOTE:: Saved files can be loaded by
2726     <M::ManakaiDISImplementation.plLoadDISDatabase>.
2727     \
2728     }
2729     @@Param:
2730     @@@Name: fileName
2731     @@@Type:
2732 wakaba 1.18 DISLang:String::ManakaiDOM:all
2733 wakaba 1.9 @@@enDesc:
2734     An environment-dependent file name of external database to save.
2735     \
2736     {NOTE:: If there is already a file named as <P::fileName>, then
2737     it is overwritten.
2738     \
2739     }
2740     @@Return:
2741     @@@SimpleException:
2742     @@@PerlDef:
2743     use Storable qw/nstore/;
2744     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
2745     nstore $self, $fileName;
2746 wakaba 1.15
2747     @Method:
2748     @@Name: xcrefToResource
2749     @@enDesc:
2750     Returns a resource object selected by an exception code
2751     reference (<Q::DOMMain:XCodeRef>).
2752     @@Param:
2753     @@@Name: xcref
2754     @@@Type:
2755     DOMMain:XCodeRef::ManakaiDOM:all
2756     @@@enDesc:
2757     Exception code to select.
2758     @@Param:
2759     @@@Name: contextNode
2760     @@@Type: ManakaiDISElement
2761     @@@enDesc:
2762     A context element node. Namespace prefixes in
2763     <P::xcref> are resolved against this node.
2764 wakaba 1.16 @@ForParam:
2765 wakaba 1.15 @@NodeParam:
2766     @@Return:
2767     @@@Type:
2768     Perl:ARRAY::ManakaiDOM:all
2769     @@@enDesc:
2770     A reference to the array containing two or three
2771     resource definitions (<Class::ManakaiDISResourceDefinition>).
2772     The first (index <CODE::0>) resource is an exception class.
2773     The second (index <CODE::1>) resource is an exception code
2774     constant. The third (index <CODE::2>) resource
2775     is an exception subtype or <DOM::null> if the reference identifies
2776     no subtype.
2777     @@@RaiseException:
2778     @@@@@: RESOURCE_NOT_DEFINED_ERR
2779     @@@@enDesc:
2780     The resource identified by the <P::xcref> is not defined
2781     or not an exception.
2782     @@@PerlDef:
2783     my ($q1, $q2, $q3) = split /\s*\.\s*/, $xcref, 3;
2784     my $r = [];
2785     __DEEP{
2786     if (defined $q3) {
2787     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
2788 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2789     ($q3, null, $forArg, node => $node));
2790 wakaba 1.15 $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
2791     .getPropertyResource>
2792     (<Q::dis2pm:parentResource>);
2793     } elsif (defined $q2) {
2794     if ($q2 =~ /:/) {
2795     $r->[1] = $self-><M::ManakaiDISDatabase.getResource>
2796 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2797     ($q2, null, $forArg, node => $node));
2798 wakaba 1.15 } else {
2799     $r->[0] = $self-><M::ManakaiDISDatabase.getResource>
2800 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2801     ($q1, null, $forArg, node => $node));
2802 wakaba 1.15 $r->[1] = $r->[0]-><M::ManakaiDISResourceDefinition
2803     .getConstResourceByName> ($q2);
2804     }
2805 wakaba 1.16 } else { ## $q1 only
2806 wakaba 1.15 $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
2807 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2808     ($q1, null, $forArg, node => $node));
2809 wakaba 1.15 if ($r->[2]-><M::ManakaiDISResourceDefinition
2810     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
2811     $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
2812     .getPropertyResource>
2813     (<Q::dis2pm:parentResource>);
2814     } else {
2815     $r->[1] = $r->[2]; CORE::delete $r->[2];
2816     }
2817     }
2818    
2819     if ($r->[2] and
2820     not $r->[2]-><M::ManakaiDISResourceDefinition
2821     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
2822     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2823     DIS:uri => {$r->[2]->{uri}},
2824     DIS:expectedType => {<Q::ManakaiDOM:ExceptionOrWarningSubType>},
2825     DIS:sourceNode => {$node},
2826     DIS:sourceCode => {$xcref},
2827     }__}__;
2828     }
2829 wakaba 1.16 $r->[2]-><AS::ManakaiDISResourceDefinition.isReferred>
2830     ($node or $contextNode)
2831     if $r->[2];
2832 wakaba 1.15
2833     if (not $r->[1] or
2834     not $r->[1]-><M::ManakaiDISResourceDefinition
2835     .isTypeURI> (<Q::ManakaiDOM:Const>)) {
2836     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2837     DIS:uri => {$r->[1]->{uri}},
2838     DIS:localName => {$r->[1]->{localName}},
2839     DIS:expectedType => {<Q::ManakaiDOM:Const>},
2840     DIS:sourceNode => {$node},
2841     DIS:sourceCode => {$xcref},
2842     }__}__;
2843     }
2844 wakaba 1.16 $r->[1]-><AS::ManakaiDISResourceDefinition.isReferred>
2845 wakaba 1.15 ($node or $contextNode);
2846    
2847     unless ($r->[0]) {
2848     my $cg = $r->[1]-><M::ManakaiDISPropertyAccessor
2849     .getPropertyResource>
2850     (<Q::dis2pm:parentResource>);
2851     $r->[0] = $cg-><M::ManakaiDISPropertyAccessor
2852     .getPropertyResource>
2853     (<Q::dis2pm:parentResource>) if $cg;
2854     }
2855     if (not $r->[0] or
2856     not $r->[0]-><M::ManakaiDISResourceDefinition
2857 wakaba 1.16 .isTypeURI> (<Q::DOMException:AnyExceptionClass>)) {
2858 wakaba 1.15 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2859     DIS:uri => {$r->[0]->{uri}},
2860     DIS:localName => {$r->[0]->{localName}},
2861 wakaba 1.16 DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
2862 wakaba 1.15 DIS:sourceNode => {$node},
2863     DIS:sourceCode => {$xcref},
2864     }__}__;
2865     }
2866 wakaba 1.16 $r->[0]-><AS::ManakaiDISResourceDefinition.isReferred>
2867 wakaba 1.15 ($node or $contextNode);
2868     }__;
2869 wakaba 1.2 ##DISDatabase
2870    
2871 wakaba 1.8 PropDef:
2872 wakaba 1.9 @QName: resource
2873     @enDesc:
2874     Resources defined in a module.
2875     @rdfs:range: ManakaiDISResourceDefinition
2876     @rdfs:domain: ManakaiDISModuleDefinition
2877    
2878     PropDef:
2879 wakaba 1.8 @QName:
2880     dis2pm:parentResource
2881     @enDesc:
2882     Static parent resource. No parent for root resources.
2883    
2884     PropDef:
2885     @QName: dynamicParentResource
2886     @enDesc:
2887     Dynamic parent resource. No parent for root resources.
2888    
2889 wakaba 1.11 PropDef:
2890     @QName: childResource
2891     @enDesc:
2892     Static child resources.
2893    
2894     PropDef:
2895     @QName: dynamicChildResource
2896     @enDesc:
2897     Dynamic child resources.
2898    
2899 wakaba 1.5 ElementTypeBinding:
2900     @Name: ForDefDupException
2901     @ElementType:
2902     ManakaiDOM:raises
2903     @ShadowContent:
2904     @@@: FOR_ALREADY_DEFINED_ERR
2905     @@Description:
2906     @@@lang:en
2907     @@@@:
2908     The <QUOTE::for> is already defined elsewhere.
2909    
2910     ElementTypeBinding:
2911     @Name: ForDefNoQNameException
2912     @ElementType:
2913     ManakaiDOM:raises
2914     @ShadowContent:
2915     @@@: NO_FOR_QNAME_ERR
2916     @@Description:
2917     @@@lang:en
2918     @@@@:
2919     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
2920    
2921     ElementTypeBinding:
2922     @Name: ResDefDupException
2923     @ElementType:
2924     ManakaiDOM:raises
2925     @ShadowContent:
2926     @@@: RESOURCE_ALREADY_DEFINED_ERR
2927     @@Description:
2928     @@@lang:en
2929     @@@@:
2930     The <QUOTE::dis> resource is already defined elsewhere.
2931    
2932     ElementTypeBinding:
2933     @Name: ElementNotAllowedException
2934     @ElementType:
2935     ManakaiDOM:raises
2936     @ShadowContent:
2937     @@@: ELEMENT_NOT_ALLOWED_ERR
2938     @@Description:
2939     @@@lang:en
2940     @@@@:
2941     An element has found where it is not allowed.
2942    
2943 wakaba 1.4 IFClsDef:
2944     @QName:
2945     @@@: DISModuleResolver
2946     @@ForCheck: ForIF
2947     @QName:
2948     @@@: ManakaiDISModuleResolver
2949     @@ForCheck: ForClass
2950     @enDesc:
2951     Objects implementing <IF::DISModuleResolver> interface
2952     are used to convert module name into <QUOTE::dis> document object.
2953     \
2954     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
2955     as a method parameter where <IF::DISModuleResolver> is
2956     expected.
2957     \
2958     }
2959     @Method:
2960     @@Name: uriToDocument
2961     @@enDesc:
2962     Returns a <QUOTE::dis> document from module name information.
2963     @@Param:
2964     @@@Name: disDB
2965     @@@Type: ManakaiDISDatabase
2966     @@@enDesc:
2967     The <QUOTE::dis> database.
2968     @@Param:
2969     @@@Name: moduleURI
2970     @@@Type: ModuleURI
2971     @@@enDesc:
2972     The URI reference of the module.
2973     \
2974     {NOTE:: This parameter is redundant, since it can be
2975     composed from other three parameters.
2976     \
2977     }
2978     @@Param:
2979     @@@Name: moduleNamespaceURI
2980     @@@Type: AnyURI
2981     @@@enDesc:
2982     The namespace URI of the module name.
2983     @@Param:
2984     @@@Name: moduleLocalName
2985     @@@Type:
2986 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
2987 wakaba 1.4 @@@enDesc:
2988     The local name of the module name.
2989     @@Param:
2990     @@@Name: moduleFor
2991     @@@Type: ForURI
2992     @@@enDesc:
2993     The <QUOTE::for> URI reference for which the module is defined.
2994     @@Return:
2995     @@@Type: ManakaiDISDocument
2996     @@@enDesc:
2997     The <QUOTE::dis> document. It don't have to be a newly created
2998     object.
2999     @@@nullCase:
3000     @@@@enDesc:
3001     The method is unable to resolve the reference.
3002     @@@PerlDef:
3003     $r = $self->(@_);
3004     @ManakaiDOM:inputNormalizer:
3005     @@ContentType:
3006     lang:Perl
3007     @@@:
3008     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
3009     if ref $INPUT eq 'CODE';
3010     @@ImplNote:
3011     @@@lang:en
3012     @@@@:
3013     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
3014     ##DISModuleResolver
3015    
3016 wakaba 1.3 PropDef:
3017     @QName: sourceFile
3018     @enDesc:
3019     Source <QUOTE::dis> documents.
3020     @rdfs:domain: ManakaiDISDatabase
3021     @rdfs:range: ManakaiDISDocument
3022    
3023 wakaba 1.2 ClsDef:
3024     @ClsQName: ManakaiDISModuleDefinition
3025     @enDesc:
3026     <QUOTE::dis> module definitions.
3027     @ClsISA: ManakaiDISPropertyAccessor
3028 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3029 wakaba 1.2
3030     @Attr:
3031     @@Name: uri
3032     @@Type: ModuleURI
3033     @@Description:
3034     @@@lang:en
3035     @@@@:
3036     The URI reference of this <QUOTE::dis> module.
3037     @@Get:
3038     @@@PerlDef:
3039     $r = $self->{uri};
3040    
3041     @Attr:
3042     @@Name: nameURI
3043     @@Type: NameURI
3044     @@enDesc:
3045     The URI reference of this module, without
3046     <QUOTE::for> identifier.
3047     @@Get:
3048 wakaba 1.3 @@@PerlDef:
3049 wakaba 1.4 $r = $self->{nameURI};
3050 wakaba 1.2
3051     @Attr:
3052     @@Name: localName
3053     @@enDesc:
3054     The local name of this module.
3055     @@Type:
3056 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3057 wakaba 1.2 @@Get:
3058     @@@PerlDef:
3059     $r = $self->{localName};
3060    
3061     @Attr:
3062     @@Name: namespaceURI
3063     @@Type: AnyURI
3064     @@enDesc:
3065     The namespace URI of the name of this resource.
3066     @@Get:
3067     @@@PerlDef:
3068     $r = $self->{namespaceURI};
3069    
3070     @Attr:
3071     @@Name: forURI
3072     @@Type: ForURI
3073     @@enDesc:
3074     The <QUOTE::for> URI reference for which this module is defined.
3075     @@Get:
3076     @@@PerlDef:
3077     $r = $self->{for};
3078    
3079     @Attr:
3080     @@Name: isDefined
3081     @@Description:
3082     @@@lang:en
3083     @@@@:
3084     Whether this module is defined or not.
3085     @@Type:
3086 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3087 wakaba 1.2 @@Get:
3088     @@@PerlDef:
3089     $r = $self->{<Q::isDefined>};
3090 wakaba 1.8
3091     @Attr:
3092     @@Name: plFullyQualifiedName
3093     @@enDesc:
3094     The fully-qualified Perl class package name.
3095     @@Type:
3096     Perl:package-name::ManakaiDOM:all
3097     @@Get:
3098     @@@NoPerlModuleNameException:
3099     @@@PerlDef:
3100     __DEEP{
3101     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3102     ($self->{namespaceURI});
3103     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3104     __UNDEEP{
3105     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3106     DIS:uri => {$self->{namespaceURI}},
3107     DIS:sourceNode => {$self->{src}},
3108     }__;
3109     }__;
3110     }
3111     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3112     (<Q::dis:AppName>, for_arg => $self->{for},
3113 wakaba 1.10 media_type => <Q::lang:Perl>,
3114     default_media_type => <Q::lang:Perl>);
3115 wakaba 1.8 if ($an) {
3116     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3117     $r =~ s/::$//g;
3118     $r .= '::' . $self->{localName};
3119     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3120     (<Q::ManakaiDOM:moduleSuffix>,
3121     for_arg => $self->{for},
3122     media_type => <Q::lang:Perl>,
3123     default_media_type => <Q::lang:Perl>);
3124     if ($sf) {
3125     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3126     }
3127     } else {
3128 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
3129 wakaba 1.8 }
3130     }__;
3131    
3132     @Attr:
3133     @@Name: plInterfaceName
3134     @@enDesc:
3135     The fully-qualified Perl interface package name.
3136     @@Type:
3137     Perl:package-name::ManakaiDOM:all
3138     @@Get:
3139     @@@NoPerlModuleNameException:
3140     @@@PerlDef:
3141     __DEEP{
3142     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3143     ($self->{namespaceURI});
3144     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3145     __UNDEEP{
3146     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3147     DIS:uri => {$self->{namespaceURI}},
3148     DIS:sourceNode => {$self->{src}},
3149     }__;
3150     }__;
3151     }
3152     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3153     (<Q::dis:AppName>, for_arg => $self->{for},
3154     forp_arg => [<Q::ManakaiDOM:ForIF>],
3155 wakaba 1.10 media_type => <Q::lang:Perl>,
3156     default_media_type => <Q::lang:Perl>);
3157 wakaba 1.8 if ($an) {
3158     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3159     $r =~ s/::$//g;
3160     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3161     (<Q::ManakaiDOM:moduleSuffix>,
3162     for_arg => $self->{for},
3163     forp_arg => [<Q::ManakaiDOM:ForIF>],
3164     media_type => <Q::lang:Perl>,
3165     default_media_type => <Q::lang:Perl>);
3166     if ($sf) {
3167     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3168     }
3169     } else {
3170 wakaba 1.14 $r = $self-><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>;
3171 wakaba 1.8 }
3172     }__;
3173 wakaba 1.13
3174     @Method:
3175     @@Name: plAddRequireModule
3176     @@enDesc:
3177     Adds a <QUOTE::dis> module into the list of modules that
3178     defines a Perl module file referred by Perl module file
3179     defined by this module.
3180     @@Param:
3181     @@@Name: moduleArg
3182     @@@Type: ManakaiDISModuleDefinition
3183     @@@enDesc:
3184     A module definition.
3185     @@Return:
3186     @@@RaiseException:
3187     @@@@@: RESOURCE_NOT_DEFINED_ERR
3188     @@@@enDesc:
3189     The module group to which <P::moduleArg> belongs
3190     is not defined.
3191     @@@PerlDef:
3192     __DEEP{
3193     my $pack = $moduleArg-><AG::ManakaiDISModuleDefinition
3194     .plFullyQualifiedName>;
3195     $self->{<Q::DIS:plRequireModule>}->{$pack} = true;
3196     }__;
3197 wakaba 1.2 ##DISModuleDefinition
3198    
3199 wakaba 1.13 PropDef:
3200     @QName: plRequireModule
3201     @enDesc:
3202     A list of Perl package name that this resource is referring.
3203    
3204 wakaba 1.8 ElementTypeBinding:
3205     @Name: NoPerlModuleNameException
3206     @ElementType:
3207     ManakaiDOM:raises
3208     @ShadowContent:
3209     @@@: RESOURCE_NOT_DEFINED_ERR
3210     @@Description:
3211     @@@lang:en
3212     @@@@:
3213     The module group corresponding to the namespace URI
3214     of this module is not defined.
3215    
3216 wakaba 1.2 ClsDef:
3217     @ClsQName: ManakaiDISForDefinition
3218     @Description:
3219     @@lang:en
3220     @@@:
3221     <QUOTE::dis> <QUOTE::for> definitions.
3222 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3223 wakaba 1.2
3224     @Attr:
3225     @@Name: uri
3226     @@Type: ForURI
3227     @@Description:
3228     @@@lang:en
3229     @@@@:
3230     The URI reference of this <QUOTE::for>.
3231     @@Get:
3232     @@@PerlDef:
3233     $r = $self->{uri};
3234 wakaba 1.10
3235     @IntMethod:
3236     @@Operator:
3237     @@@@:eq
3238     @@@ContentType:
3239     lang:Perl
3240     @@enDesc:
3241     Whether two <QUOTE::for> definitions are equal or not.
3242     Two <QUOTE::for> definitions are equal iff one's URI reference
3243     is one of another's URI reference.
3244     \
3245     {NOTE:: Aliases for <QUOTE::for> is not allowed.
3246     \
3247     }
3248     @@ImplNote:
3249     @@@lang:en
3250     @@@@:
3251     In the current implementation, two are equal iff two are
3252     equal as reference.
3253     @@Param:
3254     @@@Name: anotherFor
3255     @@@Type: ManakaiDISForDefinition
3256     @@@enDesc:
3257     Another <QUOTE::for> definition to compare.
3258     @@Return:
3259     @@@Type:
3260 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3261 wakaba 1.10 @@@enDesc:
3262     Whether two resources are equal or not.
3263     @@@PerlDef:
3264     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
3265     $r = $self->{uri} eq $anotherFor->{uri};
3266     } else {
3267     $r = false;
3268     }
3269 wakaba 1.2
3270     @Method:
3271     @@Name: isaURI
3272     @@Description:
3273     @@@lang:en
3274     @@@@:
3275     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
3276     @@Param:
3277     @@@Name: superURI
3278     @@@Type: ForURI
3279     @@@Description:
3280     @@@@lang:en
3281     @@@@@:
3282     Another <QUOTE::for> URI reference to test.
3283     @@Return:
3284     @@@Type:
3285 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3286 wakaba 1.2 @@@TrueCase:
3287     @@@@enDesc:
3288     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
3289     @@@FalseCase:
3290     @@@@enDesc:
3291     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
3292     @@@PerlDef:
3293     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
3294    
3295     @Attr:
3296     @@Name: isDefined
3297     @@Description:
3298     @@@lang:en
3299     @@@@:
3300     Whether this <QUOTE::for> is already defined or not.
3301     @@Type:
3302 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3303 wakaba 1.2 @@Get:
3304     @@@TrueCase:
3305     This <QUOTE::for> is already defined.
3306     @@@FalseCase:
3307     This <QUOTE::for> is not defined.
3308     @@@PerlDef:
3309     $r = $self->{<Q::isDefined>};
3310    
3311     @Attr:
3312     @@Name: isReferred
3313     @@Description:
3314     @@@lang:en
3315     @@@@:
3316     Whether this <QUOTE::for> is referred somewhere or not.
3317 wakaba 1.9 @@Type: ManakaiDISElement
3318 wakaba 1.2 @@Get:
3319     @@@InCase:
3320     @@@@Type:ManakaiDISElement
3321     @@@@enDesc:
3322     This <QUOTE::for> is referred by the element.
3323     @@@nullCase:
3324     This <QUOTE::for> is not referred.
3325     @@@PerlDef:
3326     $r = $self->{<Q::isReferred>};
3327     @@Set:
3328     @@@InCase:
3329     @@@@Type:ManakaiDISElement
3330     @@@@enDesc:
3331     This <QUOTE::for> is referred by the element.
3332     @@@PerlDef:
3333 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3334 wakaba 1.2
3335     @Attr:
3336     @@Name: definingModule
3337     @@Description:
3338     @@@lang:en
3339     @@@@:
3340     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3341     @@Type: ManakaiDISModuleDefinition
3342     @@Get:
3343     @@@Description:
3344     @@@@lang:en
3345     @@@@@:
3346     The module object.
3347 wakaba 1.3 @@@nullCase:
3348 wakaba 1.2 @@@@Description:
3349     @@@@@lang:en
3350     @@@@@@:
3351     This <QUOTE::for> is not associated to any module.
3352     @@@PerlDef:
3353     $r = $self->{db}
3354     -><M::ManakaiDISDatabase.getResource>
3355     ($self->{<Q::definingModule>})
3356     if defined $self->{<Q::definingModule>};
3357 wakaba 1.5
3358 wakaba 1.2 @Method:
3359 wakaba 1.5 @@Name: addISA
3360 wakaba 1.2 @@enDesc:
3361 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3362     <QUOTE::for>.
3363 wakaba 1.2 @@Param:
3364 wakaba 1.5 @@@Name: superFor
3365     @@@Type: ManakaiDISForDefinition
3366     @@@enDesc:
3367     A <QUOTE::for> definition object.
3368 wakaba 1.2 @@Return:
3369     @@@PerlDef:
3370 wakaba 1.5 my @from = ($self->{uri},
3371     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3372     my @to = ($superFor->{uri},
3373     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3374 wakaba 1.7 __DEEP{
3375     for my $from (@from) {
3376     for my $to (@to) {
3377     $self->{db}-><M::ManakaiDISDatabase.getFor>
3378     ($from)->{isa}->{$to} = true;
3379     $self->{db}-><M::ManakaiDISDatabase.getFor>
3380     ($to)->{revISA}->{$from} = true;
3381     }
3382 wakaba 1.5 }
3383 wakaba 1.7 }__;
3384 wakaba 1.5
3385 wakaba 1.2 ##DISForDefinition
3386    
3387     ClsDef:
3388     @ClsQName: ManakaiDISResourceDefinition
3389     @enDesc:
3390     <QUOTE::dis> resource definitions.
3391     @ClsISA: ManakaiDISPropertyAccessor
3392 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3393 wakaba 1.2
3394     @Attr:
3395     @@Name: uri
3396     @@Type: ResourceURI
3397     @@Description:
3398     @@@lang:en
3399     @@@@:
3400     The URI reference of this <QUOTE::dis> resource.
3401     @@Get:
3402     @@@PerlDef:
3403     $r = $self->{uri};
3404    
3405     @Attr:
3406     @@Name: nameURI
3407     @@Type: NameURI
3408     @@enDesc:
3409     The URI reference of this <QUOTE::dis> resource, without
3410     <QUOTE::for> identifier.
3411     @@Get:
3412     @@@nullCase:
3413     @@@@enDesc:
3414     This resource does not have its name URI reference.
3415 wakaba 1.3 @@@PerlDef:
3416 wakaba 1.4 $r = $self->{nameURI};
3417 wakaba 1.2
3418     @Attr:
3419     @@Name: localName
3420     @@enDesc:
3421     The local name of this resource.
3422     @@Type:
3423 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3424 wakaba 1.2 @@Get:
3425     @@@nullCase:
3426     @@@@enDesc:
3427     This resource does not have its local name.
3428     @@@PerlDef:
3429     $r = $self->{localName};
3430    
3431     @Attr:
3432     @@Name: namespaceURI
3433     @@Type: AnyURI
3434     @@enDesc:
3435     The namespace URI of the name of this resource.
3436     @@Get:
3437     @@@nullCase:
3438     The name of this resource does not have its namespace
3439     or this resource does not have its name.
3440     @@@PerlDef:
3441     $r = $self->{namespaceURI};
3442    
3443     @Attr:
3444     @@Name: isAnonymous
3445     @@enDesc:
3446     Whether this <QUOTE::dis> resource has name or not.
3447     @@Type:
3448 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3449 wakaba 1.2 @@Get:
3450     @@@TrueCase:
3451     This resource does not have any global unique name.
3452     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3453     @@@FalseCase:
3454     This resource does have its formal name.
3455     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3456     generated from the name and the <QUOTE::for> URI reference
3457     of this resource.
3458     @@@PerlDef:
3459     $r = $self->{<Q::isAnon>};
3460    
3461     @Attr:
3462     @@Name: forURI
3463     @@enDesc:
3464     The <QUOTE::for> URI reference for which this resource is defined.
3465     @@Type:ForURI
3466     @@Get:
3467     @@@PerlDef:
3468     $r = $self->{for};
3469    
3470     @Attr:
3471     @@Name: forpURI
3472     @@enDesc:
3473     The <QUOTE::for+> URI references for which this resource is defined.
3474     @@Type: ForURIList
3475     @@Get:
3476 wakaba 1.15 @@@enDesc:
3477     List of <QUOTE::for> URI references. Note that this list is
3478     <QUOTE::dead>.
3479 wakaba 1.3 @@@PerlDef:
3480 wakaba 1.15 $r = [@{$self->{forp}}];
3481    
3482     @Method:
3483     @@Name: isForURI
3484     @@enDesc:
3485     Tests whether this resource is defined for a <QUOTE::for>
3486     or <QUOTE::for+> URI reference or not.
3487     @@Param:
3488     @@@Name:forURI
3489     @@@Type:ForURI
3490     @@@enDesc:
3491     A <QUOTE::for> URI reference to test.
3492     @@Return:
3493     @@@Type:
3494     DOMMain:boolean::ManakaiDOM:all
3495     @@@TrueCase:
3496     @@@@enDesc:
3497     This resource is for <P::forURI>.
3498     @@@FalseCase:
3499     @@@@enDesc:
3500     This resource is not for <P::forURI>.
3501     @@@PerlDef:
3502     __DEEP{
3503     for my $this_for_uri ($self->{for}, @{$self->{forp}}) {
3504     if ($this_for_uri eq $forURI) { ## Shortcut
3505     $r = true;
3506     last;
3507     }
3508     my $this_for = $self->{db}-><M::ManakaiDISDatabase.getFor>
3509     ($this_for_uri);
3510     if ($this_for-><M::ManakaiDISForDefinition.isaURI> ($forURI)) {
3511     $r = true;
3512     last;
3513     }
3514     }
3515     }__;
3516 wakaba 1.2
3517     @Method:
3518 wakaba 1.7 @@Name: isSubsetOfURI
3519 wakaba 1.2 @@Description:
3520     @@@lang:en
3521     @@@@:
3522     Whether this resource is a subset of another resource or not.
3523     @@Param:
3524     @@@Name: superURI
3525     @@@Type: ResourceURI
3526     @@@Description:
3527     @@@@lang:en
3528     @@@@@:
3529     Another resource URI reference to test.
3530     @@Return:
3531     @@@Type:
3532 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3533 wakaba 1.2 @@@TrueCase:
3534     @@@@enDesc:
3535     <P::superURI> is a super-resource of this resource.
3536     @@@FalseCase:
3537     @@@@enDesc:
3538     <P::superURI> is not a super-resource of this resource.
3539     @@@PerlDef:
3540 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3541 wakaba 1.2
3542 wakaba 1.7 @Method:
3543     @@Name: addSuperResource
3544     @@enDesc:
3545     Adds a <QUOTE::dis> resource to the list of super-resource
3546     of this <QUOTE::dis> resource.
3547     @@Param:
3548     @@@Name: superRes
3549     @@@Type: ManakaiDISResourceDefinition
3550     @@@enDesc:
3551     A <QUOTE::dis> resource definition object.
3552     @@Return:
3553     @@@PerlDef:
3554     my @from = ($self->{uri},
3555     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3556     my @to = ($superRes->{uri},
3557     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3558     __DEEP{
3559     for my $from (@from) {
3560     for my $to (@to) {
3561     $self->{db}-><M::ManakaiDISDatabase.getResource>
3562     ($from)->{subOf}->{$to} = true;
3563     $self->{db}-><M::ManakaiDISDatabase.getResource>
3564     ($to)->{supOf}->{$from} = true;
3565     }
3566     }
3567     }__;
3568    
3569 wakaba 1.2 @Attr:
3570     @@Name: isDefined
3571     @@Description:
3572     @@@lang:en
3573     @@@@:
3574     Whether this resource is already defined or not.
3575     @@Type:
3576 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3577 wakaba 1.2 @@Get:
3578     @@@TrueCase:
3579     This resource is already defined.
3580     @@@FalseCase:
3581     This resource is not defined.
3582     @@@PerlDef:
3583     $r = $self->{<Q::isDefined>};
3584    
3585     @Attr:
3586     @@Name: isReferred
3587     @@Description:
3588     @@@lang:en
3589     @@@@:
3590     Whether this resource is referred or not.
3591 wakaba 1.7 @@Type: ManakaiDISElement
3592 wakaba 1.2 @@Get:
3593 wakaba 1.7 @@@enDesc:
3594 wakaba 1.9 An element that referres this resource.
3595 wakaba 1.2 @@@nullCase:
3596     This resource is not referred.
3597     @@@PerlDef:
3598     $r = $self->{<Q::isReferred>};
3599     @@Set:
3600 wakaba 1.7 @@@enDesc:
3601 wakaba 1.9 An element that referres this resource.
3602 wakaba 1.2 @@@PerlDef:
3603 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3604 wakaba 1.2
3605     @Attr:
3606     @@Name: definingModule
3607     @@Description:
3608     @@@lang:en
3609     @@@@:
3610     The <QUOTE::dis> module in which this resource is defined.
3611 wakaba 1.8 \
3612     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3613     \
3614     }
3615 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3616     @@Get:
3617     @@@Description:
3618     @@@@lang:en
3619     @@@@@:
3620     The module object.
3621 wakaba 1.3 @@@nullCase:
3622 wakaba 1.2 @@@@Description:
3623     @@@@@lang:en
3624     @@@@@@:
3625     This resource is not associated to any module.
3626     @@@PerlDef:
3627     $r = $self->{db}
3628     -><M::ManakaiDISDatabase.getModule>
3629     ($self->{<Q::definingModule>})
3630     if defined $self->{<Q::definingModule>};
3631     @@Set:
3632     @@@Description:
3633     @@@@lang:en
3634     @@@@@:
3635     The module object to which the <QUOTE::defining module> is set.
3636     @@@PerlDef:
3637     $self->{<Q::defininingModule>}
3638     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3639    
3640 wakaba 1.6 @Method:
3641     @@Name: mergeAsAlias
3642     @@enDesc:
3643     Merges another resource definition as an alias of this resource.
3644     @@Param:
3645     @@@Name: aliasResource
3646     @@@Type: ManakaiDISResourceDefinition
3647     @@@enDesc:
3648     A resource to merge.
3649     \
3650     {NOTE:: After merging all references to <P::aliasResource>
3651     should be discarded.
3652     \
3653     }
3654 wakaba 1.11 @@NodeParam:
3655 wakaba 1.6 @@Return:
3656 wakaba 1.11 @@@RaiseException:
3657     @@@@@:MERGE_ITSELF_ERR
3658     @@@@@@enDesc:
3659     An attempt is made to merge this resource itself.
3660     @@@PerlDef:
3661     if ($self eq $aliasResource) {
3662     __EXCEPTION{MERGE_ITSELF_ERR::
3663     DIS:uri => {$self->{uri}},
3664     DIS:sourceNode => {$node},
3665     }__;
3666     }
3667 wakaba 1.6 for my $uri ($aliasResource->{uri},
3668     grep {$aliasResource->{aliasURI}->{$_}}
3669     keys %{$aliasResource->{aliasURI}}) {
3670     $self->{aliasURI}->{$uri} = true;
3671     $self->{db}->{resDef}->{$uri} = $self;
3672     $self->{subOf}->{$uri} = true;
3673     $self->{supOf}->{$uri} = true;
3674     }
3675     for my $uri (grep {$aliasResource->{subOf}->{$_}}
3676     keys %{$aliasResource->{subOf}}) {
3677     $self->{subOf}->{$uri} = true;
3678     }
3679     for my $uri (grep {$aliasResource->{supOf}->{$_}}
3680     keys %{$aliasResource->{supOf}}) {
3681     $self->{supOf}->{$uri} = true;
3682     }
3683     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
3684     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
3685     __DEEP{
3686     for my $from (@from) {
3687     for my $to (@to) {
3688     $self->{db}-><M::ManakaiDISDatabase.getResource>
3689     ($from)->{subOf}->{$to} = true;
3690     $self->{db}-><M::ManakaiDISDatabase.getResource>
3691     ($to)->{supOf}->{$from} = true;
3692     }
3693     }
3694     }__;
3695 wakaba 1.7
3696     @Method:
3697     @@Name: isTypeURI
3698     @@enDesc:
3699     Tests whether this resource is of a type or not.
3700     @@Param:
3701     @@@Name: typeURI
3702     @@@Type: ResourceURI
3703     @@@enDesc:
3704     A type URI reference to test.
3705     @@Return:
3706     @@@Type:
3707 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3708 wakaba 1.7 @@@TrueCase:
3709     @@@@enDesc:
3710     This is a <P::typeURI> resource.
3711     @@@FalseCase:
3712     @@@@enDesc:
3713     This is not a <P::typeURI> resource.
3714     @@@PerlDef:
3715 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
3716     $r = $self->{<Q::rdf:type>}->{$typeURI};
3717     } else {
3718     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
3719     keys %{$self->{<Q::rdf:type>}}) {
3720     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
3721     ($t_type_uri);
3722     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3723     ($typeURI)) {
3724     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
3725     last;
3726     }
3727 wakaba 1.7 }
3728     }
3729 wakaba 1.8
3730     @Attr:
3731     @@Name: plName
3732     @@enDesc:
3733     The Perl name of this resource.
3734     @@Get:
3735     @@@Type:
3736 wakaba 1.18 DISLang:String::ManakaiDOM:all
3737 wakaba 1.8 @@@enDesc:
3738     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
3739     \
3740     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
3741     <CHAR::COLON> prefix).
3742     \
3743     - <Q::DISLang:Attribute>::: Method name.
3744     \
3745     - <Q::DISLang:Method>::: Method name.
3746     @@@nullCase:
3747     @@@@enDesc:
3748     Either the type of this resource is not listed above
3749     or this Perl constructure is anonymous.
3750     @@@RaiseException:
3751     @@@@@: NO_LOCAL_NAME_ERR
3752     @@@@enDesc:
3753     The type of this resource is either
3754     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
3755     the local name of this resource is not defined.
3756     @@@RaiseException:
3757     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
3758     @@@@enDesc:
3759     The Perl method name constructed from the source
3760     result in a reserved name.
3761     @@@PerlDef:
3762     __DEEP{
3763     if (exists $self->{<Q::dis2pm:name>}) {
3764     $r = $self->{<Q::dis2pm:name>};
3765     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3766     (<Q::ManakaiDOM:Const>) or
3767     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3768     (<Q::ManakaiDOM:ConstGroup>)) {
3769     $r = $self->{localName};
3770     unless (defined $r) {
3771     __UNDEEP{
3772     __EXCEPTION{NO_LOCAL_NAME_ERR::
3773 wakaba 1.18 DIS:uri => {$self->{uri}},
3774 wakaba 1.8 DIS:sourceNode => {$self->{src}},
3775     }__;
3776     }__;
3777     }
3778     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3779     (<Q::DISLang:Method>) or
3780     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3781     (<Q::DISLang:Attribute>)) {
3782     if (defined $self->{localName}) {
3783     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
3784     ($self->{localName});
3785     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3786     (<Q::ManakaiDOM:isForInternal>, false)) {
3787     $r = '_' . $r;
3788     }
3789     if ({
3790     import => 1,
3791     unimport => 1,
3792     isa => 1,
3793     can => 1,
3794     new => 1,
3795     as_string => 1,
3796     stringify => 1,
3797     clone => 1,
3798     }->{$r} or $r =~ /^___/) {
3799     __UNDEEP{
3800     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
3801     DIS:uri => {$self->{uri}},
3802     DIS:soruceNode => {$self->{src}},
3803     DIS:generatedName => {$r},
3804     }__;
3805     }__;
3806 wakaba 1.11 }
3807     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
3808 wakaba 1.8 .plMethodOperator>) {
3809     $r = {
3810     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
3811     <Q::DISPerl:AsStringMethod> => 'as_string',
3812 wakaba 1.16 <Q::DISPerl:NewMethod> => 'new',
3813     <Q::DISPerl:CloneMethod> => 'clone',
3814 wakaba 1.8 }->{$op_uri};
3815     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
3816     } else {
3817     $r = null;
3818     }
3819     } else {
3820     $r = null;
3821     }
3822     $self->{<Q::dis2pm:name>} = $r;
3823     }__;
3824    
3825     @Attr:
3826     @@Name: plFullyQualifiedName
3827     @@enDesc:
3828     The fully-qualified Perl name of this resource.
3829     @@Type:
3830     DISLang:String::ManakaiDOM:all
3831     @@Get:
3832     @@@enDesc:
3833     Fully-qualified name.
3834     \
3835     - <Q::ManakaiDOM:Class>::: Class package name.
3836     \
3837     - <Q::ManakaiDOM:IF>::: Interface package name.
3838     \
3839     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
3840     type symbol such as <CODE::$>).
3841     @@@nullCase:
3842     @@@@enDesc:
3843     Otherwise.
3844     @@@NoPerlModuleNameException:
3845     @@@RaiseException:
3846     @@@@@: NO_LOCAL_NAME_ERR
3847     @@@@enDesc:
3848     The local name of this resource is not defined.
3849     @@@PerlDef:
3850     __DEEP{
3851     if (exists $self->{<Q::dis2pm:name>}) {
3852     $r = $self->{<Q::dis2pm:name>};
3853     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3854     (<Q::ManakaiDOM:Class>) or
3855     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3856     (<Q::ManakaiDOM:IF>) or
3857     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3858     (<Q::DISPerl:ScalarVariable>)) {
3859 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3860 wakaba 1.8 (<Q::dis:AppName>, for_arg => $self->{for},
3861     forp_arg => $self->{forp},
3862     media_type => <Q::lang:Perl>);
3863     if ($an_node) {
3864     ## NOTE: "lang:Perl" is fully-qualified name by definition
3865 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3866 wakaba 1.8 } else {
3867 wakaba 1.10 unless (defined $self->{localName}) {
3868     __UNDEEP{
3869     __EXCEPTION{NO_LOCAL_NAME_ERR::
3870     DIS:sourceNode => {$self->{src}},
3871     }__;
3872     }__;
3873     }
3874 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3875     (<Q::ManakaiDOM:IF>)) {
3876     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3877 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
3878 wakaba 1.8 . '::' . $self->{localName};
3879     } else {
3880     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3881 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
3882 wakaba 1.8 . '::' . $self->{localName};
3883     }
3884     }
3885     } else {
3886     $r = null;
3887     }
3888     $self->{<Q::dis2pm:name>} = $r;
3889     }__;
3890    
3891     @Attr:
3892 wakaba 1.15 @@Name: plVariableName
3893     @@enDesc:
3894     The Perl variable name with prefix.
3895     @@Type:
3896     lang:Perl::ManakaiDOM:all
3897     @@Get:
3898     @@@nullCase:
3899     @@@@enDesc:
3900     This resource does not define any Perl variable.
3901     @@@PerlDef:
3902     $r = $self->{localName};
3903     if (defined $r) {
3904     __DEEP{
3905 wakaba 1.18 if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3906     (<Q::DISPerl:isNamedParameter>, false)) {
3907     $r = '$opt{' .
3908     <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName> .
3909     '}';
3910     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3911     (<Q::Perl:Array>)) {
3912     $r = '@' . $r;
3913     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3914     (<Q::Perl:Hash>)) {
3915     $r = '%' . $r;
3916     } else {
3917     $r = '$' . $r;
3918     }
3919     }__;
3920     }
3921    
3922     @Attr:
3923     @@Name: plPrototype
3924     @@enDesc:
3925     The Perl parameter prototype character.
3926     @@Type:
3927     lang:Perl::ManakaiDOM:all
3928     @@Get:
3929     @@@PerlDef:
3930     __DEEP{
3931 wakaba 1.15 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3932     (<Q::Perl:Array>)) {
3933     $r = '@' . $r;
3934     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3935     (<Q::Perl:Hash>)) {
3936     $r = '%' . $r;
3937     } else {
3938     $r = '$' . $r;
3939     }
3940     }__;
3941    
3942     @Attr:
3943 wakaba 1.8 @@Name: plMethodOperator
3944     @@enDesc:
3945     The operator to overload by this method.
3946     @@Type:
3947     DISLang:String::ManakaiDOM:all
3948     @@Get:
3949     @@@enDesc:
3950     The operator, either Perl <CODE::use operator> operator name
3951     of manakai operator URI reference.
3952     @@@nullCase:
3953     @@@@enDesc:
3954     Either this resource does not define a Perl method or
3955     this method does not overload any operator.
3956     @@@UndeclaredPrefixException:
3957     @@@RaiseException:
3958     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
3959     @@@@enDesc:
3960     Media type of the <Q::dis:Operator> node is not supported.
3961     @@@PerlDef:
3962     __DEEP{
3963     if (exists $self->{<Q::dis:Operator>}) {
3964     $r = $self->{<Q::dis:Operator>};
3965     } else {
3966     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3967     (<Q::dis:Operator>, for_arg => $self->{for},
3968     forp_arg => $self->{forp});
3969     if ($op_node) {
3970     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3971 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
3972     for_arg => $self->{forp})) {
3973 wakaba 1.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3974 wakaba 1.8 } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3975 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
3976     for_arg => $self->{forp})) {
3977 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
3978     } else {
3979 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
3980     (for_arg => $self->{for},
3981     forp_arg => $self->{forp});
3982 wakaba 1.8 __UNDEEP{
3983     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3984     DIS:uri => {$ct_uri},
3985 wakaba 1.10 DIS:sourceNode => {$op_node},
3986 wakaba 1.8 }__;
3987     }__;
3988     }
3989     } else {
3990     $r = null;
3991     }
3992     $self->{<Q::dis:Operator>} = $r;
3993     }
3994     }__;
3995    
3996     @Attr:
3997     @@Name: disDataTypeResource
3998     @@enDesc:
3999     <Q::dis:Type> attribute value of this resource.
4000     @@Type: ManakaiDISResourceDefinition
4001     @@Get:
4002     @@@RaiseException:
4003     @@@@@:NO_DIS_TYPE_ERR
4004     @@@@enDesc:
4005     <Q::dis:Type> attribute is not specified.
4006     @@@PerlDef:
4007     __DEEP{
4008     if (defined $self->{<Q::dis:Type>}) {
4009 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4010     ($self->{<Q::dis:Type>});
4011 wakaba 1.8 } else {
4012     $self->{<Q::dis2pm:TypeNode>}
4013     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4014     (<Q::dis:Type>, for_arg => $self->{for},
4015     forp_arg => $self->{forp});
4016     if ($self->{<Q::dis2pm:TypeNode>}) {
4017     $r = $self->{<Q::dis:Type>}
4018     = $self->{<Q::dis2pm:TypeNode>}
4019 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4020     (null, $self->{for});
4021     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4022     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4023     ($self->{<Q::dis2pm:TypeNode>});
4024 wakaba 1.8 } else {
4025     my $pr = $self-><M::ManakaiDISPropertyAccessor
4026     .getPropertyResource>
4027     (<Q::DIS:dynamicParentResource>);
4028     if ($pr) {
4029     $r = $pr-><AG::ManakaiDISResourceDefinition
4030     .disDataTypeResource>;
4031     $self->{<Q::dis2pm:TypeNode>}
4032     = $pr->{<Q::dis2pm:TypeNode>};
4033 wakaba 1.18 $self->{<Q::dis:Type>}
4034     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4035 wakaba 1.8 } else { ## No parent
4036     __UNDEEP{
4037     __EXCEPTION{NO_DIS_TYPE_ERR::
4038     DIS:sourceNode => {$self->{src}},
4039     }__;
4040     }__;
4041     }
4042     }
4043     }
4044     }__;
4045    
4046     @Attr:
4047     @@Name: disDataTypeNode
4048     @@enDesc:
4049     <Q::dis:Type> node for this resource.
4050     @@Get:
4051     @@@Type: ManakaiDISElement
4052     @@@RaiseException:
4053     @@@@@:NO_DIS_TYPE_ERR
4054     @@@@enDesc:
4055     <Q::dis:Type> attribute is not specified.
4056     @@@PerlDef:
4057     __DEEP{
4058 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disDataTypeResource>;
4059 wakaba 1.8 }__;
4060     $r = $self->{<Q::dis2pm:TypeNode>};
4061    
4062     @Attr:
4063     @@Name: disActualDataTypeResource
4064     @@enDesc:
4065     <Q::dis:actualType> attribute value of this resource.
4066     @@Type: ManakaiDISResourceDefinition
4067     @@Get:
4068     @@@RaiseException:
4069     @@@@@:NO_DIS_TYPE_ERR
4070     @@@@enDesc:
4071     <Q::dis:actualType> attribute is not specified,
4072     and <Q::dis:Type> attribute, neigher.
4073     @@@PerlDef:
4074     __DEEP{
4075     if (defined $self->{<Q::dis:actualType>}) {
4076 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4077     ($self->{<Q::dis:actualType>});
4078 wakaba 1.8 } else {
4079     $self->{<Q::dis2pm:actualTypeNode>}
4080     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4081     (<Q::dis:actualType>, for_arg => $self->{for},
4082     forp_arg => $self->{forp});
4083     if ($self->{<Q::dis2pm:actualTypeNode>}) {
4084     $r = $self->{<Q::dis:actualType>}
4085     = $self->{<Q::dis2pm:actualTypeNode>}
4086 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4087     (null, $self->{for});
4088     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4089     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4090     ($self->{<Q::dis2pm:actualTypeNode>});
4091 wakaba 1.8 } elsif (defined $self->{<Q::dis:Type>}) {
4092     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
4093     $self->{<Q::dis2pm:actualTypeNode>}
4094     = $self->{<Q::dis2pm:TypeNode>};
4095 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4096 wakaba 1.8 } else {
4097     $self->{<Q::dis2pm:actualTypeNode>}
4098     = $self->{<Q::dis2pm:TypeNode>}
4099     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4100     (<Q::dis:Type>, for_arg => $self->{for},
4101     forp_arg => $self->{forp});
4102     if ($self->{<Q::dis2pm:TypeNode>}) {
4103     $r = $self->{<Q::dis:actualType>}
4104     = $self->{<Q::dis:Type>}
4105     = $self->{<Q::dis2pm:TypeNode>}
4106 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4107     (null, $self->{for});
4108     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4109     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4110     ($self->{<Q::dis2pm:actualTypeNode>});
4111 wakaba 1.8 } else {
4112     my $pr = $self-><M::ManakaiDISPropertyAccessor
4113     .getPropertyResource>
4114     (<Q::DIS:dynamicParentResource>);
4115     if ($pr) {
4116 wakaba 1.18 $r = $pr-><AG::ManakaiDISResourceDefinition
4117 wakaba 1.8 .disActualDataTypeResource>;
4118     $self->{<Q::dis2pm:actualTypeNode>}
4119     = $pr->{<Q::dis2pm:actualTypeNode>};
4120 wakaba 1.18 $self->{<Q::dis:actualType>}
4121     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4122 wakaba 1.8 } else { ## No parent
4123     __UNDEEP{
4124     __EXCEPTION{NO_DIS_TYPE_ERR::
4125     DIS:sourceNode => {$self->{src}},
4126     }__;
4127     }__;
4128     }
4129     }
4130     }
4131     }
4132     }__;
4133    
4134     @Attr:
4135     @@Name: disActualDataTypeNode
4136     @@enDesc:
4137     <Q::dis:actualType> node for this resource.
4138     @@Get:
4139     @@@Type: ManakaiDISElement
4140     @@@RaiseException:
4141     @@@@@:NO_DIS_TYPE_ERR
4142     @@@@enDesc:
4143     <Q::dis:actualType> attribute is not specified,
4144     and <Q::dis:Type> attribute, neigher.
4145     @@@PerlDef:
4146     __DEEP{
4147 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeResource>;
4148 wakaba 1.8 }__;
4149     $r = $self->{<Q::dis2pm:actualTypeNode>};
4150 wakaba 1.9
4151     @IntMethod:
4152     @@Operator:
4153     @@@@: <=>
4154     @@@ContentType:
4155     lang:Perl
4156     @@enDesc:
4157     Which is greater (i.e. the spaceship operator).
4158     A resource is less than another if it is loaded by
4159     <M::ManakaiDISDatabase.loadResource> before another is loaded.
4160     Order for non-loaded resource definitions are not defined.
4161     \
4162     {NOTE:: In the current implementation, non-loaded resources
4163     are less than any loaded resource and the order in
4164     non-loaded resources is unknown.
4165     \
4166     }
4167     @@Param:
4168     @@@Name: anotherResource
4169     @@@Type: ManakaiDISResourceDefinition
4170     @@@enDesc: Another resource to compare.
4171     @@Return:
4172     @@@Type:
4173 wakaba 1.18 DOMMain:unsigned-long::ManakaiDOM:all
4174 wakaba 1.9 @@@PerlDef:
4175     if (UNIVERSAL::isa ($anotherResource,
4176     <ClassName::ManakaiDISResourceDefinition>)) {
4177     $r = $self->{seq} <=> $anotherResource->{seq};
4178     } else {
4179     $r = overload::Overloaded ($self) <=> $anotherResource;
4180     }
4181 wakaba 1.12
4182     @Attr:
4183     @@Name: plCodeFragment
4184     @@enDesc:
4185     Perl code definition fragment of this resource.
4186     @@Type: MPLCodeFragment
4187     @@Get:
4188     @@@enDesc:
4189     Perl code.
4190     @@@nullCase:
4191     @@@@enDesc:
4192     This node does not have Perl code definition.
4193     @@@RaiseException:
4194     @@@@@:NO_METHOD_RETURN_ERR
4195     @@@@enDesc:
4196     This resource is a <Q::DISLang:Method> but it does not
4197     have <Q::DISLang:MethodReturn> child-resource.
4198     @@@RaiseException:
4199     @@@@@:NO_ATTR_GET_ERR
4200     @@@@enDesc:
4201     This resource is a <Q::DISLang:Attribute> but it does not
4202     have <Q::DISLang:AttributeGet> child-resource.
4203     @@@RaiseException:
4204     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4205     @@@@enDesc:
4206     The media type of <Q::dis:Def> element is not supported.
4207 wakaba 1.18 @@@RaiseException:
4208     @@@@@: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
4209     @@@@enDesc:
4210     A non-named method paarameter is defined after
4211     a named method parameter appeared.
4212 wakaba 1.12 @@@PerlDef:
4213     __DEEP{
4214     if (exists $self->{<Q::plCodeFragment>}) {
4215     $r = $self->{<Q::plCodeFragment>};
4216     } elsif (not $self->{src}) {
4217     $r = $self->{<Q::plCodeFragment>} = null;
4218     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4219     (<Q::DISLang:MethodReturn>) or
4220     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4221     (<Q::DISLang:AttributeGet>) or
4222     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4223 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
4224     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4225     (<Q::dis2pm:BlockCode>) or
4226     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4227 wakaba 1.18 (<Q::dis2pm:InlineCode>) or
4228     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4229     (<Q::DISLang:InputProcessor>)) {
4230 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4231 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4232     (<Q::dis:Def>, for_arg => $self->{for},
4233     forp_arg => $self->{forp});
4234     if ($def-><M::ManakaiDISElement.mediaTypeMatch> (<Q::lang:Perl>)) {
4235 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
4236     ::swcfg21:ForLatest.value>;
4237 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4238 wakaba 1.14 = $self-><M::ManakaiDISResourceDefinition
4239 wakaba 1.17 .plPreprocessPerlCode> ($source_code,
4240     node => $def);
4241 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4242     (<Q::lang:dis>)) {
4243     $r = $self->{<Q::plCodeFragment>}
4244 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
4245 wakaba 1.12 -><M::MPLImpl.createPerlUnparsedCode>
4246 wakaba 1.14 ($def-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
4247 wakaba 1.12 ## TODO: implement
4248     } else {
4249     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
4250     (for_arg => $self->{for},
4251     forp_arg => $self->{forp});
4252     __UNDEEP{
4253     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4254     DIS:uri => {$mt},
4255     DIS:sourceNode => {$def},
4256     }__;
4257     }__;
4258     } # media type
4259     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4260     (<Q::DISLang:Method>)) {
4261 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4262 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
4263     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
4264     unless ($ret) {
4265     __UNDEEP{
4266     __EXCEPTION{NO_METHOD_RETURN_ERR::
4267     DIS:errResource => {$self},
4268     DIS:sourceNode => {$self->{src}},
4269     }__;
4270     }__;
4271     }
4272 wakaba 1.18 my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4273     .plImplementation>;
4274 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4275 wakaba 1.18 = $plimpl-><M::MPLImpl.createPerlSub>
4276 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
4277    
4278 wakaba 1.18 ## Method parameters
4279     my $params = $self-><M::ManakaiDISPropertyAccessor
4280     .getPropertyResourceList>
4281     (<Q::DIS:childResource>);
4282     my @param_variables;
4283     my @named_param_variables;
4284     my $prototype = '$';
4285     my $is_optional_param = false;
4286     my $is_named_param = false;
4287     for my $param (@$params) {
4288     next unless $param-><M::ManakaiDISResourceDefinition.isTypeURI>
4289     (<Q::DISLang:MethodParameter>);
4290     unless ($is_named_param) {
4291     if ($param-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4292     (<Q::DISPerl:isNamedParameter>, false)) {
4293     $is_named_param = true;
4294     $is_optional_param = true;
4295     push @param_variables, ['%opt'];
4296     $prototype .= '%';
4297     } else { ## Non-named parameter
4298     push @param_variables, [
4299     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
4300     ];
4301     if ($param-><AG::ManakaiDISResourceDefinition.plIsNullable>) {
4302     $prototype .= ';' unless $is_optional_param;
4303     $is_optional_param = true;
4304     }
4305     $prototype .= $param-><AG::ManakaiDISResourceDefinition
4306     .plPrototype>;
4307     my $param_processor
4308     = $param-><M::ManakaiDISResourceDefinition
4309     .plGetMethodInputNormalizer>;
4310     if ($param_processor) {
4311     $param_variables[-1]->[1]
4312     = $param_processor-><AG::ManakaiDISResourceDefinition
4313     .plCodeFragment>->clone;
4314     $param_variables[-1]->[1]
4315     -><M::MPLCodeFragment.replaceVariable>
4316     ('$INPUT' => $param_variables[-1]->[0]);
4317     }
4318     }
4319     } else { ## Named parameter
4320     unless ($param-><M::ManakaiDISPropertyAccessor
4321     .getPropertyBoolean>
4322     (<Q::DISPerl:isNamedParameter>, false)) {
4323     __UNDEEP{__EXCEPTION{NON_NAMED_PARAMETER_AFTER_NAMED_ERR::
4324     DIS:sourceNode => {$param->{src}},
4325     DIS:uri => {$param->{uri}},
4326     DIS:localName => {$param->{localName}},
4327     }__}__;
4328     }
4329     }
4330     if ($is_named_param) {
4331     push @named_param_variables, [
4332     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
4333     null,
4334     '$' . $param-><AG::ManakaiDISResourceDefinition.localName>,
4335     ];
4336     my $param_processor
4337     = $param-><M::ManakaiDISResourceDefinition
4338     .plGetMethodInputNormalizer>;
4339     if ($param_processor) {
4340     $named_param_variables[-1]->[1]
4341     = $param_processor-><AG::ManakaiDISResourceDefinition
4342     .plCodeFragment>->clone;
4343     $named_param_variables[-1]->[1]
4344     -><M::MPLCodeFragment.replaceVariable>
4345     ('$INPUT' => $param_variables[-1]->[0]);
4346     }
4347     }
4348     } # %$params
4349    
4350     $r-><AS::MPLSub.prototype> ($prototype);
4351 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
4352 wakaba 1.18 ($plimpl-><M::MPLImpl.createPerlStatement>
4353     ('my (' . join (', ', '$self',
4354     map {$_->[0]} @param_variables) . ') = @_'));
4355     for my $p (@param_variables, @named_param_variables) {
4356     if ($p->[1]) { ## Input processor
4357     $r-><M::MPLSS.appendCodeFragment> ($p->[1]);
4358     }
4359     }
4360    
4361     ## TODO: in/out
4362    
4363     ## Return value
4364     my $data_type;
4365     try {
4366     $data_type = $ret-><AG::ManakaiDISResourceDefinition
4367     .disActualDataTypeResource>;
4368     } catch <Class::ManakaiDISException> with {
4369     my $err = shift;
4370     if ($err->{<Q::MDOMX:subtype>} ne <Q::NO_DIS_TYPE_ERR>) {
4371     $err->throw;
4372     }
4373     };
4374    
4375     if ($data_type) {
4376     my $def = $ret->{src}-><M::ManakaiDISElement
4377     .plValueCodeFragment>
4378     (<Q::dis:DefaultValue>, $self->{db},
4379     for_arg => $self->{for},
4380     forp_arg => $self->{forp},
4381     use_default_value => true,
4382     data_type_uri => $data_type
4383     -><AG::ManakaiDISResourceDefinition.uri>);
4384     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
4385     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
4386     ('$', null, 'r');
4387     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
4388     .variableScope> ('my');
4389     if ($def) {
4390     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
4391     } else {
4392     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
4393     }
4394     $r-><M::MPLSS.appendCodeFragment> ($rs);
4395     }
4396    
4397     ## TODO: If no code
4398     my $code = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
4399     for my $np (@named_param_variables) {
4400     $code-><M::MPLCodeFragment.replaceVariable>
4401     ($np->[2] => $np->[0]);
4402     }
4403     $r-><M::MPLSS.appendCodeFragment> ($code);
4404 wakaba 1.12
4405 wakaba 1.18 if ($data_type) {
4406     $r-><M::MPLSS.appendCodeFragment>
4407     ($plimpl-><M::MPLImpl.createPerlVariable>
4408     ('$', null, 'r'));
4409     }
4410 wakaba 1.12 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4411     (<Q::DISLang:Attribute>)) {
4412 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4413 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
4414     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
4415     unless ($get) {
4416     __UNDEEP{
4417     __EXCEPTION{NO_ATTR_GET_ERR::
4418     DIS:errResource => {$self},
4419     DIS:sourceNode => {$self->{src}},
4420     }__;
4421     }__;
4422     }
4423     $r = $self->{<Q::plCodeFragment>}
4424 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
4425 wakaba 1.12 -><M::MPLImpl.createPerlSub>
4426     ($self-><AG::ManakaiDISResourceDefinition.plName>);
4427    
4428    
4429     ## TODO: Parameter, sub, set, ...
4430 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
4431 wakaba 1.12 ($get-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
4432    
4433 wakaba 1.13 } else { ## Not supported
4434 wakaba 1.12 $r = $self->{<Q::plCodeFragment>} = null;
4435     } # rdf:type
4436     }__;
4437    
4438     @Attr:
4439     @@Name:plImplementation
4440     @@enDesc:
4441     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
4442     @@Type: MPLImpl
4443     @@Get:
4444     @@@enDesc:
4445     The Perl code implementation object.
4446     @@@nullCase:
4447     This resource has no source tree associated.
4448     @@@RaiseException:
4449     @@@@@:NO_PERL_CODE_IMPL_ERR
4450     @@@@enDesc:
4451     There is no implementation that implements
4452     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
4453     @@@PerlDef:
4454     if ($self->{src}) {
4455     __DEEP{
4456     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
4457     $self->{src})-><AG::SWCFGDoc.implementation>
4458     -><M::DOMMinImpl.getFeature>
4459     (<Q::Util:PerlCode> => '1.0');
4460     }__;
4461     unless (defined $r) {
4462     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
4463    
4464     }__;
4465     }
4466     }
4467    
4468     @Method:
4469     @@Name: getChildResourceByType
4470     @@enDesc:
4471     Gets a static child resource selected by its type.
4472     @@Param:
4473     @@@Name:typeURI
4474     @@@Type:ResourceURI
4475     @@@enDesc:
4476     A URI reference identifying a resource type.
4477     @@Return:
4478     @@@Type: ManakaiDISResourceDefinition
4479     @@@enDesc:
4480     The first (by document order) child resource whose
4481     type matches with <P::resType>.
4482     @@@nullCase:
4483     @@@@enDesc:
4484     There is no resource whose type is <P::resType>.
4485     @@@PerlDef:
4486     __DEEP{
4487     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4488     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4489     ($cr_uri);
4490     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4491     $r = $cr;
4492     last;
4493     }
4494     }
4495     }__;
4496 wakaba 1.13
4497     @Method:
4498     @@Name: getChildResourceByNameAndType
4499     @@enDesc:
4500     Gets a static child resource selected by its local name and type.
4501     @@Param:
4502     @@@Name: localName
4503     @@@Type:
4504     DISCore:LocalName::ManakaiDOM:all
4505     @@@enDesc:
4506     A local name.
4507     @@Param:
4508     @@@Name:typeURI
4509     @@@Type:ResourceURI
4510     @@@enDesc:
4511     A URI reference identifying a resource type.
4512     @@Return:
4513     @@@Type: ManakaiDISResourceDefinition
4514     @@@enDesc:
4515     The first (by document order) child resource whose
4516     type matches for <P::localName> and <P::resType>.
4517     @@@nullCase:
4518     @@@@enDesc:
4519     There is no resource whose name is <P::localName> and
4520     whose type is <P::resType>.
4521     @@@PerlDef:
4522     __DEEP{
4523     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4524     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4525     ($cr_uri);
4526 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4527 wakaba 1.13 if (defined $ln and $ln eq $localName and
4528     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4529     $r = $cr;
4530     last;
4531     }
4532     }
4533     }__;
4534    
4535     @Method:
4536     @@Name: getConstResourceByName
4537     @@enDesc:
4538     Gets a constant value resource by its local name.
4539     @@Param:
4540     @@@Name:localName
4541     @@@Type:
4542     DISLang:String::ManakaiDOM:all
4543     @@@enDesc:
4544     Constant name.
4545     @@Return:
4546     @@@Type: ManakaiDISResourceDefinition
4547     @@@enDesc:
4548     The constant resource identified by <P::localName>.
4549     @@@nullCase:
4550     @@@@enDesc:
4551     There is no such constant resource.
4552     @@@PerlDef:
4553     __DEEP{
4554     my @constGroup;
4555     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4556     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4557     ($cr_uri);
4558 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4559 wakaba 1.13 if ($ln and $ln eq $localName and
4560     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4561     (<Q::ManakaiDOM:Const>)) {
4562     $r = $cr;
4563     last;
4564     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4565     (<Q::ManakaiDOM:ConstGroup>)) {
4566     push @constGroup, $cr;
4567     }
4568     }
4569     unless ($r) {
4570     for my $cg (@constGroup) {
4571     $r = $cg-><M::ManakaiDISResourceDefinition
4572     .getChildResourceByNameAndType>
4573     ($localName, <Q::ManakaiDOM:Const>);
4574     last if $r;
4575     }
4576     }
4577     }__;
4578    
4579     @Method:
4580     @@Name: plPreprocessPerlCode
4581     @@enDesc:
4582     Preprocesses a Perl block-level code fragment.
4583     @@Param:
4584     @@@Name:codeArg
4585     @@@Type:
4586     lang:Perl::ManakaiDOM:all
4587     @@@enDesc:
4588     A Perl block-level code (statements and/or blocks).
4589 wakaba 1.15 @@NodeParam:
4590     @@NamedParam:
4591     @@@Name:methodResource
4592     @@@Type:ManakaiDISResourceDefinition
4593     @@@enDesc:
4594     The resource definition of the Perl method to which
4595     the <P::codeArg> belongs.
4596     @@@nullCase:
4597     @@@@enDesc:
4598     The <P::codeArg> does not belong to any method.
4599 wakaba 1.17 @@NamedParam:
4600     @@@Name:sourceFile
4601     @@@Type:
4602     DISLang:String::ManakaiDOM:all
4603     @@@enDesc:
4604     The source file name of the <P::codeArg>.
4605     @@@nullCase:
4606     @@@@enDesc:
4607     No source file information available.
4608     @@NamedParam:
4609     @@@Name:sourceLine
4610     @@@Type:
4611     DOMMain:unsigned-long::ManakaiDOM:all
4612     @@@enDesc:
4613     The line number in the <P::sourceFile> from which
4614     the <P::codeArg> begins.
4615     @@@nullCase:
4616     @@@@enDesc:
4617     No source file information available.
4618 wakaba 1.13 @@Return:
4619     @@@Type:
4620     lang:Perl::ManakaiDOM:all
4621     @@@enDesc:
4622     Preprocessed Perl code.
4623 wakaba 1.15 @@@BlockElementException:
4624     @@@InlineElementException:
4625 wakaba 1.13 @@@PerlDef:
4626 wakaba 1.15 unless ($self->{src}) {
4627     __EXCEPTION{NO_SOURCE_NODE_ERR::
4628     DIS:uri => {$self->{uri}},
4629     }__;
4630     }
4631     __DEEP{
4632     our $RegQNameChar;
4633     our $RegBlockContent;
4634     use re 'eval';
4635     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4636     .plImplementation>;
4637     $r = $plimpl-><M::MPLImpl.createPerlBlock>;
4638 wakaba 1.17 if (defined $sourceLine) {
4639     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
4640     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
4641     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
4642     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
4643     } elsif ($node) {
4644     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
4645     (key => [qw/Name QName Type type/]);
4646     $r-><AS::PLBlockCon.currentSourceFile> ($np);
4647     $r-><AS::PLBlockCon.currentSourceLine> (1);
4648     $r-><AS::PLBlockCon.sourceFile> ($np);
4649     $r-><AS::PLBlockCon.sourceLine> (1);
4650     }
4651 wakaba 1.15
4652 wakaba 1.16 for my $source_code (split /\b(_ _(?:(?!_ _)$RegQNameChar)+
4653 wakaba 1.15 (?:\{$RegBlockContent\})?
4654 wakaba 1.16 _ _)\b/x, $codeArg) {
4655 wakaba 1.15 ## Block-level element
4656 wakaba 1.16 if ($source_code =~ /_\_\z/ and
4657     $source_code =~ s/^_\_((?:(?!_\_)$RegQNameChar)+)//) {
4658 wakaba 1.15 my $et = $self->{src}
4659     -><M::ManakaiDISElement.qnameToURI>
4660     ($1,
4661     node => $node,
4662     default_namespace_uri => <Q::disPerl:>);
4663     if ($source_code =~ s/^\{//) {
4664     $source_code =~ s/\}__\z//;
4665     } else {
4666     $source_code = '';
4667     }
4668    
4669     # ## ISSUE: __FILE__ & __LINE__ will break if multiline substition happens.
4670    
4671     if ($et eq <Q::disPerl:DEEP> or $et eq <Q::disPerl:UNDEEP>) {
4672     my $block = $r-><M::PLBlockCon.appendBlock>;
4673     $block-><M::PLBlockCon.appendStatement>
4674     ('local $Error::Depth = $Error::Depth '.
4675     ($et eq <Q::disPerl:DEEP> ? '+' : '-').
4676     ' 1');
4677     $block-><M::PLBlockCon.appendCodeFragment>
4678 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
4679     .plPreprocessPerlCode>
4680     ($source_code, node => $node,
4681     method_resource => $methodResource,
4682     source_file => $r-><AG::PLBlockCon
4683     .currentSourceFile>,
4684     source_line => $r-><AG::PLBlockCon
4685     .currentSourceLine>));
4686     $r-><M::PLBlockCon.skipLines> ($source_code);
4687 wakaba 1.15 } elsif ({
4688     <Q::disPerl:EXCEPTION> => 1,
4689     <Q::disPerl:WARNING> => 1,
4690     }->{$et}) {
4691 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
4692 wakaba 1.15 if ($source_code =~ s/^((?:(?!::).)+)(::\s*)?//s) {
4693     my ($cls, $const, $subtype)
4694     = @{$self->{db}-><M::ManakaiDISDatabase.xcrefToResource>
4695 wakaba 1.16 ($1, $self->{src},
4696     node => $node,
4697     for_arg => $self->{for})};
4698 wakaba 1.15 my $param = $self-><M::ManakaiDISResourceDefinition
4699     .plParsePreprocessParameter>
4700     ($source_code, node => $node);
4701     my $context_param
4702     = $self-><M::ManakaiDISResourceDefinition
4703     .plGetContextParameter>;
4704    
4705     $self-><M::ManakaiDISResourceDefinition
4706     .plAppendThrow>
4707     ($r, $cls, $const, $subtype,
4708     {%$param, %$context_param});
4709     } else {
4710     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR::
4711     DIS:sourceNode => {$node},
4712     DIS:sourceCode => {$source_code},
4713     DIS:elementType => {$et},
4714     }__}__;
4715     }
4716     } elsif ($et eq <Q::disPerl:CODE>) {
4717 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
4718 wakaba 1.15 my $code_name;
4719     $source_code =~ s/^\s+//;
4720     if ($source_code =~ s/^((?>(?!::).)+)//s) {
4721     $code_name = $1;
4722     } else {
4723     __UNDEEP{
4724     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
4725     DIS:sourceCode => {$source_code},
4726     DIS:sourceNode => {$node},
4727     DIS:elementType => {$et},
4728     }__;
4729     }__;
4730     }
4731     $source_code =~ s/^::\s*//;
4732     my $param = $self-><M::ManakaiDISResourceDefinition
4733     .plParsePreprocessParameter>
4734     ($source_code, node => $node);
4735     my $code_uri = $self->{src}-><M::ManakaiDISElement
4736     .tfqnamesToURI>
4737     ($code_name, null, $self->{for},
4738     node => $node);
4739     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
4740     ($code_uri);
4741     $code-><AS::ManakaiDISResourceDefinition.isReferred>
4742     ($node || $self->{src});
4743     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
4744     (<Q::dis2pm:BlockCode>)) {
4745     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4746     DIS:uri => {$code_uri},
4747     DIS:sourceNode => {$node},
4748     DIS:sourceCode => {$source_code},
4749     DIS:expectedType => {<Q::dis2pm:BlockCode>},
4750     }__;}__;
4751     }
4752     my $pc = $code-><AG::ManakaiDISResourceDefinition
4753     .plCodeFragment>->clone;
4754     unless (defined $pc) {
4755     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4756     DIS:sourceNode => {$node},
4757     DIS:sourceCode => {$source_code},
4758     DIS:uri => {$code_uri},
4759     }__}__;
4760     }
4761     for my $var (grep {/^\$/} keys %$param) {
4762     my $value;
4763     if ($param->{$var}->{type} eq 'variable') {
4764     $value = $plimpl-><M::MPLImpl.createPerlVariable>
4765     ('$', null, $param->{$var}->{value});
4766     } elsif ($param->{$var}->{type} eq 'code') {
4767     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4768     ($param->{$var}->{value});
4769     } else {
4770     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
4771     ($param->{$var}->{value});
4772     }
4773     $pc-><M::MPLCodeFragment.replaceVariable>
4774     ($var => $value);
4775     }
4776 wakaba 1.16 $r-><M::PLBlockCon.appendCodeFragment> ($pc);
4777 wakaba 1.15 } elsif ($et eq <Q::ManakaiDOM:InputNormalize>) {
4778 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
4779 wakaba 1.15 unless ($methodResource) {
4780     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_METHOD_ERR::
4781     DIS:sourceNode => {$node},
4782     DIS:sourceCode => {$source_code},
4783     DIS:elementType => {$et},
4784     }__}__;
4785     }
4786     my $param = $methodResource
4787     -><M::ManakaiDISResourceDefinition
4788     .getChildResourceByNameAndType>
4789     ($source_code, <Q::DISLang:MethodParameter>);
4790     unless ($param) {
4791     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4792     DIS:sourceNode => {$node},
4793     DIS:sourceCode => {$source_code},
4794     DIS:elementType => {$et},
4795     DIS:localName => {$source_code},
4796     DIS:expectedType => {<Q::DISLang:MethodParameter>},
4797     }__}__;
4798     }
4799     my $norm = $param-><M::ManakaiDISResourceDefinition
4800     .plGetMethodInputNormalizer>;
4801     if ($norm) {
4802     my $norm_code = $norm-><AG::ManakaiDISResourceDefinition
4803     .plCodeFragment>->clone;
4804     $norm_code-><M::MPLCodeFragment.replaceVariable>
4805     ('$INPUT' => $param-><AG::ManakaiDISResourceDefinition
4806     .plVariableName>);
4807     $r-><M::PLBlockCon.appendCodeFragment> ($norm_code);
4808     }
4809     } elsif ($et eq <Q::disPerl:FOR>) {
4810 wakaba 1.17 if ($source_code =~ s/^(((?>(?!::).)*)::\s*)//) {
4811     $r-><M::PLBlockCon.skipLines> ($1);
4812     V: for (split /\s*\|\s*/, $2) {
4813 wakaba 1.15 my $for_uri = $self->{src}
4814     -><M::ManakaiDISElement.qnameToURI>
4815     ($_, node => $node);
4816     if ($self-><M::ManakaiDISResourceDefinition
4817     .isForURI> ($for_uri)) {
4818     $r-><M::PLBlockCon.appendCodeFragment>
4819 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
4820     .plPreprocessPerlCode>
4821     ($source_code, node => $node,
4822     method_resource => $methodResource,
4823     source_file => $r-><AG::PLBlockCon.
4824     currentSourceFile>,
4825     source_line => $r-><AG::PLBlockCon.
4826     currentSourceLine>));
4827 wakaba 1.15 last V;
4828     }
4829     } # V
4830 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
4831 wakaba 1.15 } else {
4832     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_FOR_ERR::
4833     DIS:sourceNode => {$node},
4834     DIS:sourceCode => {$source_code},
4835     DIS:elementType => {$et},
4836     }__}__;
4837     }
4838     } elsif ($et eq <Q::disPerl:ASSERT>) {
4839 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
4840 wakaba 1.15 my $assert_type;
4841     if ($source_code =~ s/^\s*($RegQNameChar+)\s*::\s*//o) {
4842     $assert_type = $self->{src}
4843     -><M::ManakaiDISElement.qnameToURI>
4844     ($1, node => $node);
4845     } else {
4846     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ASSERT_TYPE_ERR::
4847     DIS:sourceNode => {$node},
4848     DIS:sourceCode => {$source_code},
4849     DIS:elementType => {$et},
4850     }__}__;
4851     }
4852     # if output assertion then
4853     =pod
4854     my $assert_block = $r-><M::PLBlockCon.appendBlock>;
4855    
4856     my $param = $self-><M::ManakaiDISResourceDefinition
4857     .plParsePreprocessParameter>
4858     ($source_code, node => $node);
4859     my $context_param
4860     = $self-><M::ManakaiDISResourceDefinition
4861     .plGetContextParameter>;
4862    
4863     if ($assert_type eq <Q::DISPerl:isPositive>) {
4864    
4865     $pre = perl_statement
4866     perl_assign
4867     'my $asActual' =>
4868     '('.perl_code ($param->{actual}, %opt).')';
4869     $cond = '$asActual > 0';
4870     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = 'a positive value';
4871     $xparam->{ExpandedURI q<DOMMain:actualValue>}
4872     = perl_code_literal q<$asActual>;
4873     } elsif ($atype eq ExpandedURI q<DISPerl:invariant>) {
4874     $cond = '0';
4875     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = $param->{msg};
4876     $xparam->{ExpandedURI q<DOMMain:actualValue>} = '(invariant)';
4877     } else {
4878     valid_err (q[Assertion type <].$atype.q[> is not supported],
4879     node => $opt{node});
4880     }
4881    
4882     $r = $pre . perl_if
4883     $cond,
4884     undef,
4885    
4886    
4887     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4888     (<Q::DOMException:CoreException>);
4889     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4890     (<Q::MDOMX:MDOM_DEBUG_BUG>);
4891     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4892     (<Q::DOMMain:ASSERTION_ERR>);
4893 wakaba 1.16 $_-><AS::ManakaiDISResourceDefinition.isReferred>
4894 wakaba 1.15 ($node || $self->{src}) for $cls, $const, $subtype;
4895     $self-><M::ManakaiDISResourceDefinition
4896     .plAppendThrow>
4897     ($assert_block, $cls, $const, $subtype,
4898     {%$param, %$context_param,
4899     <Q::DOMMain:assertionType> => {
4900     type => 'quoted', value => $assert_type,
4901     },
4902     <Q::DOMMain:traceText> => {
4903     type => 'code',
4904     value => q<(sprintf 'at %s line %s%s%s',
4905     __FILE__, __LINE__, "\n\t",
4906     Carp::longmess ())>,
4907     }});
4908    
4909     =cut
4910    
4911     } elsif ({
4912     <Q::disPerl:FILE> => 1,
4913     <Q::disPerl:LINE> => 1,
4914     <Q::disPerl:PACKAGE> => 1,
4915     }->{$et}) {
4916     $r-><M::PLAnyCon.appendAtom>
4917     ('__'.{
4918     <Q::disPerl:FILE> => 'FILE',
4919     <Q::disPerl:LINE> => 'LINE',
4920     <Q::disPerl:PACKAGE> => 'PACKAGE',
4921     }->{$et}.'__');
4922     if (length $source_code) {
4923     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR::
4924     DIS:sourceNode => {$node},
4925     DIS:sourceCode => {$source_code},
4926     DIS:elementType => {$et},
4927     }__}__;
4928     }
4929     } else {
4930     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4931     DIS:sourceNode => {$node},
4932     DIS:sourceCode => {$source_code},
4933     DIS:elementType => {$et},
4934     }__}__;
4935     }
4936     } else { ## Other than block-level element
4937     $r-><M::PLBlockCon.appendCodeFragment>
4938     ($self-><M::ManakaiDISResourceDefinition
4939 wakaba 1.16 .plPreprocessPerlStatement>
4940 wakaba 1.17 ($source_code, contains_statements => true,
4941     source_file => $r-><AG::PLBlockCon
4942     .currentSourceFile>,
4943     source_line => $r-><AG::PLBlockCon
4944     .currentSourceLine>));
4945     $r-><M::PLBlockCon.skipLines> ($source_code);
4946 wakaba 1.15 }
4947     } # for
4948     }__; # DEEP
4949    
4950    
4951     ## Checks \p character classes
4952     # while ($s =~ /\\p{([^{}]+)}/gs) {
4953     # my $name = $1;
4954     # $State->{ExpandedURI q<dis2pm:Package>}
4955     # ->{$State->{ExpandedURI q<dis2pm:currentPackage>}}
4956     # ->{ExpandedURI q<dis2pm:requiredCharClass>}
4957     # ->{$name} ||= $opt{node} || 1;
4958     # }
4959    
4960 wakaba 1.13
4961     @Method:
4962     @@Name: plPreprocessPerlStatement
4963     @@enDesc:
4964     Preprocesses a Perl inline code fragment
4965     (code fragment smaller than statement).
4966     @@Param:
4967     @@@Name:codeArg
4968     @@@Type:
4969     lang:Perl::ManakaiDOM:all
4970     @@@enDesc:
4971     A Perl code fragment.
4972     @@NodeParam:
4973 wakaba 1.16 @@NamedParam:
4974     @@@Name:containsStatements
4975     @@@Type:
4976     DOMMain:boolean::ManakaiDOM:all
4977     @@@enDesc:
4978     Whether one or more statements might be contained
4979     in <P::codeArg> or not.
4980 wakaba 1.17 @@NamedParam:
4981     @@@Name:sourceFile
4982     @@@Type:
4983     DISLang:String::ManakaiDOM:all
4984     @@@enDesc:
4985     The source file name of the <P::codeArg>.
4986     @@@nullCase:
4987     @@@@enDesc:
4988     No source file information available.
4989     @@NamedParam:
4990     @@@Name:sourceLine
4991     @@@Type:
4992     DOMMain:unsigned-long::ManakaiDOM:all
4993     @@@enDesc:
4994     The line number in the <P::sourceFile> from which
4995     the <P::codeArg> begins.
4996     @@@nullCase:
4997     @@@@enDesc:
4998     No source file information available.
4999 wakaba 1.13 @@Return:
5000 wakaba 1.16 @@@Type:MPLCodeFragment
5001 wakaba 1.13 @@@enDesc:
5002     Preprocessed Perl code.
5003 wakaba 1.16 @@@InCase:
5004     @@@@Type:
5005     PerlCode:ManakaiPerlBlock::ManakaiDOM:Perl
5006     @@@@enDesc:
5007     If <P::isInline> is <DOM::false>.
5008     @@@InCase:
5009     @@@@Type:
5010     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
5011     @@@@enDesc:
5012     If <P::isInline> is <DOM::true>.
5013 wakaba 1.13 @@@InlineElementException:
5014     @@@PerlDef:
5015     unless ($self->{src}) {
5016     __EXCEPTION{NO_SOURCE_NODE_ERR::
5017     DIS:uri => {$self->{uri}},
5018     }__;
5019     }
5020     __DEEP{
5021     our $RegQNameChar;
5022     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
5023     .plImplementation>;
5024 wakaba 1.16 if ($containsStatements) {
5025     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5026 wakaba 1.17 if (defined $sourceLine) {
5027     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
5028     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
5029     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
5030     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
5031     } elsif ($node) {
5032     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
5033     (key => [qw/Name QName Type type/]);
5034     $r-><AS::PLBlockCon.sourceFile> ($np);
5035     $r-><AS::PLBlockCon.sourceLine> (1);
5036     $r-><AS::PLBlockCon.currentSourceFile> ($np);
5037     $r-><AS::PLBlockCon.currentSourceLine> (1);
5038     }
5039 wakaba 1.16 } else {
5040     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
5041     }
5042     for my $source_code (split /(?<![\^\?qwr])(\x3C$RegQNameChar[^<>]+>
5043     )/ox, $codeArg) {
5044 wakaba 1.13 if ($source_code =~ s/^\x3C//) {
5045     $source_code =~ s/>$//;
5046     if ($source_code =~ /=$/) {
5047     ## TODO: Warning
5048     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
5049     # q{should "=" be used place of "=>"?};
5050     }
5051     if ($source_code =~ s/^(.+?):://) {
5052     my $et = $self->{src}
5053     -><M::ManakaiDISElement.qnameToURI>
5054     ($1,
5055     node => $node,
5056     default_namespace_uri => <Q::disPerl:>);
5057     if ($et eq <Q::disPerl:Q>) { ## QName constant
5058     $r-><M::PLAnyCon.appendStringLiteral>
5059     ($self->{src}
5060     -><M::ManakaiDISElement.qnameToURI>
5061     ($source_code, node => $node));
5062     } elsif ({
5063     <Q::disPerl:M> => 1,
5064     <Q::disPerl:ClassM> => 1,
5065     <Q::disPerl:AG> => 1,
5066     <Q::disPerl:AS> => 1,
5067     }->{$et}) { ## Method call
5068     my ($class_qname, $method_qname)
5069     = split /\s*\.\s*/, $source_code, 2;
5070     my $class_uri
5071     = $self->{src}
5072     -><M::ManakaiDISElement.tfqnamesToURI>
5073     ($class_qname,
5074     $self-><AG::ManakaiDISResourceDefinition
5075     .ownerClassURI>,
5076     $self->{for},
5077     node => $node);
5078     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5079     ($class_uri);
5080 wakaba 1.16 unless ($class-><AG::ManakaiDISResourceDefinition
5081     .isDefined>) {
5082     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5083     DIS:sourceNode => {$node},
5084     DIS:sourceCode => {$source_code},
5085     DIS:uri => {$class_uri},
5086     DIS:elementType => {$et},
5087     DIS:expectedType => {<Q::DISLang:AnyClass>},
5088     }__}__;
5089     }
5090 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5091 wakaba 1.13 ($node || $self->{src});
5092     if ($et eq <Q::disPerl::ClassM> and
5093     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
5094     (<Q::ManakaiDOM:IF>)) {
5095     __UNDEEP{
5096     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
5097     DIS:uri => {$class_uri},
5098     DIS:elementType => {$et},
5099     DIS:sourceNode => {$node || $self->{src}},
5100     DIS:sourceCode => {$source_code},
5101 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
5102 wakaba 1.13 }__;
5103     }__;
5104     }
5105     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
5106     (<Q::ManakaiDOM:IF>)) {
5107     $self-><AG::ManakaiDISResourceDefinition.definingModule>
5108     -><M::ManakaiDISModuleDefinition.plAddRequireModule>
5109     ($class-><AG::ManakaiDISResourceDefinition
5110     .definingModule>);
5111     }
5112 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
5113 wakaba 1.13 .getChildResourceByNameAndType>
5114     ($method_qname,
5115     {
5116     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
5117     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
5118     }->{$et} || <Q::DISLang:Method>);
5119     if (not $method or
5120     not $method-><AG::ManakaiDISResourceDefinition
5121     .isDefined>) {
5122     __UNDEEP{
5123     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5124     DIS:localName => {$method_qname},
5125     DIS:elementType => {$et},
5126     DIS:sourceNode => {$node || $self->{src}},
5127     DIS:sourceCode => {$source_code},
5128 wakaba 1.14 DIS:expectedType => {{
5129     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
5130     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
5131     }->{$et} || <Q::DISLang:Method>},
5132 wakaba 1.13 }__;
5133     }__;
5134     }
5135     my $class_name = '';
5136     if ($et eq <Q::disPerl:ClassM>) {
5137     $class_name = $class-><AG::ManakaiDISResourceDefinition
5138     .plFullyQualifiedName> . '->';
5139     }
5140     my $method_name = $method-><AG::ManakaiDISResourceDefinition
5141     .plName>;
5142     $r-><M::PLAnyCon.appendBare>
5143     ($class_name . $method_name);
5144     } elsif ({
5145     <Q::disPerl:Class> => 1,
5146     <Q::disPerl:ClassName> => 1,
5147     <Q::disPerl:IF> => 1,
5148     <Q::disPerl:IFName> => 1,
5149     }->{$et}) { ## Perl package name
5150     my $class_uri
5151     = $self->{src}
5152     -><M::ManakaiDISElement.tfqnamesToURI>
5153     ($source_code,
5154     $self-><AG::ManakaiDISResourceDefinition
5155     .ownerClassURI>,
5156     $self->{for},
5157     node => $node);
5158     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5159     ($class_uri);
5160 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5161 wakaba 1.13 ($node || $self->{src});
5162 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
5163 wakaba 1.13 .plFullyQualifiedName>;
5164 wakaba 1.14 unless ($pack) {
5165     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
5166     DIS:sourceNode => {$node || $self->{src}},
5167     DIS:sourceCode => {$source_code},
5168     DIS:uri => {$class_uri},
5169     DIS:elementType => {$et},
5170     }__}__;
5171     }
5172 wakaba 1.13 if ({
5173     <Q::disPerl:ClassName> => 1,
5174     <Q::disPerl:IFName> => 1,
5175     }->{$et}) {
5176     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
5177     } else {
5178     $r-><M::PLAnyCon.appendBare> ($pack);
5179     }
5180     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
5181     my $code_name;
5182     $source_code =~ s/^\s+//;
5183     if ($source_code =~ s/^((?>(?!::).)+)//s) {
5184     $code_name = $1;
5185     } else {
5186     __UNDEEP{
5187     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
5188     DIS:sourceCode => {$source_code},
5189     DIS:sourceNode => {$node || $self->{src}},
5190     }__;
5191     }__;
5192     }
5193     $source_code =~ s/^::\s*//;
5194     my $param = $self-><M::ManakaiDISResourceDefinition
5195     .plParsePreprocessParameter>
5196     ($source_code, node => $node);
5197     my $code_uri = $self->{src}-><M::ManakaiDISElement
5198     .tfqnamesToURI>
5199     ($code_name, null, $self->{for},
5200     node => $node);
5201     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
5202     ($code_uri);
5203 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
5204 wakaba 1.13 ($node || $self->{src});
5205     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
5206     (<Q::dis2pm:InlineCode>)) {
5207     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5208     DIS:uri => {$code_uri},
5209     DIS:sourceNode => {$node || $self->{src}},
5210     DIS:sourceCode => {$source_code},
5211     DIS:expectedType => {<Q::dis2pm:InlineCode>},
5212     }__;}__;
5213     }
5214     my $pc = $code-><AG::ManakaiDISResourceDefinition
5215     .plCodeFragment>->clone;
5216     unless (defined $pc) {
5217     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
5218     DIS:sourceNode => {$node || $self->{src}},
5219     DIS:sourceCode => {$source_code},
5220     DIS:uri => {$code_uri},
5221     }__}__;
5222     }
5223     for my $var (grep {/^\$/} keys %$param) {
5224     my $value;
5225     if ($param->{$var}->{type} eq 'variable') {
5226     $value = $plimpl-><M::MPLImpl.createPerlVariable>
5227     ('$', null, $param->{$var}->{value});
5228     } elsif ($param->{$var}->{type} eq 'code') {
5229     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
5230     ($param->{$var}->{value});
5231     } else {
5232     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
5233     ($param->{$var}->{value});
5234     }
5235     $pc-><M::MPLCodeFragment.replaceVariable>
5236     ($var => $value);
5237     }
5238 wakaba 1.16 $r-><M::PLInCon.appendCodeFragment> ($pc);
5239 wakaba 1.13 } elsif ($et eq <Q::disPerl:C>) {
5240     my ($class_qname, $const_name) = split /\./, $source_code, 2;
5241     my $class_uri
5242     = $self->{src}
5243     -><M::ManakaiDISElement.tfqnamesToURI>
5244     ($class_qname,
5245     $self-><AG::ManakaiDISResourceDefinition
5246     .ownerClassURI>,
5247     $self->{for},
5248     node => $node);
5249     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5250     ($class_uri);
5251 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5252 wakaba 1.13 ($node || $self->{src});
5253     my $const = $class-><M::ManakaiDISResourceDefinition
5254     .getConstResourceByName> ($const_name);
5255     unless (defined $const) {
5256     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5257     DIS:sourceNode => {$node || $self->{src}},
5258     DIS:sourceCode => {$source_code},
5259     DIS:localName => {$const_name},
5260 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
5261 wakaba 1.13 }__}__;
5262     }
5263 wakaba 1.14 my $pc = $const-><AG::ManakaiDISResourceDefinition
5264 wakaba 1.13 .plCodeFragment>->clone;
5265     unless (defined $pc) {
5266     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
5267     DIS:sourceNode => {$node || $self->{src}},
5268     DIS:sourceCode => {$source_code},
5269     DIS:localName => {$const_name},
5270     }__}__;
5271     }
5272     $r-><M::PLInCon.appendCodeFragment> ($pc);
5273     } else {
5274     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
5275     DIS:elementType => {$et},
5276     DIS:sourceNode => {$node || $self->{src}},
5277 wakaba 1.16 DIS:sourceCode => {$source_code},
5278 wakaba 1.13 }__}__;
5279     }
5280     } else {
5281     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
5282     DIS:sourceNode => {$node || $self->{src}},
5283     DIS:sourceCode => {$source_code},
5284 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
5285 wakaba 1.13 }__}__;
5286     }
5287     } else {
5288 wakaba 1.18 for my $source_code (split /\b( t r u e \b|
5289     f a l s e \b|
5290     n u l l \b|
5291     t r y \s* \{)/x, $source_code) {
5292 wakaba 1.16 if ({
5293     'tr'.'ue' => true,
5294     'fal'.'se' => true,
5295     'nu'.'ll' => true,
5296     }->{$source_code}) {
5297     $r-><M::PLAnyCon.appendAtom> ({
5298     'tr'.'ue' => 1,
5299     'fal'.'se' => 0,
5300     'nu'.'ll' => 'undef',
5301     }->{$source_code});
5302 wakaba 1.18 } elsif ($source_code =~ /^t r y \s* \x7B$/x) {
5303     $r-><M::PLInCon.appendCode> ('tr'.
5304     'y '."\x7B".'local $Error::Depth = $Error::Depth + 3;');
5305 wakaba 1.16 } else {
5306     $r-><M::PLInCon.appendCode> ($source_code);
5307     }
5308     }
5309     } # Inline instruction or not
5310 wakaba 1.13 } # for
5311     }__; # DEEP
5312    
5313     @Attr:
5314     @@Name: ownerClassURI
5315     @@enDesc:
5316     The URI reference of the class resource this resource
5317     belongs to.
5318     @@Type: ResourceURI
5319     @@Get:
5320     @@@enDesc:
5321     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
5322     If this resource is a class, then the URI reference
5323     of this resource is returned.
5324     @@@nullCase:
5325     @@@@enDesc:
5326     This resource does not belong to any class.
5327     @@@PerlDef:
5328     if (exists $self->{<Q::DIS:ownerClass>}) {
5329     $r = $self->{<Q::DIS:ownerClass>};
5330     } else {
5331     my $res = $self;
5332     __DEEP{
5333     {
5334     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
5335     (<Q::ManakaiDOM:Class>)) {
5336     $r = $res->{uri};
5337     } else {
5338     $res = $res-><M::ManakaiDISPropertyAccessor
5339     .getPropertyResource> (<Q::dis2pm:parentResource>);
5340     redo if $res;
5341     }
5342     }
5343     }__;
5344     $self->{<Q::DIS:ownerClass>} = $r;
5345     }
5346    
5347     @IntMethod:
5348     @@Name: plParsePreprocessParameter
5349     @@enDesc:
5350     Parses a parameter specification in preprocessing instruction
5351     and return it as a hash reference.
5352     \
5353     {NOTE:: The callee have to ensure that this resource has its
5354     <CODE::src> before the call to this method.
5355     \
5356     }
5357     @@Param:
5358     @@@Name: paramSpec
5359     @@@Type:
5360     DISLang:String::ManakaiDOM:all
5361     @@@enDesc:
5362     A parameter specification to parse.
5363     @@NodeParam:
5364     @@Return:
5365     @@@Type:
5366     Perl:hash::ManakaiDOM:all
5367     @@@enDesc:
5368     Hash containing parameters. Each hash value is also
5369     a hash reference, containing two keys <CODE::type>
5370     (its value is either <CODE::bare>, <CODE::quoted>,
5371     <CODE::code> or <CODE::variable>) and
5372     <CODE::value>.
5373     @@@RaiseException:
5374     @@@@@:BROKEN_PARAM_SPEC_ERR
5375     @@@@enDesc:
5376     The <P::paramSpec> is not well-formed.
5377     @@@PerlDef:
5378     BEGIN{
5379     our $RegQNameChar = qr/[^\s<>"'\\\[\]\{\},=\$\@%]/;
5380     use re 'eval';
5381     our $RegBlockContent;
5382     $RegBlockContent = qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{
5383     $RegBlockContent})\})*)/s;
5384     }
5385    
5386     our $RegQNameChar;
5387     our $RegBlockContent;
5388     $r = {};
5389     while ($paramSpec =~ s/^
5390     ## Parameter name
5391     (\$? $RegQNameChar+)\s*
5392    
5393     (?: =>? \s*
5394     ## ">" is now optional for inline element (">" is delimiter)
5395    
5396     ## Parameter value
5397     (
5398 wakaba 1.15 ## Variable or Bare string
5399     \ \$? $RegQNameChar+
5400 wakaba 1.13 |
5401     ## Quoted string
5402     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
5403     |
5404     ## Code
5405 wakaba 1.15 \ \{$RegBlockContent\}
5406 wakaba 1.13
5407     )
5408    
5409     \s*)?
5410    
5411     (?:,\s*|$)//ox) {
5412    
5413     my ($n, $v) = ($1, $2);
5414     if (defined $v) {
5415     if ($v =~ /^'/) {
5416     $v = {type => 'quoted',
5417     value => substr ($v, 1, length ($v) - 2)};
5418     } elsif ($v =~ /^\{/) {
5419     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
5420     } elsif ($v =~ /^\$/) {
5421 wakaba 1.16 $v = {type => 'variable', value => $v};
5422 wakaba 1.13 } else {
5423     $v = {type => 'bare', value => $v};
5424     }
5425     } else {
5426     $v = {type => 'boolean', value => true};
5427     }
5428    
5429     if ($n =~ /^\$/) {
5430     $r->{$n} = $v;
5431     } else {
5432     __DEEP{
5433     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
5434     ($n, node => $node || $self->{src})} = $v;
5435     }__;
5436     }
5437     } # while
5438    
5439     if (length $paramSpec) {
5440     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
5441     DIS:sourceCode => {$paramSpec},
5442     DIS:sourceNode => {$node || $self->{src}},
5443     }__;
5444     }
5445    
5446 wakaba 1.15 @IntMethod:
5447     @@Name: plGetContextParameter
5448     @@enDesc:
5449     Returns contextual parameters which describes the <QUOTE::location>
5450     of this resource.
5451     @@Return:
5452     @@@Type:
5453     Perl:hash::ManakaiDOM:all
5454     @@@enDesc:
5455     Hash of parameters as <M::.plParsePreprocessParameter> returns.
5456     @@@PerlDef:
5457     $r = {};
5458     __DEEP{
5459     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5460     (<Q::DISLang:MethodReturn>)) {
5461     my $method = $self-><M::ManakaiDISPropertyAccessor
5462     .getPropertyResource> (<Q::dis2pm:parentResource>);
5463     $r->{<Q::MDOMX:method>}
5464     = {type => 'quoted',
5465     value => $method-><AG::ManakaiDISResourceDefinition.plName>};
5466     my $class = $method-><M::ManakaiDISPropertyAccessor
5467     .getPropertyResource> (<Q::dis2pm:parentResource>);
5468     $r->{<Q::MDOMX:class>}
5469     = {type => 'quoted',
5470     value => $class-><AG::ManakaiDISResourceDefinition
5471     .plFullyQualifiedName>};
5472     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5473     (<Q::DISLang:AttributeGet>)) {
5474     my $attr = $self-><M::ManakaiDISPropertyAccessor
5475     .getPropertyResource> (<Q::dis2pm:parentResource>);
5476     $r->{<Q::MDOMX:attr>}
5477     = {type => 'quoted',
5478     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
5479     my $class = $attr-><M::ManakaiDISPropertyAccessor
5480     .getPropertyResource> (<Q::dis2pm:parentResource>);
5481     $r->{<Q::MDOMX:class>}
5482     = {type => 'quoted',
5483     value => $class-><AG::ManakaiDISResourceDefinition
5484     .plFullyQualifiedName>};
5485     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'get'};
5486     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5487     (<Q::DISLang:AttributeSet>)) {
5488     my $attr = $self-><M::ManakaiDISPropertyAccessor
5489     .getPropertyResource> (<Q::dis2pm:parentResource>);
5490     $r->{<Q::MDOMX:attr>}
5491     = {type => 'quoted',
5492     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
5493     my $class = $attr-><M::ManakaiDISPropertyAccessor
5494     .getPropertyResource> (<Q::dis2pm:parentResource>);
5495     $r->{<Q::MDOMX:class>}
5496     = {type => 'quoted',
5497     value => $class-><AG::ManakaiDISResourceDefinition
5498     .plFullyQualifiedName>};
5499     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'set'};
5500     } else {
5501     $r->{<Q::MDOMX:resourceURI>} = {type => 'quoted',
5502     value => $self->{uri}};
5503     }
5504     }__;
5505    
5506     @Method:
5507     @@Name: plGetMethodInputNormalizer
5508     @@enDesc:
5509     Returns an input processor. This method assumes that
5510     this resource is a method parameter (<Q::DISLang:MethodParameter>).
5511     @@Return:
5512     @@@Type:ManakaiDISResourceDefinition
5513     @@@enDesc:
5514     A <Q::DISLang:InputProcessor> corresponding to
5515     the parameter defined by this resource.
5516     \
5517     {NOTE:: <Q::ManakaiDOM:inputNormalize> property is
5518     obsolete in favor of <Q::DISLang:InputProcessor>;
5519     this method does not support the former.
5520     \
5521     }
5522     @@@nullCase:
5523     @@@@enDesc:
5524     No input processor found.
5525     @@@PerlDef:
5526     my $type;
5527     try {
5528     $type = $self-><AG::ManakaiDISResourceDefinition
5529     .disActualDataTypeResource>;
5530 wakaba 1.16 #$type_node = $self->< AG::ManakaiDISResourceDefinition
5531 wakaba 1.15 # .disActualDataTypeNode>;
5532     } catch <Class::ManakaiDISException> with {
5533     my $err = shift;
5534     unless ($err->{<Q::MDOMX:subtype>} eq <Q::DIS:NO_DIS_TYPE_ERR>) {
5535     $err->throw;
5536     }
5537     };
5538     if ($type) {
5539     __DEEP{
5540     $r = $type-><M::ManakaiDISResourceDefinition.getChildResourceByType>
5541     (<Q::DISLang:InputProcessor>);
5542     }__;
5543     }
5544    
5545     @IntMethod:
5546     @@Name: plAppendThrow
5547     @@enDesc:
5548     Appends a <Perl::report> method call statement for exception reporting.
5549     @@Param:
5550     @@@Name: parentNode
5551     @@@enDesc:
5552     The parent Perl code node to which a new statement is appended.
5553     @@@Type: PLBlockCon
5554     @@Param:
5555     @@@Name: xclass
5556     @@@Type: ManakaiDISResourceDefinition
5557     @@@enDesc:
5558     An exception class.
5559     @@Param:
5560     @@@Name: xcode
5561     @@@Type: ManakaiDISResourceDefinition
5562     @@@enDesc:
5563     An exception code constant.
5564     @@Param:
5565     @@@Name: xsubtype
5566     @@@Type: ManakaiDISResourceDefinition
5567     @@@enDesc:
5568     An exception subtype.
5569     @@@nullCase:
5570     @@@@enDesc:
5571     No subtype.
5572     @@Param:
5573     @@@Name: xparam
5574     @@@Type:
5575     Perl:hash::ManakaiDOM:all
5576     @@@enDesc:
5577     A hash containing parameters passed to the <Perl:report> method.
5578     A hash key is to be a parameter name. Hash values
5579     should also be hashes. A hash value hash has two values:
5580     <CODE::type> and <CODE::value>. A <CODE::value>
5581     value is a parameter value. If <CODE::type> is
5582     <CODE::code>, then <CODE::value> is assumed as a Perl code fragment.
5583     Otherwise, <CODE::value> is quoted to be interpreted as a string as is.
5584     @@Return:
5585 wakaba 1.16 @@@RaiseException:
5586     @@@@@: RESOURCE_NOT_DEFINED_ERR
5587     @@@@enDesc:
5588     Either <P::xclass>, <P::xcode> or <P::xsubtype>
5589     is not defined.
5590 wakaba 1.15 @@@PerlDef:
5591     my $statement = $parentNode-><M::PLBlockCon.appendStatement>
5592     ('report '.
5593     $xclass-><AG::ManakaiDISResourceDefinition.plFullyQualifiedName>.
5594     ' -object => $self');
5595 wakaba 1.16 my $xclass_module = $xclass-><AG::ManakaiDISResourceDefinition
5596     .definingModule>;
5597     unless ($xclass-><AG::ManakaiDISResourceDefinition.isDefined> or
5598     not $xclass_module) {
5599     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5600     DIS:sourceNode => {$self->{src}},
5601     DIS:uri => {$xclass->{uri}},
5602     DIS:localName => {$xclass->{localName}},
5603     DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
5604     }__;
5605     }
5606 wakaba 1.15 $self-><AG::ManakaiDISResourceDefinition.definingModule>
5607 wakaba 1.16 -><M::ManakaiDISModuleDefinition.plAddRequireModule> ($xclass_module);
5608 wakaba 1.15 $xparam->{-type} = {type => 'quoted',
5609     value => $xcode-><AG::ManakaiDISResourceDefinition
5610     .plName>};
5611     $xparam->{<Q::MDOMX:subtype>} = {type => 'quoted',
5612     value => $xsubtype->{nameURI}}
5613     if $xsubtype;
5614     for my $name (keys %$xparam) {
5615     my $pname = $name;
5616     $pname =~ s/(['\\])/\\$1/g;
5617     $pname = qq<'$pname'>;
5618     $statement-><M::PLInCon.appendCode>
5619     (', ' . $pname . ' => ');
5620     if ($xparam->{$name}->{type} eq 'code') {
5621     if (ref $xparam->{$name}->{value}) {
5622     $statement-><M::PLInCon.appendCodeFragment>
5623     ($xparam->{$name}->{value});
5624     } else {
5625 wakaba 1.16 $statement-><M::PLInCon.appendCodeFragment>
5626 wakaba 1.15 ($self-><M::ManakaiDISResourceDefinition
5627     .plPreprocessPerlStatement>
5628     ($xparam->{$name}->{value}));
5629     }
5630     } else { ## String as is
5631     $statement-><M::PLAnyCon.appendStringLiteral>
5632     ($xparam->{$name}->{value});
5633     }
5634     }
5635    
5636 wakaba 1.18 @Attr:
5637     @@Name: plIsNullable
5638     @@enDesc:
5639     Whether this resource is <QUOTE::nullable> or not.
5640     <QUOTE::Nullability> is defined for method parameters,
5641     method returns, attribute getters and attribute setters.
5642     @@Type:
5643     DOMMain:boolean::ManakaiDOM:all
5644     @@Get:
5645     @@@RaiseException:
5646     @@@@@:NO_DIS_TYPE_ERR
5647     @@@@enDesc:
5648     There is a <Q::ManakaiDOM:InCase> child resource
5649     that does not have <Q::dis:Type> attribute.
5650     @@@PerlDef:
5651     __DEEP{
5652     for my $incase (@{$self-><M::ManakaiDISPropertyAccessor
5653     .getPropertyResourceList>
5654     (<Q::DIS:childResource>)}) {
5655     next unless $incase-><M::ManakaiDISResourceDefinition.isTypeURI>
5656     (<Q::ManakaiDOM:InCase>);
5657     if ($incase-><AG::ManakaiDISResourceDefinition.disIsNullValue> or
5658     $incase-><AG::ManakaiDISResourceDefinition
5659     .disActualDataTypeResource>
5660     -><M::ManakaiDISResourceDefinition
5661     .isSubsetOfURI> (<Q::DOMMain:boolean>)) {
5662     $r = true;
5663     last;
5664     }
5665     }
5666     }__;
5667    
5668     @Attr:
5669     @@Name: disIsNullValue
5670     @@enDesc:
5671     Whether this resource have <DOM::null> value or not.
5672     A resource have <DOM::null> value iff it has
5673     <Q::dis:Value> attribute node that in turn has
5674     <Q::dis:is-null> attribute whose value set to <DOM::true>.
5675     @@Type:
5676     DOMMain:boolean::ManakaiDOM:all
5677     @@Get:
5678     @@@PerlDef:
5679     if ($self->{src}) {
5680     __DEEP{
5681     my $val = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5682     (<Q::dis:Value>,
5683     for_arg => $self->{for},
5684     forp_arg => $self->{forp});
5685     if ($val) {
5686     my $isnull = $val-><M::ManakaiDISElement.disGetAttribute>
5687     (<Q::dis:is-null>,
5688     for_arg => $self->{for},
5689     forp_arg => $self->{forp});
5690     if ($isnull and $isnull-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
5691     .value>) {
5692     $r = true;
5693     }
5694     }
5695     }__;
5696     }
5697 wakaba 1.2 ##DISResourceDefinition
5698    
5699 wakaba 1.13 ElementTypeBinding:
5700 wakaba 1.15 @Name: BlockElementException
5701     @ElementType:
5702     ManakaiDOM:raises
5703     @ShadowContent:
5704     @@@: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
5705     @@Description:
5706     @@@lang:en
5707     @@@@:
5708     An exception type specification is required but not specified.
5709     @ShadowSibling:
5710     @@ManakaiDOM:raises:
5711     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
5712     @@@Description:
5713     @@@@lang:en
5714     @@@@@:
5715     A code qualified name is required but not specified.
5716     @@ManakaiDOM:raises:
5717     @@@@: RESOURCE_NOT_DEFINED_ERR
5718     @@@Description:
5719     @@@@lang:en
5720     @@@@@:
5721     A referred resource is not defined or has different type.
5722     @@ManakaiDOM:raises:
5723     @@@@: PERL_CODE_NOT_DEFINED_ERR
5724     @@@Description:
5725     @@@@lang:en
5726     @@@@@:
5727     A referred resource does not have its Perl definition.
5728     @@ManakaiDOM:raises:
5729     @@@@: PERL_PREPROCESS_NO_METHOD_ERR
5730     @@@Description:
5731     @@@@lang:en
5732     @@@@@:
5733     A preprocessing instruction which is allowed only in
5734     methods is embeded in a context which is not in any method.
5735     @@ManakaiDOM:raises:
5736     @@@@: PERL_PREPROCESS_NO_FOR_ERR
5737     @@@Description:
5738     @@@@lang:en
5739     @@@@@:
5740     A <QUOTE::for> qualified name is required but not specified.
5741     @@ManakaiDOM:raises:
5742     @@@@: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
5743     @@@Description:
5744     @@@@lang:en
5745     @@@@@:
5746     An assertion type qualified name is required but not specified.
5747     @@ManakaiDOM:raises:
5748     @@@@: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
5749     @@@Description:
5750     @@@@lang:en
5751     @@@@@:
5752     A preprocessing instruction block is specified
5753     but not allowed for this element type.
5754    
5755     ElementTypeBinding:
5756 wakaba 1.13 @Name: InlineElementException
5757     @ElementType:
5758     ManakaiDOM:raises
5759     @ShadowContent:
5760     @@@: NO_SOURCE_NODE_ERR
5761     @@Description:
5762     @@@lang:en
5763     @@@@:
5764     This resource definition does not have associated node
5765     in the source tree.
5766     @ShadowSibling:
5767     @@ManakaiDOM:raises:
5768     @@@@: INTERFACE_CLASS_METHOD_ERR
5769     @@@Description:
5770     @@@@lang:en
5771     @@@@@:
5772     An attempt is made to call a class (static) method
5773     via an interface, not class.
5774     @@ManakaiDOM:raises:
5775     @@@@: RESOURCE_NOT_DEFINED_ERR
5776     @@@Description:
5777     @@@@lang:en
5778     @@@@@:
5779     A package, method or attribute is not defined or not
5780     a resoure of that type.
5781     @@ManakaiDOM:raises:
5782     @@@@: NO_LOCAL_NAME_ERR
5783     @@@Description:
5784     @@@@lang:en
5785     @@@@@:
5786     A referred resource does not have its local name so
5787     that it is impossible to refer it by name.
5788     @@ManakaiDOM:raises:
5789     @@@@: RESERVED_PERL_METHOD_NAME_ERR
5790     @@@Description:
5791     @@@@lang:en
5792     @@@@@:
5793     A referred method has its name reserved for special-purpose.
5794     @@ManakaiDOM:raises:
5795     @@@@: BROKEN_PARAM_SPEC_ERR
5796     @@@Description:
5797     @@@@lang:en
5798     @@@@@:
5799     A parameter specification is not well-formed.
5800     @@ManakaiDOM:raises:
5801     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
5802 wakaba 1.14 @@@Description:
5803     @@@@lang:en
5804     @@@@@:
5805     A preprocessing instruction does not contain
5806     Perl code fragment name.
5807 wakaba 1.13 @@ManakaiDOM:raises:
5808     @@@@: PERL_CODE_NOT_DEFINED_ERR
5809 wakaba 1.14 @@@Description:
5810     @@@@lang:en
5811     @@@@@:
5812     The referred resource does not have its Perl definition.
5813 wakaba 1.13 @@ManakaiDOM:raises:
5814     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
5815 wakaba 1.14 @@@Description:
5816     @@@@lang:en
5817     @@@@@:
5818     A preprocessing instruction does not contain its element type name.
5819 wakaba 1.13 @@ManakaiDOM:raises:
5820     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
5821 wakaba 1.14 @@@Description:
5822     @@@@lang:en
5823     @@@@@:
5824     An unknown element type is encounted.
5825     @@ManakaiDOM:raises:
5826     @@@@: NO_PERL_PACKAGE_NAME_ERR
5827     @@@Description:
5828     @@@@lang:en
5829     @@@@@:
5830     No Perl package name is defined for a class or interface.
5831 wakaba 1.13
5832     PropDef:
5833     @QName: ownerClass
5834     @enDesc:
5835     The class to which this resource belongs.
5836     @Type: ResourceURI
5837     @rdfs:range:
5838     rdf:Resource
5839     @rdfs:domain:
5840     ManakaiDOM:Class
5841    
5842 wakaba 1.12 ResourceDef:
5843     @QName: DOMMinImpl
5844     @rdf:type:
5845     ManakaiDOM:IF
5846     @AliasFor:
5847     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
5848    
5849     ResourceDef:
5850     @QName: SWCFGNode
5851     @rdf:type:
5852     ManakaiDOM:IF
5853     @AliasFor:
5854     swcfg21:SWCFGNode::swcfg21:ForLatest
5855    
5856     ResourceDef:
5857     @QName: SWCFGDoc
5858     @rdf:type:
5859     ManakaiDOM:IF
5860     @AliasFor:
5861     swcfg21:SWCFGDocument::swcfg21:ForLatest
5862    
5863     ResourceDef:
5864     @QName: MPLImpl
5865     @rdf:type:
5866     ManakaiDOM:Class
5867     @AliasFor:
5868     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
5869    
5870     ResourceDef:
5871     @QName: MPLCodeFragment
5872     @rdf:type:
5873     ManakaiDOM:Class
5874     @AliasFor:
5875     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
5876    
5877     ResourceDef:
5878 wakaba 1.13 @QName: PLInCon
5879     @rdf:type:
5880     ManakaiDOM:Class
5881     @AliasFor:
5882     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
5883    
5884     ResourceDef:
5885 wakaba 1.15 @QName: PLBlockCon
5886     @rdf:type:
5887     ManakaiDOM:Class
5888     @AliasFor:
5889     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
5890    
5891     ResourceDef:
5892 wakaba 1.13 @QName: PLAnyCon
5893     @rdf:type:
5894     ManakaiDOM:Class
5895     @AliasFor:
5896     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
5897    
5898     ResourceDef:
5899     @QName: MPLSS
5900     @rdf:type:
5901     ManakaiDOM:Class
5902     @AliasFor:
5903     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
5904    
5905     ResourceDef:
5906 wakaba 1.12 @QName: MPLSub
5907     @rdf:type:
5908     ManakaiDOM:Class
5909     @AliasFor:
5910     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
5911    
5912     ResourceDef:
5913     @QName: MPLUnparsedCode
5914     @rdf:type:
5915     ManakaiDOM:Class
5916     @AliasFor:
5917     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
5918    
5919     PropDef:
5920     @QName: plCodeFragment
5921     @enDesc:
5922     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
5923    
5924     XParamDef:
5925     @QName: errResource
5926     @enDesc:
5927     A resource on which an error has occurred.
5928    
5929 wakaba 1.8 XParamDef:
5930     @QName: generatedName
5931     @enDesc:
5932     A generated name.
5933    
5934 wakaba 1.2 ClsDef:
5935     @ClsQName: ManakaiDISPropertyAccessor
5936 wakaba 1.3 @enDesc:
5937 wakaba 1.2 Accessor methods for resource or module properties.
5938    
5939     @Method:
5940 wakaba 1.8 @@Name: getPropertyBoolean
5941     @@enDesc:
5942     Gets boolean property value.
5943     @@PropNameParam:
5944     @@Param:
5945     @@@Name:default
5946     @@@Type:
5947     DOMMain:boolean::ManakaiDOM:all
5948     @@@enDesc:
5949     The default value that is returned if no explicit property
5950     value specification found for this resource.
5951     @@Return:
5952     @@@Type:
5953     DOMMain:boolean::ManakaiDOM:all
5954     @@@enDesc:
5955     The property value.
5956     @@@PerlDef:
5957     if (exists $self->{$propName}) {
5958     $r = defined $self->{$propName} ? $self->{$propName} : $default;
5959     } elsif ($self->{src}) {
5960 wakaba 1.18 my $attr_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5961 wakaba 1.8 ($propName, for_arg => $self->{for},
5962     forp_arg => $self->{forp});
5963 wakaba 1.18 $r = $self->{$propName} = ($attr_node
5964     ? ($attr_node-><M::SWCFGNode.value>
5965     ? true : false)
5966     : null);
5967 wakaba 1.8 $r = $default unless defined $r;
5968     } else {
5969     $r = $default;
5970     }
5971    
5972     @Method:
5973 wakaba 1.2 @@Name: getPropertyText
5974     @@enDesc:
5975     Gets property value text.
5976     @@PropNameParam:
5977     @@Param:
5978     @@@Name:default
5979     @@@Type:
5980 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
5981 wakaba 1.2 @@@enDesc:
5982     The default value that is returned if no explicit property
5983     value specification found for this resource.
5984     @@@nullCase:
5985     @@@@enDesc:
5986     No default value supplied; <DOM::null> is returned if
5987     no value specified.
5988     @@Return:
5989     @@@Type:
5990 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
5991 wakaba 1.2 @@@enDesc:
5992     The property value string.
5993     @@@nullCase:
5994     @@@@enDesc:
5995     No value nor default value has specified.
5996     @@@PerlDef:
5997     if (exists $self->{$propName}) {
5998     $r = defined $self->{$propName} ? $self->{$propName} : $default;
5999     } elsif ($self->{src}) {
6000     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6001     ($propName, for_arg => $self->{for},
6002     forp_arg => $self->{forp});
6003 wakaba 1.8 if ($r) {
6004     $r = $self->{$propName}
6005 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
6006 wakaba 1.8 $r = $default unless defined $r;
6007     } else {
6008     $r = $default;
6009     $self->{$propName} = null;
6010     }
6011 wakaba 1.2 } else {
6012     $r = $default;
6013     }
6014    
6015     @Method:
6016     @@Name: getPropertyResource
6017     @@enDesc:
6018     Gets property value resource.
6019     @@PropNameParam:
6020 wakaba 1.10 @@NamedParam:
6021     @@@Name: defaultMediaType
6022     @@@Type: ResourceURI
6023     @@@enDesc:
6024     The URI reference of the default media type which is used
6025     when the property value is retrieved from the source tree
6026     and the source tree element does not have its <Q::dis:ContentType>
6027     attribute specified.
6028     @@@nullCase:
6029     @@@@enDesc:
6030     Defaulted to <Q::dis:TypeQName>.
6031 wakaba 1.2 @@Return:
6032     @@@Type: ManakaiDISResourceDefinition
6033     @@@enDesc:
6034     The property value resource.
6035     @@@nullCase:
6036     @@@@enDesc:
6037     No value has specified.
6038 wakaba 1.8 @@@UndeclaredPrefixException:
6039 wakaba 1.12 @@@RaiseException:
6040     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
6041     @@@@enDesc:
6042     The media type of the attribute node in the source tree
6043     corresponding to this resource is not supported.
6044 wakaba 1.2 @@@PerlDef:
6045     if (defined $self->{$propName}) {
6046 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
6047     ($self->{$propName});
6048 wakaba 1.8 } elsif ($self->{src}) {
6049     __DEEP{
6050     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6051     ($propName, for_arg => $self->{for},
6052     forp_arg => $self->{forp});
6053     if ($r) {
6054 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
6055     unless defined $defaultMediaType;
6056     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
6057 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
6058     for_arg => $self->{for},
6059     forp_arg => $self->{forp})) {
6060 wakaba 1.10 $self->{$propName}
6061     = $r-><AG::ManakaiDISElement.qnameValueURI>;
6062     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
6063 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
6064     for_arg => $self->{for},
6065     forp_arg => $self->{forp})) {
6066 wakaba 1.10 $self->{$propName}
6067     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
6068     ($self->{src}-><AG::swcfg21:SWCFGNode
6069     ::swcfg21:ForLatest.nodeID>,
6070     $self->{for});
6071     } else {
6072     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
6073     (for_arg => $self->{for},
6074     forp_arg => $self->{forp});
6075     __UNDEEP{
6076     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
6077     DIS:uri => {$mt},
6078     DIS:sourceNode => {$r},
6079     }__;
6080     }__;
6081     }
6082 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
6083     ($self->{$propName});
6084 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
6085 wakaba 1.8 }
6086     }__;
6087 wakaba 1.2 }
6088    
6089     @Method:
6090 wakaba 1.10 @@Name: getPropertyResourceList
6091     @@enDesc:
6092     Gets property value resource list.
6093     @@PropNameParam:
6094     @@NamedParam:
6095     @@@Name: recursiveISA
6096     @@@Type:
6097 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
6098 wakaba 1.10 @@@enDesc:
6099     Whether property resource values of <Q::dis:ISA> resources
6100     of this resource should also be included to the returned list or not.
6101     @@NamedParam:
6102     @@@Name: defaultMediaType
6103     @@@Type: ResourceURI
6104     @@@enDesc:
6105     The URI reference of the default media type which is used
6106     when the property value is retrieved from the source tree
6107     and the source tree element does not have its <Q::dis:ContentType>
6108     attribute specified.
6109     @@@nullCase:
6110     @@@@enDesc:
6111     Defaulted to <Q::dis:TypeQName>.
6112     @@Return:
6113     @@@Type: ResourceList
6114     @@@enDesc:
6115     An array reference of the property value resources.
6116     \
6117     {NOTE:: This list is <QUOTE::dead>.
6118     \
6119     }
6120     @@@UndeclaredPrefixException:
6121 wakaba 1.12 @@@RaiseException:
6122     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
6123     @@@@enDesc:
6124     The media type of the attribute node in the source tree
6125     corresponding to this resource is not supported.
6126 wakaba 1.10 @@@PerlDef:
6127     $r = [];
6128     if (defined $self->{$propName}) {
6129     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
6130     ? $self->{$propName} : []}) {
6131     push @$r,
6132     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
6133     }
6134     } elsif ($self->{src}) {
6135     __DEEP{
6136     $self->{$propName} = [];
6137     $defaultMediaType = <Q::dis:TypeQName>
6138     unless defined $defaultMediaType;
6139     for my $res_name_node
6140     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
6141     ($propName, for_arg => $self->{for},
6142     forp_arg => $self->{forp})}) {
6143     my $res_uri;
6144     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
6145 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
6146     for_arg => $self->{for},
6147     forp_arg => $self->{forp})) {
6148 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
6149     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
6150 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
6151     for_arg => $self->{for},
6152     forp_arg => $self->{forp})) {
6153 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
6154     ($self->{src}-><AG::swcfg21:SWCFGNode
6155     ::swcfg21:ForLatest.nodeID>,
6156     $self->{for});
6157     } else {
6158     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
6159     (for_arg => $self->{for},
6160     forp_arg => $self->{forp});
6161     __UNDEEP{
6162     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
6163     DIS:uri => {$mt},
6164     DIS:sourceNode => {$res_name_node},
6165     }__;
6166     }__;
6167     }
6168     push @{$self->{$propName}}, $res_uri;
6169     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
6170     ($res_uri);
6171     push @$r, $res;
6172 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
6173 wakaba 1.10 ($res_name_node);
6174     }
6175     }__;
6176     }
6177     if ($recursiveISA) {
6178     __DEEP{
6179     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
6180     my @p_res = @$r;
6181     for my $p_res (@p_res) {
6182     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
6183     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
6184     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
6185     .getPropertyResourceList>
6186     (<Q::dis:ISA>, recursive_isa => true,
6187     ___recursive_isa_done => $opt{___recursive_isa_done},
6188     default_media_type => $defaultMediaType)};
6189     }
6190     }__;
6191     }
6192    
6193     @Method:
6194 wakaba 1.2 @@Name: addPropertyResourceList
6195     @@enDesc:
6196     Adds a resource to a resource-list property value.
6197     \
6198     {ISSUE:: Should an exception be thrown if the property is
6199     not of list?
6200     \
6201     }
6202 wakaba 1.10 \
6203     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
6204     an item clears the list --- i.e. the property values
6205     in the source tree will be ignored. Call
6206     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
6207     before adding to avoid this behavior.
6208     \
6209     }
6210 wakaba 1.2 @@PropNameParam:
6211     @@Param:
6212     @@@Name: res
6213     @@@Type: ManakaiDISResourceDefinition
6214     @@@enDesc:
6215     A resource to add.
6216     @@Return:
6217     @@@PerlDef:
6218     if (ref $self->{$propName} eq 'ARRAY') {
6219     push @{$self->{$propName}}, $res->{uri};
6220     } elsif (not defined $self->{$propName}) {
6221     $self->{$propName} = [$res->{uri}];
6222     }
6223    
6224 wakaba 1.3 ElementTypeBinding:
6225     @Name: PropNameParam
6226     @ElementType:
6227     dis:ResourceDef
6228     @ShadowContent:
6229     @@rdf:type:
6230     DISLang:MethodParameter
6231     @@Name: propName
6232     @@Type: ResourceURI
6233     @@Description:
6234     @@@lang:en
6235     @@@@:
6236     The name of the property.
6237    
6238 wakaba 1.2 ##DISPropertyAccessor
6239    
6240     PropDef:
6241     @QName:isAnon
6242     @Description:
6243     @@lang:en
6244     @@@:
6245     Whether the subject resource is anonymous or not.
6246     @Type:
6247 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
6248 wakaba 1.2
6249     PropDef:
6250     @QName:isDefined
6251     @Description:
6252     @@lang:en
6253     @@@:
6254     Whether the subject resource is defined or not.
6255    
6256     PropDef:
6257 wakaba 1.3 @QName:isReferred
6258 wakaba 1.2 @Description:
6259     @@lang:en
6260     @@@:
6261     Whether the subject resource is referred or not.
6262     @Type:
6263     DOMMain:any
6264    
6265     PropDef:
6266     @QName:definingModule
6267     @Description:
6268     @@lang:en
6269     @@@:
6270     The <QUOTE::dis> module in which the subject resource is defined.
6271     @rdfs:domain:
6272     DISCore:Module
6273 wakaba 1.1
6274     ## -- Datatypes
6275    
6276     URITypeDef:
6277 wakaba 1.3 @QName: AnyURI
6278     @Description:
6279     @@lang:en
6280     @@@:
6281     Any URI references.
6282    
6283     URITypeDef:
6284     @QName: FileURI
6285     @enDesc:
6286     URI references identifying file.
6287    
6288     URITypeDef:
6289 wakaba 1.1 @QName: ForURI
6290     @Description:
6291     @@lang:en
6292     @@@:
6293     <QUOTE::For> URI references.
6294    
6295     DataTypeDef:
6296     @QName: ForURIList
6297     @Description:
6298     @@lang:en
6299     @@@:
6300     References to the array containing <QUOTE::for> URI references.
6301    
6302     URITypeDef:
6303 wakaba 1.3 @QName: ResourceURI
6304     @Description:
6305     @@lang:en
6306     @@@:
6307     A URI reference for a <QUOTE::dis> resource.
6308    
6309     URITypeDef:
6310 wakaba 1.1 @QName: MediaTypeURI
6311     @Description:
6312     @@lang:en
6313     @@@:
6314     Media type URI references.
6315 wakaba 1.3 @rdfs:subClassOf: ResourceURI
6316    
6317     URITypeDef:
6318     @QName: ModuleURI
6319     @enDesc:
6320     URI references for <QUOET::dis> modules.
6321     @rdfs:subClassOf: ResourceURI
6322    
6323     URITypeDef:
6324     @QName: NameURI
6325     @enDesc:
6326     URI references identifying a resource.
6327     @rdfs:subClassOf: ResourceURI
6328 wakaba 1.10
6329     DataTypeDef:
6330     @QName: ResourceList
6331     @enDesc:
6332     References to array containing resource definition objects.
6333     @rdfs:subClassOf:
6334     Perl:ARRAY::ManakaiDOM:all
6335 wakaba 1.3
6336     ElementTypeBinding:
6337     @Name: DataTypeDef
6338     @ElementType:
6339     dis:ResourceDef
6340     @ShadowContent:
6341     @@rdf:type:
6342     ManakaiDOM:DataType
6343    
6344     ElementTypeBinding:
6345     @Name: URITypeDef
6346     @ElementType:
6347     dis:ResourceDef
6348     @ShadowContent:
6349     @@rdf:type:
6350     ManakaiDOM:DataType
6351     @@rdfs:subClassOf: AnyURI
6352 wakaba 1.1
6353     ## -- Exceptions
6354    
6355     XParamDef:
6356 wakaba 1.5 @QName: anotherSourceNode
6357     @enDesc:
6358     Another source node in which an error has occurred. In cases
6359     of <QUOTE::already defined> errors, it is the node that
6360     defines the resource first.
6361     @Type: ManakaiDISNode
6362 wakaba 1.3
6363 wakaba 1.12 ResourceDef:
6364     @QName: UNDECLARED_NS_PREFIX_ERR
6365     @For: ForLatest
6366     @AliasFor:
6367     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
6368    
6369 wakaba 1.3 ExceptionDef:
6370     @ClsQName: ManakaiDISException
6371     @enDesc:
6372     Exceptions for the <QUOTE::dis> operations.
6373 wakaba 1.4 @ClsISA:
6374     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
6375 wakaba 1.3 @XConstGroupDef:
6376     @@ClsQName: ManakaiDISExceptionCode
6377     @@enDesc:
6378     Exception codes for <Class::ManakaiDISException>.
6379     @@XConstDef:
6380 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
6381     @@@Value:3
6382     @@@enDesc:
6383     An attempt is made to break the hierarchy.
6384     @@@XSubTypeDef:
6385     @@@@QName: MERGE_ITSELF_ERR
6386     @@@@enDesc:
6387     An attempt is made to merge the resource to itself.
6388     @@@@XSourceNodeParam:
6389     @@@@XParam:
6390     @@@@@QName:uri
6391     @@@@@enDesc:
6392     The URI reference of the resource to merge.
6393     @@@@enMufDef:
6394     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
6395     );> to itself
6396     @@XConstDef:
6397 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
6398     @@@Value:9
6399     @@@enDesc:
6400     An attempt is made to do something the implementation does not support.
6401     @@@XSubTypeDef:
6402     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
6403     @@@@enDesc:
6404     The implementation does not support the media type.
6405     @@@@XParam:
6406     @@@@@QName: uri
6407     @@@@@enDesc:
6408     The URI reference of the media type that is not supported.
6409     @@@@XSourceNodeParam:
6410 wakaba 1.12 @@@@enMufDef:
6411     Media type <%p (name => {<Q::DIS:uri>});> is not supported
6412 wakaba 1.3 @@@XSubTypeDef:
6413 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
6414     @@@@enDesc:
6415     An unsupported type of element is encounted.
6416     @@@@XSourceNodeParam:
6417     @@@@XParam:
6418     @@@@@QName:elementType
6419     @@@@@enDesc:
6420     The element type URI reference of the element.
6421 wakaba 1.16 @@@@enMufDef:
6422     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
6423 wakaba 1.13 @@@XSubTypeDef:
6424 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
6425 wakaba 1.3 @@@@enDesc:
6426 wakaba 1.12 There is no implementation that supports the
6427     <Feature::Util:PerlCode> feature, version
6428     <FeatureVer::1.0>.
6429 wakaba 1.3 @@XConstDef:
6430     @@@Name: INVALID_STATE_ERR
6431     @@@Value:11
6432     @@@enDesc:
6433     An attempt is made to use an object that is not (or no longer) usable.
6434     @@@XSubTypeDef:
6435     @@@@QName: NO_ASSOCIATED_DB_ERR
6436     @@@@enDesc:
6437     No <QUOTE::dis> database has been associated with this document.
6438 wakaba 1.4 @@XConstDef:
6439     @@@Name: INVALID_SOURCE_ERR
6440     @@@Value: 200
6441     @@@enDesc:
6442     The source input is well-formed but invalid.
6443     @@@XSubTypeDef:
6444     @@@@QName: NO_MODULE_QNAME_ERR
6445     @@@@enDesc:
6446     The <Q::dis:Module> element must have its <Q::dis:QName>
6447     attribute.
6448 wakaba 1.8 @@@@XSourceNodeParam:
6449     @@@XSubTypeDef:
6450     @@@@QName: NO_LOCAL_NAME_ERR
6451     @@@@enDesc:
6452     The resource does not have a local name.
6453     @@@@XSourceNodeParam:
6454 wakaba 1.4 @@@XSubTypeDef:
6455     @@@@QName: UNABLE_TO_GET_MODULE_ERR
6456     @@@@enDesc:
6457     The implementation is unable to get the module source.
6458     @@@@Def:
6459     @@@@@ContentType:
6460     lang:muf
6461     @@@@@lang:en
6462     @@@@@@:
6463     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
6464     @@@@XParam:
6465     @@@@@QName: uri
6466     @@@@@enDesc:
6467     The URI reference of the module.
6468     @@@@XParam:
6469     @@@@@QName: namespaceURI
6470     @@@@@enDesc:
6471     The namespace URI of the module name.
6472     @@@@XParam:
6473     @@@@@QName: localName
6474     @@@@@enDesc:
6475     The local name of the module name.
6476     @@@@XParam:
6477     @@@@@QName: for
6478     @@@@@enDesc:
6479     The <QUOTE::for> of the module.
6480 wakaba 1.5 @@@XSubTypeDef:
6481     @@@@QName: NO_FOR_QNAME_ERR
6482     @@@@enDesc:
6483     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
6484     @@@@XSourceNodeParam:
6485     @@@XSubTypeDef:
6486     @@@@QName: FOR_ALREADY_DEFINED_ERR
6487     @@@@enDesc:
6488     The <QUOTE::for> named as the same URI reference has
6489     already defined.
6490     @@@@XSourceNodeParam:
6491     @@@@XParam:
6492     @@@@@QName: anotherSourceNode
6493     @@@@@enDesc:
6494     The node that defines the <QUOTE::for> URI reference before.
6495 wakaba 1.7 @@@@XParam:
6496     @@@@@Name: uri
6497     @@@@@enDesc:
6498     The URI reference of the <QUOTE::for> attempted to define.
6499     @@@@enMufDef:
6500     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
6501 wakaba 1.5 @@@XSubTypeDef:
6502     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
6503     @@@@enDesc:
6504     The <QUOTE::dis> resource named as the same URI reference has
6505     already defined.
6506     @@@@XSourceNodeParam:
6507     @@@@XParam:
6508     @@@@@QName: anotherSourceNode
6509     @@@@@enDesc:
6510     The node that defines the <QUOTE::for> URI reference before.
6511 wakaba 1.7 @@@@XParam:
6512     @@@@@Name: uri
6513     @@@@@enDesc:
6514     The URI reference of the resource attempted to define.
6515     @@@@enMufDef:
6516     Resource <%p (name => {<Q::DIS:uri>});> is already defined
6517 wakaba 1.5 @@@XSubTypeDef:
6518     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
6519     @@@@enDesc:
6520     An element has occured where it is not allowed.
6521     @@@@enMufDef:
6522     Module <%p (name => {<Q::DIS:uri>});>:
6523     Element of type <%p (name => {<Q::DIS:elementType>});>
6524     is not allowed here
6525     @@@@XSourceNodeParam:
6526     @@@@XParam:
6527     @@@@@QName: elementType
6528     @@@@@enDesc:
6529     The expanded element type name of the element.
6530     @@@@XParam:
6531     @@@@@QName: uri
6532     @@@@@enDesc:
6533     The URI reference of the module.
6534 wakaba 1.7 @@@XSubTypeDef:
6535     @@@@QName: NO_REQUIRED_ATTR_ERR
6536     @@@@enDesc:
6537     A required attribute is not specified.
6538     @@@@XSourceNodeParam:
6539     @@@@XParam:
6540     @@@@@QName: elementType
6541     @@@@@enDesc:
6542     The expanded URI reference of the attribute name.
6543     @@@@enMufDef:
6544     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
6545 wakaba 1.8 @@@XSubTypeDef:
6546     @@@@QName: FOR_NOT_DEFINED_ERR
6547     @@@@enDesc:
6548     A <QUOTE::for> is referred but not defined.
6549     @@@@XSourceNodeParam:
6550     @@@@XParam:
6551     @@@@@QName: uri
6552     @@@@@enDesc:
6553     The URI reference of the <QUOTE::for> that is not defined.
6554     @@@@enMufDef:
6555     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
6556     @@@XSubTypeDef:
6557     @@@@QName: RESOURCE_NOT_DEFINED_ERR
6558     @@@@enDesc:
6559 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
6560     or the resource referred does not have the type expected.
6561 wakaba 1.8 @@@@XSourceNodeParam:
6562     @@@@XParam:
6563     @@@@@QName: uri
6564     @@@@@enDesc:
6565     The URI reference of the resource that is not defined.
6566 wakaba 1.13 @@@@XParam:
6567     @@@@@QName: elementType
6568     @@@@@enDesc:
6569     <QUOTE::dis> element type (either tree element type
6570     or preprocessing element type) of the element
6571     in which a reference to the undefined resource is contained.
6572     @@@@XParam:
6573     @@@@@QName: localName
6574     @@@@@enDesc:
6575     The local name of the undefined resource.
6576     @@@@XParam:
6577     @@@@QName: sourceCode
6578     @@@@enDesc:
6579     Source code fragment that referres this resource.
6580     @@@@XParam:
6581     @@@@@QName:expectedType
6582     @@@@@enDesc:
6583     Expected resource type.
6584 wakaba 1.8 @@@@enMufDef:
6585 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
6586 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
6587     suffix => {>});%p (name => {<Q::DIS:localName>},
6588     prefix => { "}, suffix => {"}); is not defined or wrong type%p
6589     (name => {<Q::DIS:expectedType>}, prefix => { (<},
6590     suffix => {> is expected)});
6591     @@@XSubTypeDef:
6592     @@@@QName: NO_SOURCE_NODE_ERR
6593     @@@@enDesc:
6594     A resource does not have associated node in the source tree.
6595     @@@@XSourceNodeParam:
6596     @@@@XParam:
6597     @@@@@QName:uri
6598     @@@@@enDesc:
6599     The URI reference of the resource.
6600 wakaba 1.8 @@@XSubTypeDef:
6601     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
6602     @@@@enDesc:
6603     A reserved Perl method name is used.
6604     @@@@XParam:
6605     @@@@@QName:uri
6606     @@@@@enDesc:
6607     The URI reference of the method resource.
6608     @@@@XSourceNodeParam:
6609     @@@@XParam:
6610     @@@@@QName: generatedName
6611     @@@@@enDesc:
6612     A reserved method name.
6613     @@@XSubTypeDef:
6614     @@@@QName: NO_DIS_TYPE_ERR
6615     @@@@enDesc:
6616     <Q::dis:Type> attribute is not found.
6617     @@@@XSourceNodeParam:
6618 wakaba 1.12 @@@XSubTypeDef:
6619     @@@@QName: NO_METHOD_RETURN_ERR
6620     @@@@enDesc:
6621     A <Q::DISLang:Method> resource does not have any
6622     <Q::DISLang:MethodReturn> child.
6623     @@@@XSourceNodeParam:
6624     @@@XSubTypeDef:
6625     @@@@QName: NO_ATTR_GET_ERR
6626     @@@@enDesc:
6627     A <Q::DISLang:Attribute> resource does not have any
6628     <Q::DISLang:AttributeGet> child.
6629     @@@@XSourceNodeParam:
6630 wakaba 1.13 @@@XSubTypeDef:
6631     @@@@QName:INTERFACE_CLASS_METHOD_ERR
6632     @@@@enDesc:
6633     An attempt is made to call a static (class) method
6634     from an interface.
6635     @@@@XSourceNodeParam:
6636     @@@@XParam:
6637     @@@@@QName:uri
6638     @@@@@enDesc:
6639     The URI reference of the interface.
6640     @@@@XParam:
6641     @@@@@QName:sourceCode
6642     @@@@@enDesc:
6643     Source code fragment that calls a class method.
6644     @@@@XParam:
6645     @@@@@QName:elementType
6646     @@@@@enDesc:
6647     The element type URI reference of the element
6648     that calls a method.
6649     @@@XSubTypeDef:
6650     @@@@QName: BROKEN_PARAM_SPEC_ERR
6651     @@@@enDesc:
6652     A parameter specification is broken.
6653     @@@@XParam:
6654     @@@@@QName: sourceCode
6655     @@@@@enDesc:
6656     Source code fragment that contains the broken parameter
6657     specification.
6658     @@@@XSourceNodeParam:
6659 wakaba 1.15 @@@@enMufDef:
6660     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
6661     suffix => {": });Broken parameter specification
6662 wakaba 1.13 @@@XSubTypeDef:
6663     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
6664     @@@@enDesc:
6665     A preprocessing instruction does not have its element
6666     type.
6667     @@@@XSourceNodeParam:
6668     @@@@XParam:
6669     @@@@@QName:sourceCode
6670     @@@@@enDesc:
6671     Source code fragment.
6672 wakaba 1.16 @@@@enMufDef:
6673     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
6674     suffix => {": });Element type name is not specified
6675 wakaba 1.13 @@@XSubTypeDef:
6676 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
6677 wakaba 1.13 @@@@enDesc:
6678 wakaba 1.15 No Perl package name is defined for the resource referred.
6679 wakaba 1.13 @@@@XSourceNodeParam:
6680     @@@@XParam:
6681 wakaba 1.15 @@@@@QName:sourceCode
6682 wakaba 1.13 @@@@@enDesc:
6683     Source code fragment.
6684     @@@@XParam:
6685 wakaba 1.15 @@@@@QName:uri
6686     @@@@@enDesc:
6687     THe URI reference of the resource referred.
6688     @@@@XParam:
6689     @@@@@QName:elementType
6690     @@@@@enDesc:
6691     The element type of Perl preprocessing instruction
6692     in which the resource is referred.
6693     @@@@enMufDef:
6694     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
6695     package name is not defined
6696     @@@XSubTypeDef:
6697     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
6698     @@@@enDesc:
6699     An exception type specification is required.
6700     @@@@XSourceNodeParam:
6701     @@@@XSourceCodeParam:
6702     @@@@XParam:
6703     @@@@@QName:elementType
6704     @@@@@enDesc:
6705     The element type of the preprocessing instruction.
6706     @@@XSubTypeDef:
6707     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
6708     @@@@enDesc:
6709     A code name specification is required.
6710     @@@@XSourceNodeParam:
6711     @@@@XSourceCodeParam:
6712     @@@@XParam:
6713 wakaba 1.13 @@@@@QName:elementType
6714     @@@@@enDesc:
6715 wakaba 1.15 The element type of the preprocessing instruction.
6716 wakaba 1.13 @@@XSubTypeDef:
6717     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
6718     @@@@enDesc:
6719 wakaba 1.15 The specified resource does not have its Perl definition.
6720 wakaba 1.13 @@@@XSourceNodeParam:
6721 wakaba 1.15 @@@@XSourceCodeParam:
6722 wakaba 1.13 @@@@XParam:
6723 wakaba 1.15 @@@@@QName:elementType
6724     @@@@@enDesc:
6725     The element type of the preprocessing instruction.
6726     @@@@XParam:
6727     @@@@@QName:uri
6728 wakaba 1.13 @@@@@enDesc:
6729 wakaba 1.15 The URI reference of the resource referred.
6730 wakaba 1.13 @@@@XParam:
6731     @@@@@QName:localName
6732     @@@@@enDesc:
6733     The local name of the resource referred.
6734 wakaba 1.15 @@@XSubTypeDef:
6735     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
6736     @@@@enDesc:
6737     A preprocessing instruction which is only allowed in
6738     method definitions is used in a code which is not a method.
6739     @@@@XSourceNodeParam:
6740     @@@@XSourceCodeParam:
6741 wakaba 1.13 @@@@XParam:
6742 wakaba 1.15 @@@@@QName:elementType
6743 wakaba 1.13 @@@@@enDesc:
6744 wakaba 1.15 The element type of the preprocessing instruction.
6745 wakaba 1.14 @@@XSubTypeDef:
6746 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
6747 wakaba 1.14 @@@@enDesc:
6748 wakaba 1.15 A <QUOTE::for> specification is required.
6749 wakaba 1.14 @@@@XSourceNodeParam:
6750 wakaba 1.15 @@@@XSourceCodeParam:
6751 wakaba 1.14 @@@@XParam:
6752 wakaba 1.15 @@@@@QName:elementType
6753 wakaba 1.14 @@@@@enDesc:
6754 wakaba 1.15 The element type of the preprocessing instruction.
6755     @@@XSubTypeDef:
6756     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
6757     @@@@enDesc:
6758     An assertion type specification is required.
6759     @@@@XSourceNodeParam:
6760     @@@@XSourceCodeParam:
6761 wakaba 1.14 @@@@XParam:
6762 wakaba 1.15 @@@@@QName:elementType
6763 wakaba 1.14 @@@@@enDesc:
6764 wakaba 1.15 The element type of the preprocessing instruction.
6765     @@@XSubTypeDef:
6766     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
6767     @@@@enDesc:
6768     A preprocessing instruction block occurred with
6769     element type which does not allow it.
6770     @@@@XSourceNodeParam:
6771     @@@@XSourceCodeParam:
6772 wakaba 1.14 @@@@XParam:
6773     @@@@@QName:elementType
6774     @@@@@enDesc:
6775 wakaba 1.15 The element type of the preprocessing instruction.
6776 wakaba 1.18 @@@XSubTypeDef:
6777     @@@@QName: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
6778     @@@@enDesc:
6779     A non-named method parameter following
6780     any named method parameter is occurred.
6781     @@@@XSourceNodeParam:
6782     @@@@XParam:
6783     @@@@@QName:uri
6784     @@@@@enDesc:
6785     The URI reference of the non-named method parameter resource.
6786     @@@@XParam:
6787     @@@@@QName:localName
6788     @@@@@enDesc:
6789     The local name of the non-named method parameter.
6790 wakaba 1.15
6791 wakaba 1.4 ##DISException
6792 wakaba 1.13
6793     XParamDef:
6794     @QName:expectedType
6795     @Type: ResourceURI
6796     @enDesc:
6797     Expected resource type URI reference.
6798    
6799     XParamDef:
6800     @QName: sourceCode
6801     @Type:
6802     DISLang:String::ManakaiDOM:all
6803     @enDesc:
6804     The source code fragment in which an error occurred.
6805 wakaba 1.5
6806     XParamDef:
6807     @QName: elementType
6808     @Type: ResourceURI
6809     @enDesc:
6810     The name of the element type.
6811    
6812     XParamDef:
6813     @QName: uri
6814     @Type: ResourceURI
6815     @enDesc:
6816     The name of the resource, composed from <Q::namespaceURI>,
6817     <Q::localName> and <Q::for>.
6818    
6819     XParamDef:
6820     @QName: localName
6821     @Type:
6822 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
6823 wakaba 1.5 @enDesc:
6824     The local name of the resource, unique in <Q::namespaceURI> namespace.
6825    
6826     XParamDef:
6827     @QName: namespaceURI
6828     @Type: AnyURI
6829     @enDesc:
6830     The namespace URI reference of the resource name.
6831    
6832     XParamDef:
6833     @QName: for
6834     @Type: ForURI
6835     @enDesc:
6836     The <QUOTE::for> URI reference of the resource.
6837    
6838     ElementTypeBinding:
6839     @Name: XSourceNodeParam
6840     @ElementType:
6841     ManakaiDOM:exceptionOrWarningParameter
6842     @ShadowContent:
6843     @@QName: sourceNode
6844     @@Description:
6845     @@@lang:en
6846     @@@@:
6847     The node in which an error has occurred.
6848 wakaba 1.15
6849     ElementTypeBinding:
6850     @Name: XSourceCodeParam
6851     @ElementType:
6852     ManakaiDOM:exceptionOrWarningParameter
6853     @ShadowContent:
6854     @@QName: sourceCode
6855     @@Description:
6856     @@@lang:en
6857     @@@@:
6858     The source code in which an error has occurred.
6859 wakaba 1.4
6860     ClsDef:
6861     @ClsQName: ManakaiDISExceptionTarget
6862     @enDesc:
6863     Objects that is able to be the target of an exception.
6864     @IntMethod:
6865     @@Operator:
6866     @@@@:
6867     ManakaiDOM:MUErrorHandler
6868     @@@ContentType:
6869     dis:TypeQName
6870     @@Description:
6871     @@@lang:en
6872     @@@@:
6873     This method is a generic error handler; all manakai exceptions
6874     and warnings associated to an object are once reported to this method
6875     and then delivered to appropriate entities.
6876     \
6877     If the error is an exception (such as <X::DOMCore:DOMException> or
6878     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
6879     simply thrown. If the error is only a warning, it is reported
6880     via the <IF::DOMCore:DOMError> interface.
6881     \
6882     See <PerlModule::Message::Util::Error> documentation for more
6883     information on the error reporting mechanism.
6884     \
6885     {NOTE:: This kind of methods are named as <Perl::___report_error>
6886     in the convention of <PerlModule::Message::Util::Error>.
6887     \
6888     }
6889     @@Param:
6890     @@@Name:err
6891     @@@Type:
6892     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
6893     @@@Description:
6894     @@@@lang:en
6895     @@@@@:
6896     An exception object that describes what kind of error it is
6897     and how it should be recovered.
6898     \
6899     {NOTE:: Exception objects in manakai implementation
6900     inherit the class <PerlModule::Message::Util::Error>,
6901     that in turn inherits <PerlModule::Error>.
6902     \
6903     }
6904     @@Return:
6905     @@@PerlDef:
6906     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
6907     ::ManakaiDOM:Perl>)) {
6908     $err->throw;
6909     } else {
6910     \## TODO: Implement warning reporting
6911     warn $err->stringify;
6912     }
6913     ##DISExceptionTarget
6914    
6915     ForDef:
6916     @QName:
6917     DIS:ForIF
6918     ForDef:
6919     @QName:
6920     DIS:ForClass
6921    
6922     ElementTypeBinding:
6923     @Name: IFClsDef
6924     @ElementType:
6925     dis:ResourceDef
6926     @ShadowContent:
6927     @@rdf:type:
6928     @@@@:
6929     dis:MultipleResource
6930     @@@ForCheck: !ForClass !ForIF
6931     @@rdf:type:
6932     @@@@:
6933     ManakaiDOM:IF
6934     @@@ForCheck: ForIF
6935     @@rdf:type:
6936     @@@@:
6937     ManakaiDOM:Class
6938     @@@ForCheck: ForClass
6939     @@resourceFor: ForIF
6940     @@resourceFor:
6941     @@@@: ForClass
6942     @@@ForCheck: ForLatest
6943     @@DOMMain:implementFeature:
6944     @@@@:CoreFeature10
6945     @@@ForCheck: ForClass
6946     @@ForCheck:
6947     ManakaiDOM:Perl
6948 wakaba 1.3
6949     ElementTypeBinding:
6950     @Name: ClsDef
6951     @ElementType:
6952     dis:ResourceDef
6953     @ShadowContent:
6954     @@rdf:type:
6955     ManakaiDOM:Class
6956     @@AliasFor:
6957     @@@@:
6958 wakaba 1.11 ::DIS:ForLatest
6959 wakaba 1.3 @@@For:
6960 wakaba 1.11 !=DIS:ForLatest
6961 wakaba 1.3 @@ForCheck:
6962     ManakaiDOM:Perl
6963     @@DOMMain:implementFeature: CoreFeature10
6964    
6965     ElementTypeBinding:
6966     @Name: ExceptionDef
6967     @ElementType:
6968     dis:ResourceDef
6969     @ShadowContent:
6970     @@rdf:type:
6971     ManakaiDOM:ExceptionClass
6972     @@AliasFor:
6973     @@@@:
6974     ::ForLatest
6975     @@@For:
6976     !=ForLatest
6977     @@ForCheck:
6978     ManakaiDOM:Perl
6979     @@DOMMain:implementFeature: CoreFeature10
6980    
6981     ElementTypeBinding:
6982     @Name: ClsQName
6983     @ElementType:
6984     dis:QName
6985    
6986     ElementTypeBinding:
6987     @Name: ClsISA
6988     @ElementType:
6989     dis:ISA
6990    
6991     ElementTypeBinding:
6992     @Name: Method
6993     @ElementType:
6994     dis:ResourceDef
6995     @ShadowContent:
6996     @@rdf:type:
6997     DISLang:Method
6998    
6999     ElementTypeBinding:
7000     @Name: IntMethod
7001     @ElementType:
7002     dis:ResourceDef
7003     @ShadowContent:
7004     @@rdf:type:
7005     DISLang:Method
7006     @@ManakaiDOM:isForInternal:1
7007    
7008     ElementTypeBinding:
7009     @Name: Attr
7010     @ElementType:
7011     dis:ResourceDef
7012     @ShadowContent:
7013     @@rdf:type:
7014     DISLang:Attribute
7015    
7016     ElementTypeBinding:
7017     @Name: Return
7018     @ElementType:
7019     dis:ResourceDef
7020     @ShadowContent:
7021     @@rdf:type:
7022     DISLang:MethodReturn
7023    
7024     ElementTypeBinding:
7025     @Name: Get
7026     @ElementType:
7027     dis:ResourceDef
7028     @ShadowContent:
7029     @@rdf:type:
7030     DISLang:AttributeGet
7031    
7032     ElementTypeBinding:
7033     @Name: Set
7034     @ElementType:
7035     dis:ResourceDef
7036     @ShadowContent:
7037     @@rdf:type:
7038     DISLang:AttributeSet
7039    
7040     ElementTypeBinding:
7041     @Name: Param
7042     @ElementType:
7043     dis:ResourceDef
7044     @ShadowContent:
7045     @@rdf:type:
7046     DISLang:MethodParameter
7047    
7048     ElementTypeBinding:
7049     @Name: PerlDef
7050     @ElementType:
7051     dis:Def
7052     @ShadowContent:
7053     @@ContentType:
7054     lang:Perl
7055    
7056     ElementTypeBinding:
7057     @Name: disDef
7058     @ElementType:
7059     dis:Def
7060     @ShadowContent:
7061     @@ContentType:
7062     lang:dis
7063    
7064     ElementTypeBinding:
7065     @Name: InCase
7066     @ElementType:
7067     dis:ResourceDef
7068     @ShadowContent:
7069     @@rdf:type:
7070     ManakaiDOM:InCase
7071    
7072     ElementTypeBinding:
7073     @Name: nullCase
7074     @ElementType:
7075     dis:ResourceDef
7076     @ShadowContent:
7077     @@rdf:type:
7078     ManakaiDOM:InCase
7079     @@Value:
7080     @@@is-null:1
7081    
7082     ElementTypeBinding:
7083     @Name: TrueCase
7084     @ElementType:
7085     dis:ResourceDef
7086     @ShadowContent:
7087     @@rdf:type:
7088     ManakaiDOM:InCase
7089     @@Value:true
7090     @@Type:
7091 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
7092 wakaba 1.3
7093    
7094     ElementTypeBinding:
7095     @Name: FalseCase
7096     @ElementType:
7097     dis:ResourceDef
7098     @ShadowContent:
7099     @@rdf:type:
7100     ManakaiDOM:InCase
7101     @@Value:false
7102     @@Type:
7103 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
7104 wakaba 1.3
7105     ElementTypeBinding:
7106     @Name: enDesc
7107     @ElementType:
7108     dis:Description
7109     @ShadowContent:
7110     @@lang:en
7111    
7112     ElementTypeBinding:
7113     @Name: PropDef
7114     @ElementType:
7115     dis:ResourceDef
7116     @ShadowContent:
7117     @@rdf:type:
7118     rdf:Property
7119     @@AliasFor:
7120     @@@@:
7121     ::ManakaiDOM:all
7122     @@@For:
7123     !=ManakaiDOM:all
7124    
7125     ElementTypeBinding:
7126     @Name: MethodRedef
7127     @ElementType:
7128     dis:ResourceDef
7129     @ShadowContent:
7130     @@rdf:type:
7131     DISLang:Method
7132     @@ManakaiDOM:isRedefining:1
7133    
7134     ElementTypeBinding:
7135     @Name: NamedParam
7136     @ElementType:
7137     dis:ResourceDef
7138     @ShadowContent:
7139     @@rdf:type:
7140     DISLang:MethodParameter
7141     @@DISPerl:isNamedParameter:1
7142    
7143     ElementTypeBinding:
7144     @Name: NodeParam
7145     @ElementType:
7146     dis:ResourceDef
7147     @ShadowContent:
7148     @@rdf:type:
7149     DISLang:MethodParameter
7150     @@DISPerl:isNamedParameter:1
7151     @@Name: node
7152     @@Type: ManakaiDISNode
7153     @@Description:
7154     @@@lang:en
7155     @@@@:
7156     The node in which the name has occurred. It is intended
7157     to be reported when an exception had been raised.
7158     @@ResourceDef:
7159     @@@rdf:type:
7160     ManakaiDOM:InCase
7161     @@@Value:
7162     @@@@is-null:1
7163     @@@Description:
7164     @@@@lang:en
7165     @@@@@:
7166     The source of the name is not a node.
7167    
7168     ElementTypeBinding:
7169     @Name: ForParam
7170     @ElementType:
7171     dis:ResourceDef
7172     @ShadowContent:
7173     @@rdf:type:
7174     DISLang:MethodParameter
7175     @@DISPerl:isNamedParameter:1
7176     @@Name: forArg
7177     @@Type: ForURI
7178     @@Description:
7179     @@@lang:en
7180     @@@@:
7181     The <QUOTE::for> URI reference.
7182     @@ResourceDef:
7183     @@@rdf:type:
7184     ManakaiDOM:InCase
7185     @@@Value:
7186     @@@@is-null:1
7187     @@@Description:
7188     @@@@lang:en
7189     @@@@@:
7190     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
7191    
7192     ElementTypeBinding:
7193     @Name: ForpParam
7194     @ElementType:
7195     dis:ResourceDef
7196     @ShadowContent:
7197     @@rdf:type:
7198     DISLang:MethodParameter
7199     @@DISPerl:isNamedParameter:1
7200     @@Name: forpArg
7201     @@Type: ForURIList
7202     @@Description:
7203     @@@lang:en
7204     @@@@:
7205     An array reference containing additional <QUOTE::for>
7206     constraints (<QUOTE::For+> list).
7207     @@ResourceDef:
7208     @@@rdf:type:
7209     ManakaiDOM:InCase
7210     @@@Value:
7211     @@@@is-null:1
7212     @@@Description:
7213     @@@@lang:en
7214     @@@@@:
7215     Equivalent to the empty array reference.
7216    
7217     ElementTypeBinding:
7218     @Name: MediaTypeParam
7219     @ElementType:
7220     dis:ResourceDef
7221     @ShadowContent:
7222     @@rdf:type:
7223     DISLang:MethodParameter
7224     @@DISPerl:isNamedParameter:1
7225     @@Name: mediaType
7226     @@Type: MediaTypeURI
7227     @@Description:
7228     @@@lang:en
7229     @@@@:
7230     The URI reference identifying a media type.
7231     @@ResourceDef:
7232     @@@rdf:type:
7233     ManakaiDOM:InCase
7234     @@@Value:
7235     @@@@is-null:1
7236     @@@Description:
7237     @@@@lang:en
7238     @@@@@:
7239     No media type specified.
7240    
7241     ElementTypeBinding:
7242     @Name: MediaTypeDefaultParam
7243     @ElementType:
7244     dis:ResourceDef
7245     @ShadowContent:
7246     @@rdf:type:
7247     DISLang:MethodParameter
7248     @@DISPerl:isNamedParameter:1
7249     @@Name: defaultMediaType
7250     @@Type: MediaTypeURI
7251     @@Description:
7252     @@@lang:en
7253     @@@@:
7254     The default media type, i.e. the type used when no explicit
7255     specification is not found in the source tree.
7256     @@ResourceDef:
7257     @@@rdf:type:
7258     ManakaiDOM:InCase
7259     @@@Value:
7260     @@@@is-null:1
7261     @@@Description:
7262     @@@@lang:en
7263     @@@@@:
7264     Defaulted to <Q::DOMMain:any>.
7265    
7266     ElementTypeBinding:
7267     @Name: RaiseException
7268     @ElementType:
7269     ManakaiDOM:raises
7270    
7271     ElementTypeBinding:
7272     @Name: UndeclaredPrefixException
7273     @ElementType:
7274     ManakaiDOM:raises
7275     @ShadowContent:
7276     @@@: UNDECLARED_NS_PREFIX_ERR
7277     @@Description:
7278     @@@lang:en
7279     @@@@:
7280     The implementation has encounted an undeclared namespace prefix.
7281    
7282     ElementTypeBinding:
7283     @Name: NoDBException
7284     @ElementType:
7285     ManakaiDOM:raises
7286     @ShadowContent:
7287     @@@: NO_DB_ASSOCIATED_ERR
7288     @@Description:
7289     @@@lang:en
7290     @@@@:
7291     No <QUOTE::dis> database is associated to this document.
7292    
7293     ElementTypeBinding:
7294     @Name: XConstGroupDef
7295     @ElementType:
7296     dis:ResourceDef
7297     @ShadowContent:
7298     @@rdf:type:
7299     ManakaiDOM:ConstGroup
7300     @@Type:
7301     DOMMain:unsigned-short::ManakaiDOM:all
7302     @@rdfs:subClassOf:
7303     DOMMain:unsigned-short::ManakaiDOM:all
7304    
7305     ElementTypeBinding:
7306     @Name: XConstDef
7307     @ElementType:
7308     dis:ResourceDef
7309     @ShadowContent:
7310     @@rdf:type:
7311     ManakaiDOM:Const
7312    
7313     ElementTypeBinding:
7314     @Name: XSubTypeDef
7315     @ElementType:
7316     dis:ResourceDef
7317     @ShadowContent:
7318     @@rdf:type:
7319     ManakaiDOM:ExceptionOrWarningSubType
7320    
7321     ElementTypeBinding:
7322     @Name: XParam
7323     @ElementType:
7324     ManakaiDOM:exceptionOrWarningParameter
7325    
7326     ElementTypeBinding:
7327     @Name: XParamDef
7328     @ElementType:
7329     dis:ResourceDef
7330     @ShadowContent:
7331     @@rdf:type:
7332     DOMMain:XWParameter
7333 wakaba 1.12 @@For:
7334     =ManakaiDOM:all
7335 wakaba 1.3
7336     ElementTypeBinding:
7337     @Name: enMufDef
7338     @ElementType:
7339     dis:Def
7340     @ShadowContent:
7341     @@ContentType:
7342     lang:muf
7343     @@lang:en
7344    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24