/[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.21 - (hide annotations) (download)
Wed Apr 27 12:32:39 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.20: +204 -18 lines
bin/cdis2pm.pl: Overloads 'bool' if some other operator is overloaded; lib/Message/Util/DIS.dis: Outputting of contants and exception codes implemented

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14 wakaba 1.14 This module provides an object model for <QUOTE::dis> document format.
15 wakaba 1.1
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24 wakaba 1.19 manakai <CODE::lib/manakai/dis.pl> and <CODE::bin/cdis2pm.pl>
25 wakaba 1.1 @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.21 $Date: 2005/04/27 06:24:47 $
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 wakaba 1.19 @@@nullCase:
1658     @@@@enDesc:
1659     This node itself is used.
1660 wakaba 1.18 @@Param:
1661     @@@Name: disDatabase
1662     @@@Type: ManakaiDISDatabase
1663     @@@enDesc:
1664     The <QUOTE::dis> database against which a value is evaluated.
1665     @@ForParam:
1666     @@ForpParam:
1667     @@NamedParam:
1668     @@@Name:dataTypeURI
1669     @@@Type:
1670     ResourceURI
1671     @@@enDesc:
1672     The URI reference of a data type. It is used to convert
1673     untyped value and to define default value if <P::useDefaultValue>
1674     is set to <DOM::true>.
1675     @@@nullCase:
1676     @@@@enDesc:
1677     No data type. If the value is untyped, it is treated
1678     as if <Q::DISCore:String>.
1679     @@NamedParam:
1680     @@@Name:useDefaultValue
1681     @@@Type:
1682     DOMMain:boolean::ManakaiDOM:all
1683     @@@enDesc:
1684     Whether some default value should be provided if possible or not.
1685     @@Type:
1686     MPLCodeFragment
1687     @@Return:
1688     @@@enDesc:
1689     Perl code fragment object for value attribute.
1690     @@@nullCase:
1691     @@@@enDesc:
1692     There is no <P::attrURI> attribute.
1693     @@@UndeclaredPrefixException:
1694     @@@RaiseException:
1695     @@@@@:NO_PERL_CODE_IMPL_ERR
1696     @@@@enDesc:
1697     There is no implementation that implements
1698     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
1699     @@@PerlDef:
1700     __DEEP{
1701     my $dataType;
1702 wakaba 1.19 my $vnode = defined $attrURI
1703     ? $self-><M::ManakaiDISElement.disGetAttribute>
1704 wakaba 1.18 ($attrURI,
1705     for_arg => $forArg,
1706 wakaba 1.19 forp_arg => $forpArg)
1707     : $self;
1708 wakaba 1.18 my $plimpl = $self-><AG::ManakaiDISElement.plImplementation>;
1709     if ($vnode) {
1710     unless ($plimpl) {
1711     __UNDEEP{__EXCEPTION{NO_PERL_CODE_IMPL_ERR}__}__;
1712     }
1713     my $isnull = $vnode-><M::ManakaiDISElement.disGetAttribute>
1714     (<Q::dis:is-null>,
1715     for_arg => $forArg,
1716     forp_arg => $forpArg);
1717     if ($isnull and $isnull-><M::SWCFGNode.value>) {
1718     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('null');
1719     } else {
1720     my $vnode_type_uri = $vnode-><M::ManakaiDISElement.mediaTypeURI>;
1721     my $vnode_value = $vnode-><M::SWCFGNode.value>;
1722     if ($vnode_type_uri) {
1723     my $vnode_type =$disDatabase-><M::ManakaiDISDatabase.getResource>
1724     ($vnode_type_uri);
1725     if ($vnode_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1726     (<Q::dis:Boolean>)) {
1727     $r = $plimpl-><M::MPLImpl.createPerlAtom>
1728     ($vnode_value ? true : false);
1729     } elsif ($vnode_type-><M::ManakaiDISResourceDefinition
1730     .isSubsetOfURI>
1731     (<Q::dis:TypeQName>)) {
1732     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1733 wakaba 1.19 ($vnode-><M::ManakaiDISElement
1734 wakaba 1.18 .qnameToURI> ($vnode_value,
1735     node => $vnode));
1736     } else { ## DISCore:String or some
1737     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1738     ($vnode_value);
1739     }
1740     } elsif ($dataTypeURI) {
1741 wakaba 1.21 $dataType ||= $disDatabase-><M::ManakaiDISDatabase.getResource>
1742     ($dataTypeURI);
1743     if ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1744     (<Q::DISIDL:AnyRealNumber>)) {
1745     $r = $plimpl-><M::MPLImpl.createPerlAtom> (0 + $vnode_value);
1746     } else { ## DOMMain:DOMString or some
1747 wakaba 1.18 $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>
1748     ($vnode_value);
1749 wakaba 1.21 }
1750 wakaba 1.18 } else { ## Untyped
1751     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral>($vnode_value);
1752     }
1753     }
1754     } # has value
1755    
1756     if (not $r and $useDefaultValue) {
1757     $dataType ||= $disDatabase-><M::ManakaiDISDatabase.getResource>
1758     ($dataTypeURI);
1759     if ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1760     (<Q::DISLang:String>)) {
1761     $r = $plimpl-><M::MPLImpl.createPerlStringLiteral> ('');
1762     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1763     (<Q::DOMMain:boolean>) or
1764     $dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1765 wakaba 1.21 (<Q::DISIDL:AnyRealNumber>)) {
1766 wakaba 1.18 $r = $plimpl-><M::MPLImpl.createPerlAtom> ('0');
1767     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1768     (<Q::Perl:ARRAY>)) {
1769     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('[]');
1770     } elsif ($dataType-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
1771     (<Q::Perl:hash>)) {
1772     $r = $plimpl-><M::MPLImpl.createPerlAtom> ('{}');
1773     }
1774     }
1775     }__;
1776 wakaba 1.19
1777     @Method:
1778     @@Name:plCodeFragment
1779     @@enDesc:
1780     Converts <Q::lang:dis> into Perl code.
1781     @@Param:
1782     @@@Name:disResource
1783     @@@Type:ManakaiDISResourceDefinition
1784     @@@enDesc:
1785     A <QUOTE::dis> resource with which code is evaluated.
1786     @@ForParam:
1787     @@ForpParam:
1788     @@NamedParam:
1789     @@@Name:containsStatements
1790     @@@Type:
1791     DOMMain:boolean::ManakaiDOM:all
1792     @@@enDesc:
1793     Whether the code is block-level or inline-level.
1794     @@Return:
1795     @@@Type: MPLCodeFragment
1796     @@@enDesc:
1797     Perl code converted from this node.
1798     @@@disPerlException:
1799     @@@PerlDef:
1800     __DEEP{
1801     my $plimpl = $self-><AG::ManakaiDISElement.plImplementation>;
1802     my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1803     .expandedURI>;
1804     if ($et eq <Q::dis:Def>) {
1805     my $value = $self-><M::SWCFGNode.value>;
1806     if (defined $value) {
1807     __UNDEEP{__EXCEPTION{DISPERL_NO_VALUE_ALLOWED_ERR::
1808     DIS:sourceNode => {$self},
1809     DIS:elementType => {$et},
1810     }__}__;
1811     }
1812     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
1813     for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1814     (for_arg => $forArg, forp_arg => $forpArg)}) {
1815     my $ccode = $c-><M::ManakaiDISElement.plCodeFragment>
1816     ($disResource,
1817     for_arg => $forArg, forp_arg => $forpArg);
1818     $r-><M::PLBlockCon.appendCodeFragment> ($ccode) if $ccode;
1819     }
1820     } elsif ({
1821     <Q::DISLang:constValue> => true,
1822     <Q::DISPerl:cloneCode> => true,
1823     }->{$et}) {
1824     my ($qname, $const_name, $on) = split /\s*\.\s*/,
1825     $self-><M::SWCFGNode.value>, 3;
1826     my $uri = $self-><M::ManakaiDISElement.tfqnamesToURI>
1827     ($qname,
1828     $disResource->
1829     <AG::ManakaiDISResourceDefinition.uri>,
1830     $forArg, node => $self);
1831     my $const;
1832     if (defined $const_name) {
1833     my $owner = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
1834     ($uri);
1835     $owner-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1836     if ($et eq <Q::DISLang:constValue>) {
1837     $const = $owner-><M::ManakaiDISResourceDefinition
1838     .getConstResourceByName> ($const_name);
1839     unless (defined $const) {
1840     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1841     DIS:localName => {$const_name},
1842     DIS:sourceNode => {$self},
1843     DIS:elementType => {$et},
1844     DIS:expectedType => {<Q::ManakaiDOM:Const>},
1845     }__}__;
1846     }
1847     } else {
1848     $const = $owner-><M::ManakaiDISResourceDefinition
1849     .getChildResourceByNameAndType>
1850     ($const_name, <Q::DISLang:AnyMethod>);
1851     unless (defined $const) {
1852     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1853     DIS:localName => {$const_name},
1854     DIS:sourceNode => {$self},
1855     DIS:elementType => {$et},
1856     DIS:expectedType => {<Q::DISLang:AnyMethod>},
1857     }__}__;
1858     }
1859     }
1860     } else {
1861     $const = $disResource->{db}-><M::ManakaiDISDatabase.getResource>
1862     ($uri);
1863     }
1864     if ($const-><M::ManakaiDISResourceDefinition.isTypeURI>
1865     (<Q::ManakaiDOM:Const>)) {
1866     $const-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1867    
1868     my $data_type = $const-><AG::ManakaiDISResourceDefinition
1869     .disActualDataTypeResource>;
1870     my $val = $const->{src}-><M::ManakaiDISElement
1871     .plValueCodeFragment>
1872     (<Q::dis:Value>, $disResource->{db},
1873     for_arg => $forArg,
1874     forp_arg => $forpArg,
1875     data_type_uri => $data_type
1876     -><AG::ManakaiDISResourceDefinition.uri>);
1877     unless (defined $val) {
1878     __UNDEEP{__EXCEPTION{NO_CONST_VALUE_ERR::
1879     DIS:uri => {$const->{uri}},
1880     DIS:localName => {$const->{localName}},
1881     DIS:sourceNode => {$const->{src}},
1882     DIS:elementType => {$et},
1883     }__}__;
1884     }
1885    
1886     if ($containsStatements) {
1887     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
1888     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
1889     ('$', null, 'r');
1890     $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
1891     } else {
1892     $r = $val;
1893     }
1894     } elsif ($const-><M::ManakaiDISResourceDefinition.isTypeURI>
1895     (<Q::DISLang:AnyMethod>)) {
1896     my $ret = $self-><M::ManakaiDISResourceDefinition
1897     .getChildResourceByType>
1898     ($const-><M::ManakaiDISResourceDefinition
1899     .isTypeURI> (<Q::DISLang:Method>)
1900     ? <Q::DISLang:MethodReturn>
1901     : ($on and $on eq 'set')
1902     ? <Q::DISLang:AttributeSet>
1903     : <Q::DISLang:AttributeGet>);
1904     unless ($ret) {
1905     __UNDEEP{
1906     if ($const-><M::ManakaiDISResourceDefinition
1907     .isTypeURI> (<Q::DISLang:Method>)) {
1908     __EXCEPTION{NO_METHOD_RETURN_ERR::
1909     DIS:errResource => {$const},
1910     DIS:sourceNode => {$const->{src}},
1911     DIS:elementType => {$et},
1912     }__;
1913     } elsif ($on and $on eq 'set') {
1914     __EXCEPTION{NO_ATTR_SET_ERR::
1915     DIS:errResource => {$const},
1916     DIS:sourceNode => {$const->{src}},
1917     DIS:elementType => {$et},
1918     }__;
1919     } else {
1920     __EXCEPTION{NO_ATTR_GET_ERR::
1921     DIS:errResource => {$const},
1922     DIS:sourceNode => {$const->{src}},
1923     DIS:elementType => {$et},
1924     }__;
1925     }
1926     }__; # UNDEEP
1927     }
1928     $r = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
1929     } else {
1930     if ($et eq <Q::DISLang:constValue>) {
1931     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1932     DIS:uri => {$const->{uri}},
1933     DIS:localName => {$const->{localName}},
1934     DIS:sourceNode => {$self->{src}},
1935     DIS:expectedType => {<Q::ManakaiDOM:Const>},
1936     }__}__;
1937     } else { # DISPerl:cloneCode
1938     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
1939     DIS:uri => {$const->{uri}},
1940     DIS:localName => {$const->{localName}},
1941     DIS:sourceNode => {$self->{src}},
1942     DIS:expectedType => {<Q::DISLang:AnyMethod>},
1943     }__}__;
1944     }
1945     }
1946     } elsif ($et eq <Q::DISLang:value>) {
1947     my $val = $self-><M::ManakaiDISElement
1948     .plValueCodeFragment>
1949     (null, $disResource->{db},
1950     for_arg => $forArg,
1951     forp_arg => $forpArg);
1952     if ($containsStatements) {
1953     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
1954     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
1955     ('$', null, 'r');
1956     $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
1957     } else {
1958     $r = $val;
1959     }
1960     } elsif ({
1961     <Q::dis:GetProp> => true,
1962     <Q::dis:GetPropNode> => true,
1963     <Q::swcfg21:GetPropNode> => true,
1964     }->{$et}) {
1965     my $prop_uri = $self-><AG::ManakaiDISElement.qnameValueURI>;
1966     $disResource->{db}
1967     -><M::ManakaiDISDatabase.getResource> ($prop_uri)
1968     -><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1969     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
1970     my $val = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
1971     $val-><M::PLInCon.appendCode> ('$self->{node}->{');
1972     $val-><M::PLAnyCon.appendStringLiteral> ($prop_uri);
1973     $val-><M::PLInCon.appendCode> ('}');
1974     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
1975     ('$', null, 'r');
1976     $r-><M::PLAnyCon.appendNewAssignment> ($rvar => $val);
1977    
1978     if ({<Q::dis:GetPropNode> => true,
1979     <Q::swcfg21:GetPropNode> => true}->{$et}) {
1980     my $q = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
1981     $q-><M::PLBlockCon.appendCodeFragment> ($r);
1982     $q-><M::PLBlockCon.appendNewIf>
1983     ($plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
1984     ('defined $r'),
1985     my $qt = $plimpl-><M::MPLImpl.createPerlBlockContainer>);
1986     $qt-><M::PLBlockCon.appendStatement>
1987     -><M::PLAnyCon.appendNewAssignment>
1988     ($rvar->clone => my $qtr = $plimpl-><M::MPLImpl
1989     .createPerlInlineContainer>);
1990     my $cls = $disResource->{db}-><M::ManakaiDISDatabase
1991     .getResource> ({
1992     <Q::dis:GetPropNode> => <Q::DOMCore:ManakaiDOMNode>,
1993     <Q::swcfg21:GetPropNode> =>
1994     <Q::swcfg21:ManakaiSWCFGNode>,
1995     }->{$et}, for_arg => $forArg);
1996     $cls-><AS::ManakaiDISResourceDefinition.isReferred> ($self);
1997     $qtr-><M::PLInCon.appendCode>
1998     ($cls-><AG::ManakaiDISResourceDefinition
1999     .plFullyQualifiedName> . q[->_get_node_reference ($r)]);
2000     $r = $q;
2001     }
2002     } elsif ($et eq <Q::dis:SetProp>) {
2003     my $prop_uri = $self-><AG::ManakaiDISElement.qnameValueURI>;
2004     $disResource->{db}
2005     -><M::ManakaiDISDatabase.getResource> ($prop_uri)
2006     -><AS::ManakaiDISResourceDefinition.isReferred> ($self);
2007     $r = $plimpl-><M::MPLImpl.createPerlStatement>;
2008     my $val = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
2009     $val-><M::PLInCon.appendCode> ('$self->{node}->{');
2010     $val-><M::PLAnyCon.appendStringLiteral> ($prop_uri);
2011     $val-><M::PLInCon.appendCode> ('}');
2012     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
2013     ('$', null, 'given');
2014     $r-><M::PLAnyCon.appendNewAssignment> ($val => $rvar);
2015     my $chk = $self-><M::ManakaiDISElement.disGetAttribute>
2016     (<Q::dis:CheckReadOnly>);
2017     if ($chk and $chk-><M::SWCFGNode.value>) {
2018     my $q = $plimpl-><M::MPLImpl.createPerlIf>;
2019     (my $qc = $plimpl-><M::MPLImpl.createPerlInlineContainer>,
2020     my $qt = $plimpl-><M::MPLImpl.createPerlBlockContainer>);
2021     $qc-><M::PLInCon.appendCode> ('$self->{node}->{');
2022     $qc-><M::PLAnyCon.appendStringLiteral> (<Q::DOMCore:read-only>);
2023     $qc-><M::PLInCon.appendCode> ('}');
2024    
2025     my $for_uri = $disResource-><M::ManakaiDISDatabase.getFor>
2026     ($forArg)-><M::ManakaiDISForDefinition.isaURI>
2027     (<Q::ManakaiDOM:ManakaiDOM1>)
2028     ? $forArg : <Q::ManakaiDOM:ManakaiDOMLatest>;
2029     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
2030     (<Q::DOMCore:DOMException>,
2031     for_arg => $for_uri);
2032     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
2033     (<Q::DOMCore:NO_MODIFICATION_ALLOWED_ERR>,
2034     for_arg => $for_uri);
2035     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
2036     (<Q::MDOMX:NOMOD_THIS>,
2037     for_arg => $for_uri);
2038     $_-><AS::ManakaiDISResourceDefinition.isReferred>
2039     ($self) for $cls, $const, $subtype;
2040     my $context_param = $disResource-><M::ManakaiDISResourceDefinition
2041     .plGetContextParameter>;
2042     $disResource-><M::ManakaiDISResourceDefinition
2043     .plAppendThrow>
2044     ($qt, $cls, $const, $subtype,
2045     {%$context_param});
2046     $r = $q;
2047     } # Read-only checking
2048     } elsif ($et eq <Q::DOMMain:raiseException>) {
2049     my ($cls, $const, $subtype)
2050     = @{$disResource->{db}-><M::ManakaiDISDatabase.xcrefToResource>
2051     ($self-><M::SWCFGNode.value>,
2052     $self,
2053     node => $self,
2054     for_arg => $forArg)};
2055     my $context_param = $disResource-><M::ManakaiDISResourceDefinition
2056     .plGetContextParameter>;
2057     $disResource-><M::ManakaiDISResourceDefinition
2058     .plAppendThrow>
2059     ($r = $plimpl-><M::MPLImpl.createPerlBlockContainer>,
2060     $cls, $const, $subtype,
2061     {%$context_param});
2062     } elsif ({
2063     <Q::dis:ContentType> => true,
2064     <Q::dis:For> => true, <Q::dis:ForCheck> => true,
2065     <Q::dis:ImplNote> => true,
2066     <Q::DISLang:nop> => true,
2067     }->{$et}) {
2068     #
2069     } else {
2070     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
2071     DIS:sourceNode => {$self},
2072     DIS:elementType => {$et},
2073     }__}__;
2074     }
2075     }__; # DEEP
2076 wakaba 1.1 ##DISElement
2077    
2078 wakaba 1.19 ElementTypeBinding:
2079     @Name: disPerlException
2080     @ElementType:
2081     ManakaiDOM:raises
2082     @ShadowContent:
2083     @@@: DISPERL_NO_VALUE_ALLOWED_ERR
2084     @@Description:
2085     @@@lang:en
2086     @@@@:
2087     An element value is specified where it is not allowed.
2088     @ShadowSibling:
2089     @@ManakaiDOM:raises:
2090     @@@@: RESOURCE_NOT_DEFINED_ERR
2091     @@@Description:
2092     @@@@lang:en
2093     @@@@@:
2094     An undefined resource is referred or a referred resource
2095     is defined but have different type than the one expected.
2096     @@ManakaiDOM:raises:
2097     @@@@: NO_CONST_VALUE_ERR
2098     @@@Description:
2099     @@@@lang:en
2100     @@@@@:
2101     A constant value definition does not have its <Q::dis:Value>
2102     attribute.
2103     @@ManakaiDOM:raises:
2104     @@@@: NO_METHOD_RETURN_ERR
2105     @@@Description:
2106     @@@@lang:en
2107     @@@@@:
2108     A method definition does not have a <Q::DISLang:MethodReturn>
2109     child resource.
2110     @@ManakaiDOM:raises:
2111     @@@@: NO_ATTR_GET_ERR
2112     @@@Description:
2113     @@@@lang:en
2114     @@@@@:
2115     An attribute definition does not have a <Q::DISLang:AttributeGet>
2116     child resource.
2117     @@ManakaiDOM:raises:
2118     @@@@: NO_ATTR_SET_ERR
2119     @@@Description:
2120     @@@@lang:en
2121     @@@@@:
2122     An attribute setter is referred but the attribute definition
2123     does not have <Q::DISLang:AttributeSet> child resource.
2124     @@ManakaiDOM:raises:
2125     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
2126     @@@Description:
2127     @@@@lang:en
2128     @@@@@:
2129     An unsupported type of element has appeared.
2130    
2131    
2132 wakaba 1.1 ClsDef:
2133 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
2134     @ClsISA: ManakaiDISElement
2135     @enDesc:
2136     The <Q::dis:Module> elements.
2137    
2138     @Attr:
2139     @@Name: requireElement
2140     @@enDesc:
2141     The <Q::dis:Require> child element. The element is
2142     newly created if not exist.
2143     @@Type: ManakaiDISElement
2144     @@Get:
2145     @@@PerlDef:
2146     __DEEP{
2147     $r = $self-><M::swcfg21:SWCFGNode
2148     ::swcfg21:ForLatest.getAttributeNS>
2149     (<Q::dis:>, 'Require', make_new_node => true);
2150     }__;
2151    
2152     @Attr:
2153     @@Name: defaultForURI
2154     @@enDesc:
2155     The value of <Q::dis:DefaultFor> attribute.
2156     @@Type: ForURI
2157     @@Get:
2158     @@@enDesc:
2159     The value of <Q::dis:DefaultFor> child element. If missing,
2160     <Q::ManakaiDOM:all> is returned.
2161     @@@PerlDef:
2162     __DEEP{
2163     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2164     .getAttributeNS>
2165     (<Q::dis:>, 'DefaultFor');
2166     if ($df) {
2167     $r = $df-><AG::ManakaiDISElement.qnameValueURI>
2168     || <Q::ManakaiDOM:all>;
2169     } else {
2170     $r = <Q::ManakaiDOM:all>;
2171     }
2172     }__;
2173     @@Set:
2174     @@@PerlDef:
2175     __DEEP{
2176     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
2177     (<Q::dis:>, 'DefaultFor' => $given);
2178     }__;
2179 wakaba 1.7
2180     @Attr:
2181     @@Name: definingNamespaceURI
2182     @@enDesc:
2183     The value of <Q::dis:NamespaceURI> attribute, i.e.
2184     the URI reference of the namespace that this module primary
2185     defines.
2186     \
2187     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
2188     \
2189     }
2190     @@Type: AnyURI
2191     @@Get:
2192     @@@PerlDef:
2193     __DEEP{
2194     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2195     .getAttributeNS>
2196     (<Q::dis:>, 'Namespace');
2197     if ($df) {
2198 wakaba 1.14 $r = $df-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2199 wakaba 1.7 } else {
2200     __ASSERT{DISPerl:invariant::
2201     msg => {qq["dis:Namespace" attribute not found]},
2202     }__;
2203     }
2204     }__;
2205     @@Set:
2206     @@@PerlDef:
2207     __DEEP{
2208     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
2209     (<Q::dis:>, 'Namespace' => $given);
2210     }__;
2211 wakaba 1.4 ##DISModuleElement
2212    
2213     ClsDef:
2214 wakaba 1.2 @ClsQName: ManakaiDISElementList
2215     @enDesc:
2216     @@lang:en
2217     @@@:
2218     Lists of elements.
2219     \
2220     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
2221     later changes to the tree does not affect this type of objects.
2222     \
2223     }
2224     ##DISElementList
2225    
2226     ClsDef:
2227 wakaba 1.1 @ClsQName: ManakaiDISComment
2228 wakaba 1.7 @ClsISA: ManakaiDISNode
2229 wakaba 1.1 @ClsISA:
2230 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
2231 wakaba 1.1 @Description:
2232     @@lang:en
2233     @@@:
2234     <QUOTE::dis> comment node objects.
2235     ##DISComment
2236    
2237     ClsDef:
2238     @ClsQName: ManakaiDISDocumentFragment
2239 wakaba 1.7 @ClsISA: ManakaiDISNode
2240 wakaba 1.1 @ClsISA:
2241 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
2242 wakaba 1.1 @Description:
2243     @@lang:en
2244     @@@:
2245     <QUOTE::dis> document fragment node objects.
2246     ##DISDocumentFragment
2247    
2248     ClsDef:
2249     @ClsQName: ManakaiDISDocument
2250 wakaba 1.7 @ClsISA: ManakaiDISNode
2251 wakaba 1.1 @ClsISA:
2252 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
2253 wakaba 1.1 @Description:
2254     @@lang:en
2255     @@@:
2256     <QUOTE::dis> document node objects.
2257 wakaba 1.2
2258     @Attr:
2259 wakaba 1.4 @@Name: moduleElement
2260     @@enDesc:
2261     The <Q::dis:Module> element in this document. The element is
2262     newly created if not exist.
2263     @@Type: ManakaiDISModuleElement
2264     @@Get:
2265     @@@PerlDef:
2266     __DEEP{
2267     $r = $self-><M::swcfg21:SWCFGNode
2268     ::swcfg21:ForLatest.getAttributeNS>
2269     (<Q::dis:>, 'Module', make_new_node => true);
2270     }__;
2271     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
2272    
2273     @Attr:
2274 wakaba 1.2 @@Name: disDatabase
2275     @@enDesc:
2276     Associated <QUOTE::dis> database.
2277    
2278     @@Type: ManakaiDISDatabase
2279     @@Get:
2280     @@@NoDBException:
2281     @@@PerlDef:
2282     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
2283 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
2284 wakaba 1.2 } else {
2285     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
2286     }
2287     @@Set:
2288     @@@PerlDef:
2289     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
2290     require Scalar::Util;
2291     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
2292 wakaba 1.5
2293     @Method:
2294     @@Name: disChildElements
2295     @@enDesc:
2296 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
2297 wakaba 1.5 @@ForParam:
2298     @@ForpParam:
2299     @@Return:
2300     @@@Type: ManakaiDISElementList
2301     @@@enDesc:
2302     The current snapshot of child nodes.
2303     @@@PerlDef:
2304     $r = bless [], <ClassName::ManakaiDISElementList>;
2305     __DEEP{
2306     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2307     .childNodes>}) {
2308     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2309     .nodeType> eq '#element';
2310     my $dn = $cn->{<Q::TreeCore:node>}
2311     -><M::ManakaiDOM:ManakaiDOMNodeObject
2312     ::ManakaiDOM:Perl.newReference>
2313     (<ClassName::ManakaiDISElement>);
2314     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
2315     push @$r, $dn;
2316     }
2317     }__;
2318 wakaba 1.10
2319     @Method:
2320     @@Name: disAllChildElements
2321     @@enDesc:
2322     A list of child elements, without <QUOTE::for> checks.
2323     @@Return:
2324     @@@Type: ManakaiDISElementList
2325     @@@enDesc:
2326     The current snapshot of child nodes.
2327     @@@PerlDef:
2328     $r = bless [], <ClassName::ManakaiDISElementList>;
2329     __DEEP{
2330     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2331     .childNodes>}) {
2332     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2333     .nodeType> eq '#element';
2334     my $dn = $cn->{<Q::TreeCore:node>}
2335     -><M::ManakaiDOM:ManakaiDOMNodeObject
2336     ::ManakaiDOM:Perl.newReference>
2337     (<ClassName::ManakaiDISElement>);
2338     push @$r, $dn;
2339     }
2340     }__;
2341 wakaba 1.1 ##DISDocument
2342 wakaba 1.2
2343     PropDef:
2344     @QName: db
2345     @enDesc:
2346     Associated <QUOTE::dis> database.
2347     @rdfs:domain: ManakaiDISDocument
2348     @rdfs:range: ManakaiDISDatabase
2349    
2350     ## -- Definition object database
2351    
2352     ClsDef:
2353     @ClsQName: ManakaiDISDatabase
2354     @enDesc:
2355     Resource database created from <QUOTE::dis> source data.
2356 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2357 wakaba 1.2
2358     @Method:
2359     @@Name: getModule
2360     @@Description:
2361     @@@lang:en
2362     @@@@:
2363     Returns a <QUOTE::dis> module definition.
2364     @@Param:
2365 wakaba 1.9 @@@Name: moduleURI
2366 wakaba 1.2 @@@Type: ModuleURI
2367     @@@Description:
2368     @@@@lang:en
2369     @@@@@:
2370     A <QUOTE::dis> module URI reference.
2371 wakaba 1.9 @@ForParam:
2372 wakaba 1.2 @@Return:
2373     @@@Type: ManakaiDISModuleDefinition
2374     @@@Description:
2375     @@@@lang:en
2376     @@@@@:
2377     The module definition.
2378     @@@PerlDef:
2379 wakaba 1.9 my $modURI;
2380     if (defined $forArg) {
2381     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
2382     $uri => $modURI}__;
2383     } else {
2384     $modURI = $moduleURI;
2385     }
2386 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
2387     $r = $self->{modDef}->{$modURI};
2388     } else {
2389     $r = $self->{modDef}->{$modURI}
2390     = bless {
2391     uri => $modURI,
2392     db => $self,
2393     for => <Q::ManakaiDOM:all>,
2394     forp => [],
2395     }, <ClassName::ManakaiDISModuleDefinition>;
2396     require Scalar::Util;
2397     Scalar::Util::weaken ($r->{db});
2398     }
2399    
2400     @Method:
2401     @@Name: getFor
2402     @@Description:
2403     @@@lang:en
2404     @@@@:
2405     Returns a <QUOTE::for> definition object.
2406     @@Param:
2407     @@@Name: forURI
2408     @@@Type: ForURI
2409     @@@Description:
2410     @@@@lang:en
2411     @@@@@:
2412     A <QUOTE::for> URI reference.
2413     @@@InCase:
2414     @@@@Value:
2415     @@@@@is-null:1
2416     @@@@Description:
2417     @@@@@lang:en
2418     @@@@@@:
2419     Defaulted to <Q::ManakaiDOM:all>.
2420     @@Return:
2421     @@@Type: ManakaiDISForDefinition
2422     @@@PerlDef:
2423     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
2424     if (defined $self->{forDef}->{$forURI}) {
2425     $r = $self->{forDef}->{$forURI};
2426     } else {
2427     $r = $self->{forDef}->{$forURI}
2428     = bless {
2429     uri => $forURI,
2430     isa => {<Q::ManakaiDOM:all> => true},
2431     revISA => {},
2432     db => $self,
2433     }, <ClassName::ManakaiDISForDefinition>;
2434     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
2435     require Scalar::Util;
2436     Scalar::Util::weaken ($r->{db});
2437     }
2438    
2439     @Method:
2440     @@Name: getResource
2441     @@Description:
2442     @@@lang:en
2443     @@@@:
2444     Returns a <QUOTE::dis> resource definition.
2445     @@Param:
2446 wakaba 1.9 @@@Name: resourceURI
2447 wakaba 1.2 @@@Type: ResourceURI
2448     @@@Description:
2449     @@@@lang:en
2450     @@@@@:
2451     A <QUOTE::dis> resource URI reference.
2452 wakaba 1.3 @@@nullCase:
2453 wakaba 1.2 @@@@Description:
2454     @@@@@lang:en
2455     @@@@@@:
2456     Defaulted to <Q::DOMMain:any>.
2457 wakaba 1.9 @@ForParam:
2458 wakaba 1.2 @@Return:
2459     @@@Type: ManakaiDISResourceDefinition
2460     @@@Description:
2461     @@@@lang:en
2462     @@@@@:
2463     The resource definition.
2464     @@@PerlDef:
2465 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
2466     my $resURI;
2467     if (defined $forArg) {
2468     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
2469     $uri => $resURI}__;
2470     } else {
2471     $resURI = $resourceURI;
2472     }
2473 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
2474     $r = $self->{resDef}->{$resURI};
2475     } else {
2476     $r = $self->{resDef}->{$resURI}
2477     = bless {
2478     uri => $resURI,
2479 wakaba 1.6 aliasURI => {$resURI => true},
2480 wakaba 1.2 subOf => {},
2481     supOf => {},
2482     db => $self,
2483     for => <Q::ManakaiDOM:all>,
2484     forp => [],
2485 wakaba 1.9 seq => -1,
2486 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
2487     require Scalar::Util;
2488     Scalar::Util::weaken ($r->{db});
2489     }
2490 wakaba 1.3
2491     @Method:
2492     @@Name: getSourceFile
2493     @@enDesc:
2494     Gets <QUOTE::dis> source document.
2495     @@Param:
2496     @@@Name: fileName
2497     @@@Type: FileURI
2498     @@@enDesc:
2499     A URI reference identifying a file.
2500     @@Return:
2501     @@@Type: ManakaiDISDocument
2502     @@@enDesc:
2503     The <QUOTE::dis> source document.
2504     @@@nullCase:
2505     @@@@enDesc:
2506     No document associated with that <P::fileName>.
2507     @@@PerlDef:
2508     $r = $self->{<Q::sourceFile>}->{$fileName};
2509     @Method:
2510     @@Name: setSourceFile
2511     @@enDesc:
2512     Puts <QUOTE::dis> source document object.
2513     @@Param:
2514     @@@Name: fileName
2515     @@@Type: FileURI
2516     @@@enDesc:
2517 wakaba 1.4 A URI reference identifying a file. If there is already a
2518 wakaba 1.3 source document, then the association has been updated.
2519     @@Param:
2520     @@@Name: doc
2521     @@@Type: ManakaiDISDocument
2522     @@@enDesc:
2523     The document object to set.
2524     @@Return:
2525     @@@PerlDef:
2526     $self->{<Q::sourceFile>}->{$fileName} = $doc;
2527 wakaba 1.4
2528     @Method:
2529     @@Name: loadModule
2530     @@enDesc:
2531     Loads definitions from a <QUOTE::dis> document.
2532     @@Param:
2533     @@@Name: doc
2534     @@@Type:ManakaiDISDocument
2535     @@@enDesc:
2536     The source <QUOTE::dis> document object. Its
2537     <A::ManakaiDISDocument.disDatabase> must be this database.
2538     @@Param:
2539     @@@Name: resolver
2540     @@@Type: DISModuleResolver
2541     @@@enDesc:
2542     The resolver to convert module name into <QUOTE::dis> document object.
2543     @@ForParam:
2544     @@Return:
2545     @@@RaiseException:
2546     @@@@@: NO_MODULE_QNAME_ERR
2547     @@@@enDesc:
2548     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2549     @@@RaiseException:
2550     @@@@@: UNABLE_TO_GET_MODULE_ERR
2551     @@@@enDesc:
2552     The implementation is unable to get a module source.
2553 wakaba 1.5 @@@ForDefDupException:
2554     @@@ForDefNoQNameException:
2555     @@@ResDefDupException:
2556     @@@ElementNotAllowedException:
2557 wakaba 1.7 @@@RaiseException:
2558     @@@@@:NO_REQUIRED_ATTR_ERR
2559     @@@@enDesc:
2560     The <Q::dis:Module> element does not have
2561     <Q::dis:Namespace> attribute.
2562 wakaba 1.4 @@@PerlDef:
2563     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2564     if ref $resolver eq 'CODE';
2565     ## -- Module Name, URI
2566     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2567     my $mod_node;
2568     my $mod_name_node;
2569     __DEEP{
2570     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2571     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2572     ::swcfg21:ForLatest.getAttributeNS>
2573     (<Q::dis:>, 'QName');
2574     unless ($mod_name_node) {
2575     __UNDEEP{
2576     __EXCEPTION{NO_MODULE_QNAME_ERR::
2577     DIS:sourceNode => {$mod_node},
2578     }__;
2579     }__;
2580     }
2581 wakaba 1.5 my $mod_name_uri = $mod_name_node
2582     -><AG::ManakaiDISElement.qnameValueURI>;
2583 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2584     ($mod_name_uri, for_arg => $forArg);
2585 wakaba 1.4
2586 wakaba 1.14 unless ($mod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2587 wakaba 1.4 ## -- Initializes Module Definition Object
2588     $mod->{nameURI} = $mod_name_uri;
2589     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2590     .qnameValueLocalName>;
2591     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2592     .qnameValueNamespaceURI>;
2593     $mod->{for} = $forArg;
2594     $mod->{src} = $mod_node;
2595 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2596 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2597 wakaba 1.5 ($mod->{nameURI} => $doc);
2598    
2599 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2600     = $mod->{src}
2601     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2602     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2603     (<Q::swcfg21:fileName>);
2604 wakaba 1.5
2605 wakaba 1.12 ## -- Loads "for" definition
2606     my $root_elements
2607     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2608     if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2609     for my $el (@$root_elements) {
2610 wakaba 1.14 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2611 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2612     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2613     }
2614     }
2615    
2616 wakaba 1.5 ## -- Loads "for all"
2617 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2618     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2619 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2620     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2621 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2622     $mod->{localName}, <Q::ManakaiDOM:all>);
2623 wakaba 1.5 unless ($rdoc) {
2624     __UNDEEP{
2625     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2626 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2627 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2628     DIS:localName => {$mod->{localName}},
2629 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2630 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2631     }__;
2632     }__;
2633     }
2634     $self-><M::ManakaiDISDatabase.loadModule>
2635 wakaba 1.9 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>);
2636 wakaba 1.5 } # Unless "for all" loaded
2637 wakaba 1.4
2638     ## -- Loads Required Modules
2639 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2640 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2641     .requireElement>;
2642 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2643     .disAllChildElements>}) {
2644 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2645     .expandedURI> eq <Q::dis:Module>;
2646     my ($uri, $nuri, $ln, $for);
2647 wakaba 1.14 my $mqn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2648 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'QName');
2649     if ($mqn) {
2650 wakaba 1.14 my $mqv = $mqn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2651 wakaba 1.4 .value>;
2652 wakaba 1.14 my $mqp = $mqn-><M::ManakaiDISElement.qnameToPair>
2653 wakaba 1.4 ($mqv, node => $mqn);
2654     ($nuri, $ln) = @$mqp;
2655     } else {
2656 wakaba 1.14 my $mn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2657 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'Name');
2658     if ($mn) {
2659     $nuri = $mod->{namespaceURI};
2660 wakaba 1.14 $ln = $mn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2661 wakaba 1.4 } else {
2662     $nuri = $mod->{namespaceURI};
2663     $ln = $mod->{localName};
2664     }
2665     }
2666 wakaba 1.14 my $wfn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2667 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'WithFor');
2668     if ($wfn) {
2669     $for = $wfn-><AG::ManakaiDISElement.qnameValueURI>;
2670     } else {
2671     $for = $mod->{for};
2672     }
2673 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2674     ($nuri . $ln, for_arg => $for);
2675 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2676     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2677 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2678 wakaba 1.4 unless ($rdoc) {
2679     __UNDEEP{
2680     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2681 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2682 wakaba 1.4 DIS:namespaceURI => {$nuri},
2683     DIS:localName => {$ln},
2684     DIS:for => {$for},
2685     DIS:sourceNode => {$rm},
2686     }__;
2687     }__;
2688     }
2689     $self-><M::ManakaiDISDatabase.loadModule>
2690     ($rdoc, $resolver, for_arg => $for);
2691     }
2692     } # Child Module elements
2693    
2694 wakaba 1.12 ## -- Loads child resources
2695 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2696     (for_arg => $forArg);
2697 wakaba 1.5 for my $el (@$root_elements) {
2698 wakaba 1.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2699 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2700 wakaba 1.9 ($mod, null, null, $el,
2701 wakaba 1.7 for_arg => $forArg);
2702     } else {
2703 wakaba 1.14 my $et = $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2704 wakaba 1.7 .expandedURI>;
2705     if ({
2706 wakaba 1.5 <Q::dis:ForDef> => 1,
2707     <Q::dis:Module> => 1,
2708     <Q::dis:ImplNote> => 1,
2709 wakaba 1.7 }->{$et}) {
2710     #
2711     } else {
2712     __UNDEEP{
2713     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2714     DIS:elementType => {$et},
2715     DIS:sourceNode => {$el},
2716     DIS:uri => {$mod->{uri}},
2717     }__;
2718 wakaba 1.5 }__;
2719 wakaba 1.7 }
2720     } # element types
2721     }
2722    
2723     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2724     .getAttributeNS>
2725     (<Q::dis:>, 'Namespace');
2726 wakaba 1.14 unless ($dn and defined $dn-><M::swcfg21:SWCFGNode
2727     ::swcfg21:ForLatest.value>) {
2728 wakaba 1.7 __UNDEEP{
2729     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2730     DIS:elementType => {<Q::dis:Namespace>},
2731     DIS:sourceNode => {$mod_node},
2732 wakaba 1.5 }__;
2733 wakaba 1.7 }__;
2734 wakaba 1.5 }
2735     } # Unless this module loaded
2736     }__; # Deep
2737    
2738     @Method:
2739     @@Name: loadFor
2740     @@enDesc:
2741     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2742     @@Param:
2743     @@@Name: mod
2744     @@@Type: ManakaiDISModuleDefinition
2745     @@@enDesc:
2746     The module in which the <QUOTE::for> to load is defined.
2747     @@Param:
2748     @@@Name: el
2749     @@@Type:ManakaiDISElement
2750     @@@enDesc:
2751     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2752     @@Return:
2753     @@@ForDefDupException:
2754     @@@ForDefNoQNameException:
2755     @@@ElementNotAllowedException:
2756     @@@PerlDef:
2757     __DEEP{
2758     my $qn_node = $el-><M::swcfg21:SWCFGNode
2759     ::swcfg21:ForLatest.getAttributeNS>
2760     (<Q::dis:>, 'QName');
2761     unless ($qn_node) {
2762     __UNDEEP{
2763     __EXCEPTION{NO_FOR_QNAME_ERR::
2764     DIS:sourceNode => {$qn_node},
2765     }__;
2766     }__;
2767     }
2768     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2769     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2770    
2771 wakaba 1.14 unless ($for-><AG::ManakaiDISForDefinition.isDefined>) {
2772 wakaba 1.10 ## -- Initializes "For" Definition Object
2773 wakaba 1.5 $for->{src} = $el;
2774     $for->{<Q::isDefined>} = true;
2775     $for->{<Q::definingModule>} = $mod->{uri};
2776    
2777 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2778 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2779     .expandedURI>;
2780     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2781     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2782 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2783 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2784 wakaba 1.14 $sfor-><AS::ManakaiDISForDefinition.isReferred> ($ce);
2785 wakaba 1.5 ## TODO: warn if dis:Implement
2786     } elsif ({
2787     <Q::dis:Description> => 1,
2788     <Q::dis:ImplNote> => 1,
2789     <Q::dis:FullName> => 1,
2790     <Q::dis:QName> => 1,
2791     }->{$xn}) {
2792     #
2793     } else {
2794     __UNDEEP{
2795     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2796     DIS:elementType => {$xn},
2797     DIS:sourceNode => {$ce},
2798     DIS:uri => {$mod->{uri}},
2799     }__;
2800     }__;
2801     }
2802     }
2803     } else {
2804     __UNDEEP{
2805     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2806     DIS:sourceNode => {$el},
2807     DIS:anotherSourceNode => {$for->{src}},
2808     }__;
2809     }__;
2810     } # isDefine?
2811     }__; # DEEP
2812    
2813     @Method:
2814     @@Name: loadResource
2815     @@enDesc:
2816     Loads definition of a <QUOTE::dis> resource from a
2817     <Q::dis:ResourceDef> element.
2818     @@Param:
2819     @@@Name: mod
2820     @@@Type: ManakaiDISModuleDefinition
2821     @@@enDesc:
2822     The module in which the resource to load is defined.
2823     @@Param:
2824     @@@Name: parentResource
2825     @@@Type: ManakaiDISResourceDefinition
2826     @@@enDesc:
2827 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2828 wakaba 1.5 @@@nullCase:
2829     @@@@enDesc:
2830     The resource to load is a root resource, i.e. <P::el> is
2831     a direct child of the document node.
2832     @@Param:
2833 wakaba 1.7 @@@Name: dynParent
2834 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2835 wakaba 1.7 @@@enDesc:
2836     The dynamic parent resource of the resource to load.
2837 wakaba 1.9 @@@nullCase:
2838 wakaba 1.7 @@@@enDesc:
2839 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2840     a direct child of the document node.
2841 wakaba 1.7 @@Param:
2842 wakaba 1.5 @@@Name: el
2843     @@@Type:ManakaiDISElement
2844     @@@enDesc:
2845     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2846     @@ForParam:
2847     @@ForpParam:
2848     @@Return:
2849     @@@ResDefDupException:
2850     @@@ElementNotAllowedException:
2851     @@@PerlDef:
2852     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2853     $forpArg ||= [];
2854     __DEEP{
2855 wakaba 1.6 ## -- Node names
2856    
2857     ## Unique resource identifier generated from node id
2858     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
2859     my $node_uri;
2860     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
2861     $forp => $forpArg, $uri => $node_uri}__;
2862    
2863     ## User defined resource identifiers
2864 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
2865     (<Q::dis:QName>, for_arg => $forArg,
2866     forp_arg => $forpArg);
2867     my $res;
2868     if ($qn_node) {
2869     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2870 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2871     ($qn_uri, for_arg => $forArg);
2872 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2873 wakaba 1.5 __UNDEEP{
2874     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2875 wakaba 1.9 DIS:uri => {$res->{uri}},
2876 wakaba 1.5 DIS:sourceNode => {$qn_node},
2877     DIS:anotherSourceNode => {$res->{src}},
2878     }__;
2879 wakaba 1.6 }__;
2880 wakaba 1.5 }
2881     $res->{nameURI} = $qn_uri;
2882     $res->{localName} = $qn_node-><AG::ManakaiDISElement
2883     .qnameValueLocalName>;
2884     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
2885     .qnameValueNamespaceURI>;
2886     } else { ## Anonymous or local
2887     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
2888     (<Q::dis:Name>, for_arg => $forArg,
2889     forp_arg => $forpArg);
2890     if ($n_node) {
2891     if ($parentResource) {
2892     my $puri = $parentResource->{uri};
2893     my $ru;
2894 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2895     ::swcfg21:ForLatest.value>;
2896 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
2897     $localName => $ln,
2898     $result => $ru}__;
2899 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2900     ($ru, for_arg => $forArg);
2901 wakaba 1.5 $res->{nameURI} = $ru;
2902 wakaba 1.14 $res->{localName} = $n_node-><M::swcfg21:SWCFGNode
2903     ::swcfg21:ForLatest.value>;
2904 wakaba 1.5 $res->{<Q::isAnon>} = true;
2905     } else { ## Root local name resource
2906 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2907 wakaba 1.7 ::swcfg21:ForLatest.value>;
2908     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2909     .getPropertyText>
2910     (<Q::dis:Namespace>, null);
2911     my $qn_uri = $ns_uri . $ln;
2912 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2913     ($qn_uri, for_arg => $forArg);
2914 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2915 wakaba 1.6 __UNDEEP{
2916     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2917 wakaba 1.9 DIS:uri => {$res->{uri}},
2918 wakaba 1.6 DIS:sourceNode => {$n_node},
2919     DIS:anotherSourceNode => {$res->{src}},
2920     }__;
2921     }__;
2922     }
2923     $res->{nameURI} = $qn_uri;
2924 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2925     $res->{localName} = $ln;
2926 wakaba 1.5 }
2927     } else {
2928 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2929 wakaba 1.5 $res->{<Q::isAnon>} = true;
2930     }
2931 wakaba 1.6 } # anon
2932 wakaba 1.5 $res->{for} = $forArg;
2933     $res->{forp} = $forpArg;
2934     $res->{src} = $el;
2935     $res->{<Q::definingModule>} = $mod->{uri};
2936 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2937     (<Q::DIS:resource>, $res);
2938 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2939     = $parentResource ? $parentResource->{uri} : null;
2940     $res->{<Q::dynamicParentResource>}
2941 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2942     unless ($res->{uri} eq $node_uri) {
2943     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2944     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2945     }
2946 wakaba 1.7 $res->{<Q::isDefined>} = true;
2947 wakaba 1.9 $res->{seq} = $self->{seq}++;
2948    
2949 wakaba 1.6 ## -- Alias
2950     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2951     (<Q::dis:AliasFor>, for_arg => $forArg,
2952     forp_arg => $forpArg);
2953     if ($al_node) {
2954     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2955     ($node_id, $forArg);
2956     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2957     ($canon_uri);
2958 wakaba 1.14 $canon_res-><AS::ManakaiDISResourceDefinition.isReferred> ($al_node);
2959 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
2960     ($res, node => $al_node);
2961 wakaba 1.6 $res = $canon_res;
2962     }
2963 wakaba 1.5
2964 wakaba 1.11 ## -- Registers as child
2965     $parentResource-><M::ManakaiDISPropertyAccessor
2966     .addPropertyResourceList>
2967     (<Q::DIS:childResource>, $res)
2968     if $parentResource;
2969     $dynParent-><M::ManakaiDISPropertyAccessor
2970     .addPropertyResourceList>
2971     (<Q::DIS:dynamicChildResource>, $res)
2972     if $dynParent;
2973    
2974 wakaba 1.7 my $is_multires = false;
2975     my @props;
2976     my @cres;
2977 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2978     (for_arg => $forArg, forp_arg => $forpArg)};
2979 wakaba 1.7 while (@ce0) {
2980     my $ce = shift @ce0;
2981     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2982     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2983     $res->{<Q::rdf:type>}->{$type_uri} = true;
2984     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2985 wakaba 1.14 $type-><AS::ManakaiDISResourceDefinition.isReferred> ($ce);
2986 wakaba 1.7 if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2987     (<Q::dis:MultipleResource>)) {
2988     $is_multires = true;
2989     }
2990     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2991     (<Q::dis:subsetOf>)) {
2992     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2993     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2994     ($node_id, $forArg));
2995     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2996 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
2997 wakaba 1.7 push @cres, $ce;
2998     } else {
2999     ## Property and invalid element is not checked, since not
3000     ## all property definitions has loaded at this stage.
3001     push @props, $ce;
3002     }
3003     } # @ce0
3004    
3005     ## -- Child resources
3006     unless ($is_multires) {
3007     for my $re (@cres) {
3008     unless ($al_node) {
3009     $self-><M::ManakaiDISDatabase.loadResource>
3010     ($mod, $res, $res, $re,
3011     for_arg => $forArg, forp_arg => $forpArg);
3012 wakaba 1.5 } else {
3013 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
3014     (<Q::dis:aliasChild>, for_arg => $forArg,
3015     forp_arg => $forpArg);
3016     if ($ac and $ac-><M::swcfg21:SWCFGNode
3017     ::swcfg21:ForLatest.value>) {
3018     $self-><M::ManakaiDISDatabase.loadResource>
3019     ($mod, $res, $res, $re,
3020     for_arg => $forArg, forp_arg => $forpArg);
3021     }
3022 wakaba 1.4 }
3023     }
3024 wakaba 1.7 }
3025 wakaba 1.5
3026 wakaba 1.7 ## -- Multiple representations
3027     if ($is_multires) {
3028     for my $pe (@props) {
3029     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
3030 wakaba 1.10 (<Q::dis:resourceFor>)) {
3031 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
3032 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
3033 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($pe);
3034 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
3035     ($mod, $parentResource, $res, $el,
3036     for_arg => $forArg,
3037     forp_arg => [@{$forpArg}, $for_uri]);
3038     }
3039     }
3040     }
3041 wakaba 1.5 }__; # DEEP
3042 wakaba 1.8
3043     @Method:
3044     @@Name: checkUndefinedResource
3045     @@enDesc:
3046     Checks whether there is referred but undefined resource or not.
3047     @@Return:
3048     @@@RaiseException:
3049     @@@@@: FOR_NOT_DEFINED_ERR
3050     @@@@enDesc:
3051     There is a <QUOTE::for> that is referred but not defined.
3052     @@@RaiseException:
3053     @@@@@: RESOURCE_NOT_DEFINED_ERR
3054     @@@@enDesc:
3055     There is a resource that is referred but not defined.
3056     @@@PerlDef:
3057     for my $fd (values %{$self->{forDef}}) {
3058     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
3059     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
3060     __EXCEPTION{FOR_NOT_DEFINED_ERR::
3061     DIS:uri => {$fd->{uri}},
3062     DIS:sourceNode => {$ref},
3063     }__;
3064     }
3065     }
3066     for my $fd (values %{$self->{resDef}}) {
3067     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
3068     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
3069     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3070     DIS:uri => {$fd->{uri}},
3071     DIS:sourceNode => {$ref},
3072     }__;
3073     }
3074     }
3075 wakaba 1.5
3076 wakaba 1.9
3077     @Method:
3078     @@Name: plStore
3079     @@enDesc:
3080     Saves this database to an external file.
3081     \
3082     {NOTE:: Saved files can be loaded by
3083     <M::ManakaiDISImplementation.plLoadDISDatabase>.
3084     \
3085     }
3086     @@Param:
3087     @@@Name: fileName
3088     @@@Type:
3089 wakaba 1.18 DISLang:String::ManakaiDOM:all
3090 wakaba 1.9 @@@enDesc:
3091     An environment-dependent file name of external database to save.
3092     \
3093     {NOTE:: If there is already a file named as <P::fileName>, then
3094     it is overwritten.
3095     \
3096     }
3097     @@Return:
3098     @@@SimpleException:
3099     @@@PerlDef:
3100     use Storable qw/nstore/;
3101     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
3102     nstore $self, $fileName;
3103 wakaba 1.15
3104     @Method:
3105     @@Name: xcrefToResource
3106     @@enDesc:
3107     Returns a resource object selected by an exception code
3108     reference (<Q::DOMMain:XCodeRef>).
3109     @@Param:
3110     @@@Name: xcref
3111     @@@Type:
3112     DOMMain:XCodeRef::ManakaiDOM:all
3113     @@@enDesc:
3114     Exception code to select.
3115     @@Param:
3116     @@@Name: contextNode
3117     @@@Type: ManakaiDISElement
3118     @@@enDesc:
3119     A context element node. Namespace prefixes in
3120     <P::xcref> are resolved against this node.
3121 wakaba 1.16 @@ForParam:
3122 wakaba 1.15 @@NodeParam:
3123     @@Return:
3124     @@@Type:
3125     Perl:ARRAY::ManakaiDOM:all
3126     @@@enDesc:
3127     A reference to the array containing two or three
3128     resource definitions (<Class::ManakaiDISResourceDefinition>).
3129     The first (index <CODE::0>) resource is an exception class.
3130     The second (index <CODE::1>) resource is an exception code
3131     constant. The third (index <CODE::2>) resource
3132     is an exception subtype or <DOM::null> if the reference identifies
3133     no subtype.
3134     @@@RaiseException:
3135     @@@@@: RESOURCE_NOT_DEFINED_ERR
3136     @@@@enDesc:
3137     The resource identified by the <P::xcref> is not defined
3138     or not an exception.
3139     @@@PerlDef:
3140     my ($q1, $q2, $q3) = split /\s*\.\s*/, $xcref, 3;
3141     my $r = [];
3142     __DEEP{
3143     if (defined $q3) {
3144     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3145 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3146     ($q3, null, $forArg, node => $node));
3147 wakaba 1.15 $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
3148     .getPropertyResource>
3149     (<Q::dis2pm:parentResource>);
3150     } elsif (defined $q2) {
3151     if ($q2 =~ /:/) {
3152     $r->[1] = $self-><M::ManakaiDISDatabase.getResource>
3153 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3154     ($q2, null, $forArg, node => $node));
3155 wakaba 1.15 } else {
3156     $r->[0] = $self-><M::ManakaiDISDatabase.getResource>
3157 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3158     ($q1, null, $forArg, node => $node));
3159 wakaba 1.15 $r->[1] = $r->[0]-><M::ManakaiDISResourceDefinition
3160     .getConstResourceByName> ($q2);
3161     }
3162 wakaba 1.16 } else { ## $q1 only
3163 wakaba 1.15 $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3164 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
3165     ($q1, null, $forArg, node => $node));
3166 wakaba 1.15 if ($r->[2]-><M::ManakaiDISResourceDefinition
3167     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
3168     $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
3169     .getPropertyResource>
3170     (<Q::dis2pm:parentResource>);
3171     } else {
3172     $r->[1] = $r->[2]; CORE::delete $r->[2];
3173     }
3174     }
3175    
3176     if ($r->[2] and
3177     not $r->[2]-><M::ManakaiDISResourceDefinition
3178     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
3179     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3180     DIS:uri => {$r->[2]->{uri}},
3181     DIS:expectedType => {<Q::ManakaiDOM:ExceptionOrWarningSubType>},
3182     DIS:sourceNode => {$node},
3183     DIS:sourceCode => {$xcref},
3184     }__}__;
3185     }
3186 wakaba 1.16 $r->[2]-><AS::ManakaiDISResourceDefinition.isReferred>
3187     ($node or $contextNode)
3188     if $r->[2];
3189 wakaba 1.15
3190     if (not $r->[1] or
3191     not $r->[1]-><M::ManakaiDISResourceDefinition
3192     .isTypeURI> (<Q::ManakaiDOM:Const>)) {
3193     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3194     DIS:uri => {$r->[1]->{uri}},
3195     DIS:localName => {$r->[1]->{localName}},
3196     DIS:expectedType => {<Q::ManakaiDOM:Const>},
3197     DIS:sourceNode => {$node},
3198     DIS:sourceCode => {$xcref},
3199     }__}__;
3200     }
3201 wakaba 1.16 $r->[1]-><AS::ManakaiDISResourceDefinition.isReferred>
3202 wakaba 1.15 ($node or $contextNode);
3203    
3204     unless ($r->[0]) {
3205     my $cg = $r->[1]-><M::ManakaiDISPropertyAccessor
3206     .getPropertyResource>
3207     (<Q::dis2pm:parentResource>);
3208     $r->[0] = $cg-><M::ManakaiDISPropertyAccessor
3209     .getPropertyResource>
3210     (<Q::dis2pm:parentResource>) if $cg;
3211     }
3212     if (not $r->[0] or
3213     not $r->[0]-><M::ManakaiDISResourceDefinition
3214 wakaba 1.16 .isTypeURI> (<Q::DOMException:AnyExceptionClass>)) {
3215 wakaba 1.15 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3216     DIS:uri => {$r->[0]->{uri}},
3217     DIS:localName => {$r->[0]->{localName}},
3218 wakaba 1.16 DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
3219 wakaba 1.15 DIS:sourceNode => {$node},
3220     DIS:sourceCode => {$xcref},
3221     }__}__;
3222     }
3223 wakaba 1.16 $r->[0]-><AS::ManakaiDISResourceDefinition.isReferred>
3224 wakaba 1.15 ($node or $contextNode);
3225     }__;
3226 wakaba 1.2 ##DISDatabase
3227    
3228 wakaba 1.8 PropDef:
3229 wakaba 1.9 @QName: resource
3230     @enDesc:
3231     Resources defined in a module.
3232     @rdfs:range: ManakaiDISResourceDefinition
3233     @rdfs:domain: ManakaiDISModuleDefinition
3234    
3235     PropDef:
3236 wakaba 1.8 @QName:
3237     dis2pm:parentResource
3238     @enDesc:
3239     Static parent resource. No parent for root resources.
3240    
3241     PropDef:
3242     @QName: dynamicParentResource
3243     @enDesc:
3244     Dynamic parent resource. No parent for root resources.
3245    
3246 wakaba 1.11 PropDef:
3247     @QName: childResource
3248     @enDesc:
3249     Static child resources.
3250    
3251     PropDef:
3252     @QName: dynamicChildResource
3253     @enDesc:
3254     Dynamic child resources.
3255    
3256 wakaba 1.5 ElementTypeBinding:
3257     @Name: ForDefDupException
3258     @ElementType:
3259     ManakaiDOM:raises
3260     @ShadowContent:
3261     @@@: FOR_ALREADY_DEFINED_ERR
3262     @@Description:
3263     @@@lang:en
3264     @@@@:
3265     The <QUOTE::for> is already defined elsewhere.
3266    
3267     ElementTypeBinding:
3268     @Name: ForDefNoQNameException
3269     @ElementType:
3270     ManakaiDOM:raises
3271     @ShadowContent:
3272     @@@: NO_FOR_QNAME_ERR
3273     @@Description:
3274     @@@lang:en
3275     @@@@:
3276     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
3277    
3278     ElementTypeBinding:
3279     @Name: ResDefDupException
3280     @ElementType:
3281     ManakaiDOM:raises
3282     @ShadowContent:
3283     @@@: RESOURCE_ALREADY_DEFINED_ERR
3284     @@Description:
3285     @@@lang:en
3286     @@@@:
3287     The <QUOTE::dis> resource is already defined elsewhere.
3288    
3289     ElementTypeBinding:
3290     @Name: ElementNotAllowedException
3291     @ElementType:
3292     ManakaiDOM:raises
3293     @ShadowContent:
3294     @@@: ELEMENT_NOT_ALLOWED_ERR
3295     @@Description:
3296     @@@lang:en
3297     @@@@:
3298     An element has found where it is not allowed.
3299    
3300 wakaba 1.4 IFClsDef:
3301     @QName:
3302     @@@: DISModuleResolver
3303     @@ForCheck: ForIF
3304     @QName:
3305     @@@: ManakaiDISModuleResolver
3306     @@ForCheck: ForClass
3307     @enDesc:
3308     Objects implementing <IF::DISModuleResolver> interface
3309     are used to convert module name into <QUOTE::dis> document object.
3310     \
3311     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
3312     as a method parameter where <IF::DISModuleResolver> is
3313     expected.
3314     \
3315     }
3316     @Method:
3317     @@Name: uriToDocument
3318     @@enDesc:
3319     Returns a <QUOTE::dis> document from module name information.
3320     @@Param:
3321     @@@Name: disDB
3322     @@@Type: ManakaiDISDatabase
3323     @@@enDesc:
3324     The <QUOTE::dis> database.
3325     @@Param:
3326     @@@Name: moduleURI
3327     @@@Type: ModuleURI
3328     @@@enDesc:
3329     The URI reference of the module.
3330     \
3331     {NOTE:: This parameter is redundant, since it can be
3332     composed from other three parameters.
3333     \
3334     }
3335     @@Param:
3336     @@@Name: moduleNamespaceURI
3337     @@@Type: AnyURI
3338     @@@enDesc:
3339     The namespace URI of the module name.
3340     @@Param:
3341     @@@Name: moduleLocalName
3342     @@@Type:
3343 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
3344 wakaba 1.4 @@@enDesc:
3345     The local name of the module name.
3346     @@Param:
3347     @@@Name: moduleFor
3348     @@@Type: ForURI
3349     @@@enDesc:
3350     The <QUOTE::for> URI reference for which the module is defined.
3351     @@Return:
3352     @@@Type: ManakaiDISDocument
3353     @@@enDesc:
3354     The <QUOTE::dis> document. It don't have to be a newly created
3355     object.
3356     @@@nullCase:
3357     @@@@enDesc:
3358     The method is unable to resolve the reference.
3359     @@@PerlDef:
3360     $r = $self->(@_);
3361     @ManakaiDOM:inputNormalizer:
3362     @@ContentType:
3363     lang:Perl
3364     @@@:
3365     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
3366     if ref $INPUT eq 'CODE';
3367     @@ImplNote:
3368     @@@lang:en
3369     @@@@:
3370     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
3371     ##DISModuleResolver
3372    
3373 wakaba 1.3 PropDef:
3374     @QName: sourceFile
3375     @enDesc:
3376     Source <QUOTE::dis> documents.
3377     @rdfs:domain: ManakaiDISDatabase
3378     @rdfs:range: ManakaiDISDocument
3379    
3380 wakaba 1.2 ClsDef:
3381     @ClsQName: ManakaiDISModuleDefinition
3382     @enDesc:
3383     <QUOTE::dis> module definitions.
3384     @ClsISA: ManakaiDISPropertyAccessor
3385 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3386 wakaba 1.2
3387     @Attr:
3388     @@Name: uri
3389     @@Type: ModuleURI
3390     @@Description:
3391     @@@lang:en
3392     @@@@:
3393     The URI reference of this <QUOTE::dis> module.
3394     @@Get:
3395     @@@PerlDef:
3396     $r = $self->{uri};
3397    
3398     @Attr:
3399     @@Name: nameURI
3400     @@Type: NameURI
3401     @@enDesc:
3402     The URI reference of this module, without
3403     <QUOTE::for> identifier.
3404     @@Get:
3405 wakaba 1.3 @@@PerlDef:
3406 wakaba 1.4 $r = $self->{nameURI};
3407 wakaba 1.2
3408     @Attr:
3409     @@Name: localName
3410     @@enDesc:
3411     The local name of this module.
3412     @@Type:
3413 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3414 wakaba 1.2 @@Get:
3415     @@@PerlDef:
3416     $r = $self->{localName};
3417    
3418     @Attr:
3419     @@Name: namespaceURI
3420     @@Type: AnyURI
3421     @@enDesc:
3422     The namespace URI of the name of this resource.
3423     @@Get:
3424     @@@PerlDef:
3425     $r = $self->{namespaceURI};
3426    
3427     @Attr:
3428     @@Name: forURI
3429     @@Type: ForURI
3430     @@enDesc:
3431     The <QUOTE::for> URI reference for which this module is defined.
3432     @@Get:
3433     @@@PerlDef:
3434     $r = $self->{for};
3435    
3436     @Attr:
3437     @@Name: isDefined
3438     @@Description:
3439     @@@lang:en
3440     @@@@:
3441     Whether this module is defined or not.
3442     @@Type:
3443 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3444 wakaba 1.2 @@Get:
3445     @@@PerlDef:
3446     $r = $self->{<Q::isDefined>};
3447 wakaba 1.8
3448     @Attr:
3449     @@Name: plFullyQualifiedName
3450     @@enDesc:
3451     The fully-qualified Perl class package name.
3452     @@Type:
3453     Perl:package-name::ManakaiDOM:all
3454     @@Get:
3455     @@@NoPerlModuleNameException:
3456     @@@PerlDef:
3457     __DEEP{
3458     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3459     ($self->{namespaceURI});
3460     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3461     __UNDEEP{
3462     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3463     DIS:uri => {$self->{namespaceURI}},
3464     DIS:sourceNode => {$self->{src}},
3465     }__;
3466     }__;
3467     }
3468     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3469     (<Q::dis:AppName>, for_arg => $self->{for},
3470 wakaba 1.10 media_type => <Q::lang:Perl>,
3471     default_media_type => <Q::lang:Perl>);
3472 wakaba 1.8 if ($an) {
3473     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3474     $r =~ s/::$//g;
3475     $r .= '::' . $self->{localName};
3476     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3477     (<Q::ManakaiDOM:moduleSuffix>,
3478     for_arg => $self->{for},
3479     media_type => <Q::lang:Perl>,
3480     default_media_type => <Q::lang:Perl>);
3481     if ($sf) {
3482     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3483     }
3484     } else {
3485 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
3486 wakaba 1.8 }
3487     }__;
3488    
3489     @Attr:
3490     @@Name: plInterfaceName
3491     @@enDesc:
3492     The fully-qualified Perl interface package name.
3493     @@Type:
3494     Perl:package-name::ManakaiDOM:all
3495     @@Get:
3496     @@@NoPerlModuleNameException:
3497     @@@PerlDef:
3498     __DEEP{
3499     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
3500     ($self->{namespaceURI});
3501     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3502     __UNDEEP{
3503     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3504     DIS:uri => {$self->{namespaceURI}},
3505     DIS:sourceNode => {$self->{src}},
3506     }__;
3507     }__;
3508     }
3509     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3510     (<Q::dis:AppName>, for_arg => $self->{for},
3511     forp_arg => [<Q::ManakaiDOM:ForIF>],
3512 wakaba 1.10 media_type => <Q::lang:Perl>,
3513     default_media_type => <Q::lang:Perl>);
3514 wakaba 1.8 if ($an) {
3515     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3516     $r =~ s/::$//g;
3517     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3518     (<Q::ManakaiDOM:moduleSuffix>,
3519     for_arg => $self->{for},
3520     forp_arg => [<Q::ManakaiDOM:ForIF>],
3521     media_type => <Q::lang:Perl>,
3522     default_media_type => <Q::lang:Perl>);
3523     if ($sf) {
3524     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3525     }
3526     } else {
3527 wakaba 1.14 $r = $self-><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>;
3528 wakaba 1.8 }
3529     }__;
3530 wakaba 1.2 ##DISModuleDefinition
3531    
3532 wakaba 1.8 ElementTypeBinding:
3533     @Name: NoPerlModuleNameException
3534     @ElementType:
3535     ManakaiDOM:raises
3536     @ShadowContent:
3537     @@@: RESOURCE_NOT_DEFINED_ERR
3538     @@Description:
3539     @@@lang:en
3540     @@@@:
3541     The module group corresponding to the namespace URI
3542     of this module is not defined.
3543    
3544 wakaba 1.2 ClsDef:
3545     @ClsQName: ManakaiDISForDefinition
3546     @Description:
3547     @@lang:en
3548     @@@:
3549     <QUOTE::dis> <QUOTE::for> definitions.
3550 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3551 wakaba 1.2
3552     @Attr:
3553     @@Name: uri
3554     @@Type: ForURI
3555     @@Description:
3556     @@@lang:en
3557     @@@@:
3558     The URI reference of this <QUOTE::for>.
3559     @@Get:
3560     @@@PerlDef:
3561     $r = $self->{uri};
3562 wakaba 1.10
3563     @IntMethod:
3564     @@Operator:
3565     @@@@:eq
3566     @@@ContentType:
3567     lang:Perl
3568     @@enDesc:
3569     Whether two <QUOTE::for> definitions are equal or not.
3570     Two <QUOTE::for> definitions are equal iff one's URI reference
3571     is one of another's URI reference.
3572     \
3573     {NOTE:: Aliases for <QUOTE::for> is not allowed.
3574     \
3575     }
3576     @@ImplNote:
3577     @@@lang:en
3578     @@@@:
3579     In the current implementation, two are equal iff two are
3580     equal as reference.
3581     @@Param:
3582     @@@Name: anotherFor
3583     @@@Type: ManakaiDISForDefinition
3584     @@@enDesc:
3585     Another <QUOTE::for> definition to compare.
3586     @@Return:
3587     @@@Type:
3588 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3589 wakaba 1.10 @@@enDesc:
3590     Whether two resources are equal or not.
3591     @@@PerlDef:
3592     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
3593     $r = $self->{uri} eq $anotherFor->{uri};
3594     } else {
3595     $r = false;
3596     }
3597 wakaba 1.2
3598     @Method:
3599     @@Name: isaURI
3600     @@Description:
3601     @@@lang:en
3602     @@@@:
3603     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
3604     @@Param:
3605     @@@Name: superURI
3606     @@@Type: ForURI
3607     @@@Description:
3608     @@@@lang:en
3609     @@@@@:
3610     Another <QUOTE::for> URI reference to test.
3611     @@Return:
3612     @@@Type:
3613 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3614 wakaba 1.2 @@@TrueCase:
3615     @@@@enDesc:
3616     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
3617     @@@FalseCase:
3618     @@@@enDesc:
3619     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
3620     @@@PerlDef:
3621     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
3622    
3623     @Attr:
3624     @@Name: isDefined
3625     @@Description:
3626     @@@lang:en
3627     @@@@:
3628     Whether this <QUOTE::for> is already defined or not.
3629     @@Type:
3630 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3631 wakaba 1.2 @@Get:
3632     @@@TrueCase:
3633     This <QUOTE::for> is already defined.
3634     @@@FalseCase:
3635     This <QUOTE::for> is not defined.
3636     @@@PerlDef:
3637     $r = $self->{<Q::isDefined>};
3638    
3639     @Attr:
3640     @@Name: isReferred
3641     @@Description:
3642     @@@lang:en
3643     @@@@:
3644     Whether this <QUOTE::for> is referred somewhere or not.
3645 wakaba 1.9 @@Type: ManakaiDISElement
3646 wakaba 1.2 @@Get:
3647     @@@InCase:
3648     @@@@Type:ManakaiDISElement
3649     @@@@enDesc:
3650     This <QUOTE::for> is referred by the element.
3651     @@@nullCase:
3652     This <QUOTE::for> is not referred.
3653     @@@PerlDef:
3654     $r = $self->{<Q::isReferred>};
3655     @@Set:
3656     @@@InCase:
3657     @@@@Type:ManakaiDISElement
3658     @@@@enDesc:
3659     This <QUOTE::for> is referred by the element.
3660     @@@PerlDef:
3661 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3662 wakaba 1.2
3663     @Attr:
3664     @@Name: definingModule
3665     @@Description:
3666     @@@lang:en
3667     @@@@:
3668     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3669     @@Type: ManakaiDISModuleDefinition
3670     @@Get:
3671     @@@Description:
3672     @@@@lang:en
3673     @@@@@:
3674     The module object.
3675 wakaba 1.3 @@@nullCase:
3676 wakaba 1.2 @@@@Description:
3677     @@@@@lang:en
3678     @@@@@@:
3679     This <QUOTE::for> is not associated to any module.
3680     @@@PerlDef:
3681     $r = $self->{db}
3682     -><M::ManakaiDISDatabase.getResource>
3683     ($self->{<Q::definingModule>})
3684     if defined $self->{<Q::definingModule>};
3685 wakaba 1.5
3686 wakaba 1.2 @Method:
3687 wakaba 1.5 @@Name: addISA
3688 wakaba 1.2 @@enDesc:
3689 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3690     <QUOTE::for>.
3691 wakaba 1.2 @@Param:
3692 wakaba 1.5 @@@Name: superFor
3693     @@@Type: ManakaiDISForDefinition
3694     @@@enDesc:
3695     A <QUOTE::for> definition object.
3696 wakaba 1.2 @@Return:
3697     @@@PerlDef:
3698 wakaba 1.5 my @from = ($self->{uri},
3699     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3700     my @to = ($superFor->{uri},
3701     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3702 wakaba 1.7 __DEEP{
3703     for my $from (@from) {
3704     for my $to (@to) {
3705     $self->{db}-><M::ManakaiDISDatabase.getFor>
3706     ($from)->{isa}->{$to} = true;
3707     $self->{db}-><M::ManakaiDISDatabase.getFor>
3708     ($to)->{revISA}->{$from} = true;
3709     }
3710 wakaba 1.5 }
3711 wakaba 1.7 }__;
3712 wakaba 1.5
3713 wakaba 1.2 ##DISForDefinition
3714    
3715     ClsDef:
3716     @ClsQName: ManakaiDISResourceDefinition
3717     @enDesc:
3718     <QUOTE::dis> resource definitions.
3719     @ClsISA: ManakaiDISPropertyAccessor
3720 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3721 wakaba 1.21
3722     @IntMethod:
3723     @@Operator:
3724     @@@@:eq
3725     @@@ContentType:
3726     lang:Perl
3727     @@enDesc:
3728     Whether two <QUOTE::dis> resource definitions are equal or not.
3729     Two resource definitions are equal iff one's <A::.uri> is
3730     literally equal to another's <A::.uri>.
3731     @@Param:
3732     @@@Name: anotherResource
3733     @@@Type: ManakaiDISResourceDefinition
3734     @@@enDesc:
3735     Another resource definition to compare.
3736     @@Return:
3737     @@@Type:
3738     DOMMain:boolean::ManakaiDOM:all
3739     @@@enDesc:
3740     Whether two resources are equal or not.
3741     @@@PerlDef:
3742     if (UNIVERSAL::isa ($anotherResource,
3743     <ClassName::ManakaiDISResourceDefinition>)) {
3744     $r = $self->{uri} eq $anotherResource->{uri};
3745     } else {
3746     $r = false;
3747     }
3748 wakaba 1.2
3749     @Attr:
3750     @@Name: uri
3751     @@Type: ResourceURI
3752     @@Description:
3753     @@@lang:en
3754     @@@@:
3755     The URI reference of this <QUOTE::dis> resource.
3756     @@Get:
3757     @@@PerlDef:
3758     $r = $self->{uri};
3759    
3760     @Attr:
3761     @@Name: nameURI
3762     @@Type: NameURI
3763     @@enDesc:
3764     The URI reference of this <QUOTE::dis> resource, without
3765     <QUOTE::for> identifier.
3766     @@Get:
3767     @@@nullCase:
3768     @@@@enDesc:
3769     This resource does not have its name URI reference.
3770 wakaba 1.3 @@@PerlDef:
3771 wakaba 1.4 $r = $self->{nameURI};
3772 wakaba 1.2
3773     @Attr:
3774     @@Name: localName
3775     @@enDesc:
3776     The local name of this resource.
3777     @@Type:
3778 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3779 wakaba 1.2 @@Get:
3780     @@@nullCase:
3781     @@@@enDesc:
3782     This resource does not have its local name.
3783     @@@PerlDef:
3784     $r = $self->{localName};
3785    
3786     @Attr:
3787     @@Name: namespaceURI
3788     @@Type: AnyURI
3789     @@enDesc:
3790     The namespace URI of the name of this resource.
3791     @@Get:
3792     @@@nullCase:
3793     The name of this resource does not have its namespace
3794     or this resource does not have its name.
3795     @@@PerlDef:
3796     $r = $self->{namespaceURI};
3797    
3798     @Attr:
3799     @@Name: isAnonymous
3800     @@enDesc:
3801     Whether this <QUOTE::dis> resource has name or not.
3802     @@Type:
3803 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3804 wakaba 1.2 @@Get:
3805     @@@TrueCase:
3806     This resource does not have any global unique name.
3807     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3808     @@@FalseCase:
3809     This resource does have its formal name.
3810     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3811     generated from the name and the <QUOTE::for> URI reference
3812     of this resource.
3813     @@@PerlDef:
3814     $r = $self->{<Q::isAnon>};
3815    
3816     @Attr:
3817     @@Name: forURI
3818     @@enDesc:
3819     The <QUOTE::for> URI reference for which this resource is defined.
3820     @@Type:ForURI
3821     @@Get:
3822     @@@PerlDef:
3823     $r = $self->{for};
3824    
3825     @Attr:
3826     @@Name: forpURI
3827     @@enDesc:
3828     The <QUOTE::for+> URI references for which this resource is defined.
3829     @@Type: ForURIList
3830     @@Get:
3831 wakaba 1.15 @@@enDesc:
3832     List of <QUOTE::for> URI references. Note that this list is
3833     <QUOTE::dead>.
3834 wakaba 1.3 @@@PerlDef:
3835 wakaba 1.15 $r = [@{$self->{forp}}];
3836    
3837     @Method:
3838     @@Name: isForURI
3839     @@enDesc:
3840     Tests whether this resource is defined for a <QUOTE::for>
3841     or <QUOTE::for+> URI reference or not.
3842     @@Param:
3843     @@@Name:forURI
3844     @@@Type:ForURI
3845     @@@enDesc:
3846     A <QUOTE::for> URI reference to test.
3847     @@Return:
3848     @@@Type:
3849     DOMMain:boolean::ManakaiDOM:all
3850     @@@TrueCase:
3851     @@@@enDesc:
3852     This resource is for <P::forURI>.
3853     @@@FalseCase:
3854     @@@@enDesc:
3855     This resource is not for <P::forURI>.
3856     @@@PerlDef:
3857     __DEEP{
3858     for my $this_for_uri ($self->{for}, @{$self->{forp}}) {
3859     if ($this_for_uri eq $forURI) { ## Shortcut
3860     $r = true;
3861     last;
3862     }
3863     my $this_for = $self->{db}-><M::ManakaiDISDatabase.getFor>
3864     ($this_for_uri);
3865     if ($this_for-><M::ManakaiDISForDefinition.isaURI> ($forURI)) {
3866     $r = true;
3867     last;
3868     }
3869     }
3870     }__;
3871 wakaba 1.2
3872     @Method:
3873 wakaba 1.7 @@Name: isSubsetOfURI
3874 wakaba 1.2 @@Description:
3875     @@@lang:en
3876     @@@@:
3877     Whether this resource is a subset of another resource or not.
3878     @@Param:
3879     @@@Name: superURI
3880     @@@Type: ResourceURI
3881     @@@Description:
3882     @@@@lang:en
3883     @@@@@:
3884     Another resource URI reference to test.
3885     @@Return:
3886     @@@Type:
3887 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3888 wakaba 1.2 @@@TrueCase:
3889     @@@@enDesc:
3890     <P::superURI> is a super-resource of this resource.
3891     @@@FalseCase:
3892     @@@@enDesc:
3893     <P::superURI> is not a super-resource of this resource.
3894     @@@PerlDef:
3895 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3896 wakaba 1.2
3897 wakaba 1.7 @Method:
3898     @@Name: addSuperResource
3899     @@enDesc:
3900     Adds a <QUOTE::dis> resource to the list of super-resource
3901     of this <QUOTE::dis> resource.
3902     @@Param:
3903     @@@Name: superRes
3904     @@@Type: ManakaiDISResourceDefinition
3905     @@@enDesc:
3906     A <QUOTE::dis> resource definition object.
3907     @@Return:
3908     @@@PerlDef:
3909     my @from = ($self->{uri},
3910     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3911     my @to = ($superRes->{uri},
3912     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3913     __DEEP{
3914     for my $from (@from) {
3915     for my $to (@to) {
3916     $self->{db}-><M::ManakaiDISDatabase.getResource>
3917     ($from)->{subOf}->{$to} = true;
3918     $self->{db}-><M::ManakaiDISDatabase.getResource>
3919     ($to)->{supOf}->{$from} = true;
3920     }
3921     }
3922     }__;
3923    
3924 wakaba 1.2 @Attr:
3925     @@Name: isDefined
3926     @@Description:
3927     @@@lang:en
3928     @@@@:
3929     Whether this resource is already defined or not.
3930     @@Type:
3931 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
3932 wakaba 1.2 @@Get:
3933     @@@TrueCase:
3934     This resource is already defined.
3935     @@@FalseCase:
3936     This resource is not defined.
3937     @@@PerlDef:
3938     $r = $self->{<Q::isDefined>};
3939    
3940     @Attr:
3941     @@Name: isReferred
3942     @@Description:
3943     @@@lang:en
3944     @@@@:
3945     Whether this resource is referred or not.
3946 wakaba 1.7 @@Type: ManakaiDISElement
3947 wakaba 1.2 @@Get:
3948 wakaba 1.7 @@@enDesc:
3949 wakaba 1.9 An element that referres this resource.
3950 wakaba 1.2 @@@nullCase:
3951     This resource is not referred.
3952     @@@PerlDef:
3953     $r = $self->{<Q::isReferred>};
3954     @@Set:
3955 wakaba 1.7 @@@enDesc:
3956 wakaba 1.9 An element that referres this resource.
3957 wakaba 1.2 @@@PerlDef:
3958 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3959 wakaba 1.2
3960     @Attr:
3961     @@Name: definingModule
3962     @@Description:
3963     @@@lang:en
3964     @@@@:
3965     The <QUOTE::dis> module in which this resource is defined.
3966 wakaba 1.8 \
3967     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3968     \
3969     }
3970 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3971     @@Get:
3972     @@@Description:
3973     @@@@lang:en
3974     @@@@@:
3975     The module object.
3976 wakaba 1.3 @@@nullCase:
3977 wakaba 1.2 @@@@Description:
3978     @@@@@lang:en
3979     @@@@@@:
3980     This resource is not associated to any module.
3981     @@@PerlDef:
3982     $r = $self->{db}
3983     -><M::ManakaiDISDatabase.getModule>
3984     ($self->{<Q::definingModule>})
3985     if defined $self->{<Q::definingModule>};
3986     @@Set:
3987     @@@Description:
3988     @@@@lang:en
3989     @@@@@:
3990     The module object to which the <QUOTE::defining module> is set.
3991     @@@PerlDef:
3992     $self->{<Q::defininingModule>}
3993     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3994    
3995 wakaba 1.6 @Method:
3996     @@Name: mergeAsAlias
3997     @@enDesc:
3998     Merges another resource definition as an alias of this resource.
3999     @@Param:
4000     @@@Name: aliasResource
4001     @@@Type: ManakaiDISResourceDefinition
4002     @@@enDesc:
4003     A resource to merge.
4004     \
4005     {NOTE:: After merging all references to <P::aliasResource>
4006     should be discarded.
4007     \
4008     }
4009 wakaba 1.11 @@NodeParam:
4010 wakaba 1.6 @@Return:
4011 wakaba 1.11 @@@RaiseException:
4012     @@@@@:MERGE_ITSELF_ERR
4013     @@@@@@enDesc:
4014     An attempt is made to merge this resource itself.
4015     @@@PerlDef:
4016     if ($self eq $aliasResource) {
4017     __EXCEPTION{MERGE_ITSELF_ERR::
4018     DIS:uri => {$self->{uri}},
4019     DIS:sourceNode => {$node},
4020     }__;
4021     }
4022 wakaba 1.6 for my $uri ($aliasResource->{uri},
4023     grep {$aliasResource->{aliasURI}->{$_}}
4024     keys %{$aliasResource->{aliasURI}}) {
4025     $self->{aliasURI}->{$uri} = true;
4026     $self->{db}->{resDef}->{$uri} = $self;
4027     $self->{subOf}->{$uri} = true;
4028     $self->{supOf}->{$uri} = true;
4029     }
4030     for my $uri (grep {$aliasResource->{subOf}->{$_}}
4031     keys %{$aliasResource->{subOf}}) {
4032     $self->{subOf}->{$uri} = true;
4033     }
4034     for my $uri (grep {$aliasResource->{supOf}->{$_}}
4035     keys %{$aliasResource->{supOf}}) {
4036     $self->{supOf}->{$uri} = true;
4037     }
4038     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
4039     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
4040     __DEEP{
4041     for my $from (@from) {
4042     for my $to (@to) {
4043     $self->{db}-><M::ManakaiDISDatabase.getResource>
4044     ($from)->{subOf}->{$to} = true;
4045     $self->{db}-><M::ManakaiDISDatabase.getResource>
4046     ($to)->{supOf}->{$from} = true;
4047     }
4048     }
4049     }__;
4050 wakaba 1.7
4051     @Method:
4052     @@Name: isTypeURI
4053     @@enDesc:
4054     Tests whether this resource is of a type or not.
4055     @@Param:
4056     @@@Name: typeURI
4057     @@@Type: ResourceURI
4058     @@@enDesc:
4059     A type URI reference to test.
4060     @@Return:
4061     @@@Type:
4062 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
4063 wakaba 1.7 @@@TrueCase:
4064     @@@@enDesc:
4065     This is a <P::typeURI> resource.
4066     @@@FalseCase:
4067     @@@@enDesc:
4068     This is not a <P::typeURI> resource.
4069     @@@PerlDef:
4070 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
4071     $r = $self->{<Q::rdf:type>}->{$typeURI};
4072     } else {
4073     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
4074     keys %{$self->{<Q::rdf:type>}}) {
4075     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
4076     ($t_type_uri);
4077     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
4078     ($typeURI)) {
4079     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
4080     last;
4081     }
4082 wakaba 1.7 }
4083     }
4084 wakaba 1.8
4085     @Attr:
4086     @@Name: plName
4087     @@enDesc:
4088     The Perl name of this resource.
4089     @@Get:
4090     @@@Type:
4091 wakaba 1.18 DISLang:String::ManakaiDOM:all
4092 wakaba 1.8 @@@enDesc:
4093     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
4094     \
4095     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
4096     <CHAR::COLON> prefix).
4097     \
4098     - <Q::DISLang:Attribute>::: Method name.
4099     \
4100     - <Q::DISLang:Method>::: Method name.
4101     @@@nullCase:
4102     @@@@enDesc:
4103     Either the type of this resource is not listed above
4104     or this Perl constructure is anonymous.
4105     @@@RaiseException:
4106     @@@@@: NO_LOCAL_NAME_ERR
4107     @@@@enDesc:
4108     The type of this resource is either
4109     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
4110     the local name of this resource is not defined.
4111     @@@RaiseException:
4112     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
4113     @@@@enDesc:
4114     The Perl method name constructed from the source
4115     result in a reserved name.
4116     @@@PerlDef:
4117     __DEEP{
4118     if (exists $self->{<Q::dis2pm:name>}) {
4119     $r = $self->{<Q::dis2pm:name>};
4120     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4121     (<Q::ManakaiDOM:Const>) or
4122     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4123     (<Q::ManakaiDOM:ConstGroup>)) {
4124 wakaba 1.21 $r = uc $self->{localName};
4125 wakaba 1.8 unless (defined $r) {
4126     __UNDEEP{
4127     __EXCEPTION{NO_LOCAL_NAME_ERR::
4128 wakaba 1.18 DIS:uri => {$self->{uri}},
4129 wakaba 1.8 DIS:sourceNode => {$self->{src}},
4130     }__;
4131     }__;
4132     }
4133 wakaba 1.21 if ($r =~ /^_/ or $r =~ /_$/) {
4134     __UNDEEP{
4135     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4136     DIS:uri => {$self->{uri}},
4137     DIS:localName => {$self->{localName}},
4138     DIS:soruceNode => {$self->{src}},
4139     DIS:generatedName => {$r},
4140     }__;
4141     }__;
4142     }
4143 wakaba 1.8 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4144     (<Q::DISLang:Method>) or
4145     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4146     (<Q::DISLang:Attribute>)) {
4147     if (defined $self->{localName}) {
4148     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
4149     ($self->{localName});
4150     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4151     (<Q::ManakaiDOM:isForInternal>, false)) {
4152     $r = '_' . $r;
4153     }
4154     if ({
4155     import => 1,
4156     unimport => 1,
4157     isa => 1,
4158     can => 1,
4159     new => 1,
4160     as_string => 1,
4161     stringify => 1,
4162     clone => 1,
4163     }->{$r} or $r =~ /^___/) {
4164     __UNDEEP{
4165     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
4166     DIS:uri => {$self->{uri}},
4167     DIS:soruceNode => {$self->{src}},
4168     DIS:generatedName => {$r},
4169     }__;
4170     }__;
4171 wakaba 1.11 }
4172     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
4173 wakaba 1.8 .plMethodOperator>) {
4174     $r = {
4175     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
4176     <Q::DISPerl:AsStringMethod> => 'as_string',
4177 wakaba 1.16 <Q::DISPerl:NewMethod> => 'new',
4178     <Q::DISPerl:CloneMethod> => 'clone',
4179 wakaba 1.8 }->{$op_uri};
4180     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
4181     } else {
4182     $r = null;
4183     }
4184     } else {
4185     $r = null;
4186     }
4187     $self->{<Q::dis2pm:name>} = $r;
4188     }__;
4189    
4190     @Attr:
4191     @@Name: plFullyQualifiedName
4192     @@enDesc:
4193     The fully-qualified Perl name of this resource.
4194     @@Type:
4195     DISLang:String::ManakaiDOM:all
4196     @@Get:
4197     @@@enDesc:
4198     Fully-qualified name.
4199     \
4200     - <Q::ManakaiDOM:Class>::: Class package name.
4201     \
4202     - <Q::ManakaiDOM:IF>::: Interface package name.
4203     \
4204     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
4205     type symbol such as <CODE::$>).
4206     @@@nullCase:
4207     @@@@enDesc:
4208     Otherwise.
4209     @@@NoPerlModuleNameException:
4210     @@@RaiseException:
4211     @@@@@: NO_LOCAL_NAME_ERR
4212     @@@@enDesc:
4213     The local name of this resource is not defined.
4214     @@@PerlDef:
4215     __DEEP{
4216     if (exists $self->{<Q::dis2pm:name>}) {
4217     $r = $self->{<Q::dis2pm:name>};
4218     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4219     (<Q::ManakaiDOM:Class>) or
4220     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4221     (<Q::ManakaiDOM:IF>) or
4222     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4223     (<Q::DISPerl:ScalarVariable>)) {
4224 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4225 wakaba 1.8 (<Q::dis:AppName>, for_arg => $self->{for},
4226     forp_arg => $self->{forp},
4227     media_type => <Q::lang:Perl>);
4228     if ($an_node) {
4229     ## NOTE: "lang:Perl" is fully-qualified name by definition
4230 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4231 wakaba 1.8 } else {
4232 wakaba 1.10 unless (defined $self->{localName}) {
4233     __UNDEEP{
4234     __EXCEPTION{NO_LOCAL_NAME_ERR::
4235     DIS:sourceNode => {$self->{src}},
4236     }__;
4237     }__;
4238     }
4239 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4240     (<Q::ManakaiDOM:IF>)) {
4241     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
4242 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
4243 wakaba 1.8 . '::' . $self->{localName};
4244     } else {
4245     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
4246 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
4247 wakaba 1.8 . '::' . $self->{localName};
4248     }
4249     }
4250     } else {
4251     $r = null;
4252     }
4253     $self->{<Q::dis2pm:name>} = $r;
4254     }__;
4255    
4256     @Attr:
4257 wakaba 1.15 @@Name: plVariableName
4258     @@enDesc:
4259     The Perl variable name with prefix.
4260     @@Type:
4261     lang:Perl::ManakaiDOM:all
4262     @@Get:
4263     @@@nullCase:
4264     @@@@enDesc:
4265     This resource does not define any Perl variable.
4266     @@@PerlDef:
4267     $r = $self->{localName};
4268     if (defined $r) {
4269     __DEEP{
4270 wakaba 1.18 if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4271     (<Q::DISPerl:isNamedParameter>, false)) {
4272     $r = '$opt{' .
4273 wakaba 1.21 <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
4274     ($r) .
4275 wakaba 1.18 '}';
4276     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4277     (<Q::Perl:Array>)) {
4278     $r = '@' . $r;
4279     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4280     (<Q::Perl:Hash>)) {
4281     $r = '%' . $r;
4282     } else {
4283     $r = '$' . $r;
4284     }
4285     }__;
4286     }
4287    
4288     @Attr:
4289     @@Name: plPrototype
4290     @@enDesc:
4291     The Perl parameter prototype character.
4292     @@Type:
4293     lang:Perl::ManakaiDOM:all
4294     @@Get:
4295     @@@PerlDef:
4296     __DEEP{
4297 wakaba 1.15 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4298     (<Q::Perl:Array>)) {
4299     $r = '@' . $r;
4300     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4301     (<Q::Perl:Hash>)) {
4302     $r = '%' . $r;
4303     } else {
4304     $r = '$' . $r;
4305     }
4306     }__;
4307    
4308     @Attr:
4309 wakaba 1.8 @@Name: plMethodOperator
4310     @@enDesc:
4311     The operator to overload by this method.
4312     @@Type:
4313     DISLang:String::ManakaiDOM:all
4314     @@Get:
4315     @@@enDesc:
4316     The operator, either Perl <CODE::use operator> operator name
4317     of manakai operator URI reference.
4318     @@@nullCase:
4319     @@@@enDesc:
4320     Either this resource does not define a Perl method or
4321     this method does not overload any operator.
4322     @@@UndeclaredPrefixException:
4323     @@@RaiseException:
4324     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
4325     @@@@enDesc:
4326     Media type of the <Q::dis:Operator> node is not supported.
4327     @@@PerlDef:
4328     __DEEP{
4329     if (exists $self->{<Q::dis:Operator>}) {
4330     $r = $self->{<Q::dis:Operator>};
4331     } else {
4332     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4333     (<Q::dis:Operator>, for_arg => $self->{for},
4334     forp_arg => $self->{forp});
4335     if ($op_node) {
4336     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
4337 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
4338     for_arg => $self->{forp})) {
4339 wakaba 1.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4340 wakaba 1.8 } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
4341 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
4342     for_arg => $self->{forp})) {
4343 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
4344     } else {
4345 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
4346     (for_arg => $self->{for},
4347     forp_arg => $self->{forp});
4348 wakaba 1.8 __UNDEEP{
4349     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4350     DIS:uri => {$ct_uri},
4351 wakaba 1.10 DIS:sourceNode => {$op_node},
4352 wakaba 1.8 }__;
4353     }__;
4354     }
4355     } else {
4356     $r = null;
4357     }
4358     $self->{<Q::dis:Operator>} = $r;
4359     }
4360     }__;
4361    
4362     @Attr:
4363     @@Name: disDataTypeResource
4364     @@enDesc:
4365     <Q::dis:Type> attribute value of this resource.
4366     @@Type: ManakaiDISResourceDefinition
4367     @@Get:
4368     @@@RaiseException:
4369     @@@@@:NO_DIS_TYPE_ERR
4370     @@@@enDesc:
4371     <Q::dis:Type> attribute is not specified.
4372     @@@PerlDef:
4373     __DEEP{
4374     if (defined $self->{<Q::dis:Type>}) {
4375 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4376     ($self->{<Q::dis:Type>});
4377 wakaba 1.8 } else {
4378     $self->{<Q::dis2pm:TypeNode>}
4379     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4380     (<Q::dis:Type>, for_arg => $self->{for},
4381     forp_arg => $self->{forp});
4382     if ($self->{<Q::dis2pm:TypeNode>}) {
4383     $r = $self->{<Q::dis:Type>}
4384     = $self->{<Q::dis2pm:TypeNode>}
4385 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4386     (null, $self->{for});
4387     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4388     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4389     ($self->{<Q::dis2pm:TypeNode>});
4390 wakaba 1.8 } else {
4391     my $pr = $self-><M::ManakaiDISPropertyAccessor
4392     .getPropertyResource>
4393     (<Q::DIS:dynamicParentResource>);
4394     if ($pr) {
4395     $r = $pr-><AG::ManakaiDISResourceDefinition
4396     .disDataTypeResource>;
4397     $self->{<Q::dis2pm:TypeNode>}
4398     = $pr->{<Q::dis2pm:TypeNode>};
4399 wakaba 1.18 $self->{<Q::dis:Type>}
4400     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4401 wakaba 1.8 } else { ## No parent
4402     __UNDEEP{
4403     __EXCEPTION{NO_DIS_TYPE_ERR::
4404     DIS:sourceNode => {$self->{src}},
4405     }__;
4406     }__;
4407     }
4408     }
4409     }
4410     }__;
4411    
4412     @Attr:
4413     @@Name: disDataTypeNode
4414     @@enDesc:
4415     <Q::dis:Type> node for this resource.
4416     @@Get:
4417     @@@Type: ManakaiDISElement
4418     @@@RaiseException:
4419     @@@@@:NO_DIS_TYPE_ERR
4420     @@@@enDesc:
4421     <Q::dis:Type> attribute is not specified.
4422     @@@PerlDef:
4423     __DEEP{
4424 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disDataTypeResource>;
4425 wakaba 1.8 }__;
4426     $r = $self->{<Q::dis2pm:TypeNode>};
4427    
4428     @Attr:
4429     @@Name: disActualDataTypeResource
4430     @@enDesc:
4431     <Q::dis:actualType> attribute value of this resource.
4432     @@Type: ManakaiDISResourceDefinition
4433     @@Get:
4434     @@@RaiseException:
4435     @@@@@:NO_DIS_TYPE_ERR
4436     @@@@enDesc:
4437     <Q::dis:actualType> attribute is not specified,
4438     and <Q::dis:Type> attribute, neigher.
4439     @@@PerlDef:
4440     __DEEP{
4441     if (defined $self->{<Q::dis:actualType>}) {
4442 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4443     ($self->{<Q::dis:actualType>});
4444 wakaba 1.8 } else {
4445     $self->{<Q::dis2pm:actualTypeNode>}
4446     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4447     (<Q::dis:actualType>, for_arg => $self->{for},
4448     forp_arg => $self->{forp});
4449     if ($self->{<Q::dis2pm:actualTypeNode>}) {
4450     $r = $self->{<Q::dis:actualType>}
4451     = $self->{<Q::dis2pm:actualTypeNode>}
4452 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4453     (null, $self->{for});
4454     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4455     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4456     ($self->{<Q::dis2pm:actualTypeNode>});
4457 wakaba 1.8 } elsif (defined $self->{<Q::dis:Type>}) {
4458     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
4459     $self->{<Q::dis2pm:actualTypeNode>}
4460     = $self->{<Q::dis2pm:TypeNode>};
4461 wakaba 1.18 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4462 wakaba 1.8 } else {
4463     $self->{<Q::dis2pm:actualTypeNode>}
4464     = $self->{<Q::dis2pm:TypeNode>}
4465     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4466     (<Q::dis:Type>, for_arg => $self->{for},
4467     forp_arg => $self->{forp});
4468     if ($self->{<Q::dis2pm:TypeNode>}) {
4469     $r = $self->{<Q::dis:actualType>}
4470     = $self->{<Q::dis:Type>}
4471     = $self->{<Q::dis2pm:TypeNode>}
4472 wakaba 1.18 -><M::ManakaiDISElement.tfqnamesValueURI>
4473     (null, $self->{for});
4474     $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
4475     $r-><AS::ManakaiDISResourceDefinition.isReferred>
4476     ($self->{<Q::dis2pm:actualTypeNode>});
4477 wakaba 1.8 } else {
4478     my $pr = $self-><M::ManakaiDISPropertyAccessor
4479     .getPropertyResource>
4480     (<Q::DIS:dynamicParentResource>);
4481     if ($pr) {
4482 wakaba 1.18 $r = $pr-><AG::ManakaiDISResourceDefinition
4483 wakaba 1.8 .disActualDataTypeResource>;
4484     $self->{<Q::dis2pm:actualTypeNode>}
4485     = $pr->{<Q::dis2pm:actualTypeNode>};
4486 wakaba 1.18 $self->{<Q::dis:actualType>}
4487     = $r-><AG::ManakaiDISResourceDefinition.uri>;
4488 wakaba 1.8 } else { ## No parent
4489     __UNDEEP{
4490     __EXCEPTION{NO_DIS_TYPE_ERR::
4491     DIS:sourceNode => {$self->{src}},
4492     }__;
4493     }__;
4494     }
4495     }
4496     }
4497     }
4498     }__;
4499    
4500     @Attr:
4501     @@Name: disActualDataTypeNode
4502     @@enDesc:
4503     <Q::dis:actualType> node for this resource.
4504     @@Get:
4505     @@@Type: ManakaiDISElement
4506     @@@RaiseException:
4507     @@@@@:NO_DIS_TYPE_ERR
4508     @@@@enDesc:
4509     <Q::dis:actualType> attribute is not specified,
4510     and <Q::dis:Type> attribute, neigher.
4511     @@@PerlDef:
4512     __DEEP{
4513 wakaba 1.18 $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeResource>;
4514 wakaba 1.8 }__;
4515     $r = $self->{<Q::dis2pm:actualTypeNode>};
4516 wakaba 1.9
4517     @IntMethod:
4518     @@Operator:
4519     @@@@: <=>
4520     @@@ContentType:
4521     lang:Perl
4522     @@enDesc:
4523     Which is greater (i.e. the spaceship operator).
4524     A resource is less than another if it is loaded by
4525     <M::ManakaiDISDatabase.loadResource> before another is loaded.
4526     Order for non-loaded resource definitions are not defined.
4527     \
4528     {NOTE:: In the current implementation, non-loaded resources
4529     are less than any loaded resource and the order in
4530     non-loaded resources is unknown.
4531     \
4532     }
4533     @@Param:
4534     @@@Name: anotherResource
4535     @@@Type: ManakaiDISResourceDefinition
4536     @@@enDesc: Another resource to compare.
4537     @@Return:
4538     @@@Type:
4539 wakaba 1.18 DOMMain:unsigned-long::ManakaiDOM:all
4540 wakaba 1.9 @@@PerlDef:
4541     if (UNIVERSAL::isa ($anotherResource,
4542     <ClassName::ManakaiDISResourceDefinition>)) {
4543     $r = $self->{seq} <=> $anotherResource->{seq};
4544     } else {
4545     $r = overload::Overloaded ($self) <=> $anotherResource;
4546     }
4547 wakaba 1.12
4548     @Attr:
4549     @@Name: plCodeFragment
4550     @@enDesc:
4551     Perl code definition fragment of this resource.
4552     @@Type: MPLCodeFragment
4553     @@Get:
4554     @@@enDesc:
4555     Perl code.
4556     @@@nullCase:
4557     @@@@enDesc:
4558     This node does not have Perl code definition.
4559     @@@RaiseException:
4560     @@@@@:NO_METHOD_RETURN_ERR
4561     @@@@enDesc:
4562     This resource is a <Q::DISLang:Method> but it does not
4563     have <Q::DISLang:MethodReturn> child-resource.
4564     @@@RaiseException:
4565     @@@@@:NO_ATTR_GET_ERR
4566     @@@@enDesc:
4567     This resource is a <Q::DISLang:Attribute> but it does not
4568     have <Q::DISLang:AttributeGet> child-resource.
4569     @@@RaiseException:
4570     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4571     @@@@enDesc:
4572     The media type of <Q::dis:Def> element is not supported.
4573 wakaba 1.18 @@@RaiseException:
4574     @@@@@: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
4575     @@@@enDesc:
4576     A non-named method paarameter is defined after
4577     a named method parameter appeared.
4578 wakaba 1.19 @@@disPerlException:
4579     @@@InlineElementException:
4580     @@@BlockElementException:
4581 wakaba 1.20 @@@RaiseException:
4582     @@@@@:PERL_SUBROUTINE_ALREADY_DEFINED_ERR
4583     @@@@enDesc:
4584     A resource defines a Perl subroutine whose name is
4585     same as the name of another subroutine.
4586     @@@RaiseException:
4587     @@@@@:PERL_OPERATOR_ALREADY_OVERLOADED_ERR
4588     @@@@enDesc:
4589     A resource is defined to overload an operator
4590     that is also defined to be overloaded by another resource.
4591     @@@RaiseException:
4592     @@@@@:PERL_UNUSED_SUBROUTINE_ERR
4593     @@@@enDesc:
4594     A resource defines a Perl subroutine which is not
4595     used anywhere.
4596 wakaba 1.12 @@@PerlDef:
4597     __DEEP{
4598     if (exists $self->{<Q::plCodeFragment>}) {
4599     $r = $self->{<Q::plCodeFragment>};
4600     } elsif (not $self->{src}) {
4601     $r = $self->{<Q::plCodeFragment>} = null;
4602     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4603     (<Q::DISLang:MethodReturn>) or
4604     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4605     (<Q::DISLang:AttributeGet>) or
4606     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4607 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
4608     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4609     (<Q::dis2pm:BlockCode>) or
4610     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4611 wakaba 1.18 (<Q::dis2pm:InlineCode>) or
4612     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4613     (<Q::DISLang:InputProcessor>)) {
4614 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4615 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4616     (<Q::dis:Def>, for_arg => $self->{for},
4617     forp_arg => $self->{forp});
4618 wakaba 1.19 my $is_inline = $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4619     (<Q::dis2pm:InlineCode>) ? true : false;
4620     unless ($def) {
4621     $r = null;
4622     } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4623     (<Q::lang:Perl>)) {
4624 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
4625     ::swcfg21:ForLatest.value>;
4626 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4627 wakaba 1.19 = $is_inline
4628     ? $self-><M::ManakaiDISResourceDefinition
4629     .plPreprocessPerlStatement>
4630     ($source_code,
4631     node => $def,
4632     contains_statements => false)
4633     : $self-><M::ManakaiDISResourceDefinition
4634 wakaba 1.17 .plPreprocessPerlCode> ($source_code,
4635     node => $def);
4636 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4637     (<Q::lang:dis>)) {
4638     $r = $self->{<Q::plCodeFragment>}
4639 wakaba 1.19 = $def-><M::ManakaiDISElement.plCodeFragment>
4640     ($self, for_arg => $self->{for},
4641     forp_arg => $self->{forp},
4642     contains_statements => not $is_inline);
4643 wakaba 1.12 } else {
4644     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
4645     (for_arg => $self->{for},
4646     forp_arg => $self->{forp});
4647     __UNDEEP{
4648     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4649     DIS:uri => {$mt},
4650     DIS:sourceNode => {$def},
4651     }__;
4652     }__;
4653     } # media type
4654     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4655     (<Q::DISLang:Method>)) {
4656 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4657 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
4658     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
4659     unless ($ret) {
4660     __UNDEEP{
4661     __EXCEPTION{NO_METHOD_RETURN_ERR::
4662     DIS:errResource => {$self},
4663     DIS:sourceNode => {$self->{src}},
4664     }__;
4665     }__;
4666     }
4667 wakaba 1.18 my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4668     .plImplementation>;
4669 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4670 wakaba 1.18 = $plimpl-><M::MPLImpl.createPerlSub>
4671 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
4672    
4673 wakaba 1.18 ## Method parameters
4674     my $params = $self-><M::ManakaiDISPropertyAccessor
4675     .getPropertyResourceList>
4676     (<Q::DIS:childResource>);
4677     my @param_variables;
4678     my @named_param_variables;
4679     my $prototype = '$';
4680     my $is_optional_param = false;
4681     my $is_named_param = false;
4682     for my $param (@$params) {
4683     next unless $param-><M::ManakaiDISResourceDefinition.isTypeURI>
4684     (<Q::DISLang:MethodParameter>);
4685     unless ($is_named_param) {
4686     if ($param-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
4687     (<Q::DISPerl:isNamedParameter>, false)) {
4688     $is_named_param = true;
4689     $is_optional_param = true;
4690     push @param_variables, ['%opt'];
4691     $prototype .= '%';
4692     } else { ## Non-named parameter
4693     push @param_variables, [
4694     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
4695     ];
4696     if ($param-><AG::ManakaiDISResourceDefinition.plIsNullable>) {
4697     $prototype .= ';' unless $is_optional_param;
4698     $is_optional_param = true;
4699     }
4700     $prototype .= $param-><AG::ManakaiDISResourceDefinition
4701     .plPrototype>;
4702     my $param_processor
4703     = $param-><M::ManakaiDISResourceDefinition
4704     .plGetMethodInputNormalizer>;
4705     if ($param_processor) {
4706     $param_variables[-1]->[1]
4707     = $param_processor-><AG::ManakaiDISResourceDefinition
4708     .plCodeFragment>->clone;
4709     $param_variables[-1]->[1]
4710     -><M::MPLCodeFragment.replaceVariable>
4711     ('$INPUT' => $param_variables[-1]->[0]);
4712     }
4713     }
4714     } else { ## Named parameter
4715     unless ($param-><M::ManakaiDISPropertyAccessor
4716     .getPropertyBoolean>
4717     (<Q::DISPerl:isNamedParameter>, false)) {
4718     __UNDEEP{__EXCEPTION{NON_NAMED_PARAMETER_AFTER_NAMED_ERR::
4719     DIS:sourceNode => {$param->{src}},
4720     DIS:uri => {$param->{uri}},
4721     DIS:localName => {$param->{localName}},
4722     }__}__;
4723     }
4724     }
4725     if ($is_named_param) {
4726     push @named_param_variables, [
4727     $param-><AG::ManakaiDISResourceDefinition.plVariableName>,
4728     null,
4729     '$' . $param-><AG::ManakaiDISResourceDefinition.localName>,
4730     ];
4731     my $param_processor
4732     = $param-><M::ManakaiDISResourceDefinition
4733     .plGetMethodInputNormalizer>;
4734     if ($param_processor) {
4735     $named_param_variables[-1]->[1]
4736     = $param_processor-><AG::ManakaiDISResourceDefinition
4737     .plCodeFragment>->clone;
4738     $named_param_variables[-1]->[1]
4739     -><M::MPLCodeFragment.replaceVariable>
4740     ('$INPUT' => $param_variables[-1]->[0]);
4741     }
4742     }
4743     } # %$params
4744    
4745     $r-><AS::MPLSub.prototype> ($prototype);
4746 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
4747 wakaba 1.18 ($plimpl-><M::MPLImpl.createPerlStatement>
4748     ('my (' . join (', ', '$self',
4749     map {$_->[0]} @param_variables) . ') = @_'));
4750     for my $p (@param_variables, @named_param_variables) {
4751     if ($p->[1]) { ## Input processor
4752     $r-><M::MPLSS.appendCodeFragment> ($p->[1]);
4753     }
4754     }
4755    
4756     ## TODO: in/out
4757    
4758     ## Return value
4759     my $data_type;
4760     try {
4761     $data_type = $ret-><AG::ManakaiDISResourceDefinition
4762     .disActualDataTypeResource>;
4763     } catch <Class::ManakaiDISException> with {
4764     my $err = shift;
4765     if ($err->{<Q::MDOMX:subtype>} ne <Q::NO_DIS_TYPE_ERR>) {
4766     $err->throw;
4767     }
4768     };
4769    
4770     if ($data_type) {
4771     my $def = $ret->{src}-><M::ManakaiDISElement
4772     .plValueCodeFragment>
4773     (<Q::dis:DefaultValue>, $self->{db},
4774     for_arg => $self->{for},
4775     forp_arg => $self->{forp},
4776     use_default_value => true,
4777     data_type_uri => $data_type
4778     -><AG::ManakaiDISResourceDefinition.uri>);
4779     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
4780     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
4781     ('$', null, 'r');
4782     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
4783     .variableScope> ('my');
4784     if ($def) {
4785     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
4786     } else {
4787     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
4788     }
4789     $r-><M::MPLSS.appendCodeFragment> ($rs);
4790     }
4791    
4792     my $code = $ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
4793 wakaba 1.19 if ($code) {
4794     for my $np (@named_param_variables) {
4795     $code-><M::MPLCodeFragment.replaceVariable>
4796     ($np->[2] => $np->[0]);
4797     }
4798     $r-><M::MPLSS.appendCodeFragment> ($code);
4799    
4800     $ret->{<Q::DIS:plDefined>} = true;
4801     $self->{<Q::DIS:plDefined>} = true;
4802 wakaba 1.21 } else { ## Method code not defined
4803 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4804     (<Q::DOMException:CoreException>,
4805     for_arg => <Q::ManakaiDOM:Perl>);
4806     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4807     (<Q::DOMException:NOT_SUPPROTED_ERR>,
4808     for_arg => <Q::ManakaiDOM:Perl>);
4809     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4810     (<Q::MDOMX:MDOM_IMPL_METHOD_NOT_IMPLEMENTED>,
4811     for_arg => <Q::ManakaiDOM:Perl>);
4812     $_-><AS::ManakaiDISResourceDefinition.isReferred>
4813     ($ret->{src}) for $cls, $const, $subtype;
4814     my $context_param = $ret-><M::ManakaiDISResourceDefinition
4815     .plGetContextParameter>;
4816     $self-><M::ManakaiDISResourceDefinition
4817     .plAppendThrow>
4818     ($r, $cls, $const, $subtype,
4819     {%$context_param});
4820     $ret->{<Q::DIS:plDefined>} = false;
4821     $self->{<Q::DIS:plDefined>} = false;
4822 wakaba 1.18 }
4823 wakaba 1.12
4824 wakaba 1.18 if ($data_type) {
4825     $r-><M::MPLSS.appendCodeFragment>
4826     ($plimpl-><M::MPLImpl.createPerlVariable>
4827     ('$', null, 'r'));
4828     }
4829 wakaba 1.12 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4830     (<Q::DISLang:Attribute>)) {
4831 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4832 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
4833     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
4834     unless ($get) {
4835     __UNDEEP{
4836     __EXCEPTION{NO_ATTR_GET_ERR::
4837     DIS:errResource => {$self},
4838     DIS:sourceNode => {$self->{src}},
4839     }__;
4840     }__;
4841     }
4842 wakaba 1.20 my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4843     .plImplementation>;
4844 wakaba 1.19 my $data_type = $get-><AG::ManakaiDISResourceDefinition
4845     .disActualDataTypeResource>;
4846     my $get_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
4847 wakaba 1.21 $get_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
4848 wakaba 1.19 my $code = $get-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
4849     if ($code) {
4850     ## Default value
4851     my $def = $get->{src}-><M::ManakaiDISElement
4852     .plValueCodeFragment>
4853     (<Q::dis:DefaultValue>, $self->{db},
4854     for_arg => $self->{for},
4855     forp_arg => $self->{forp},
4856     use_default_value => true,
4857     data_type_uri => $data_type
4858     -><AG::ManakaiDISResourceDefinition.uri>);
4859     my $rs = $plimpl-><M::MPLImpl.createPerlStatement>;
4860     my $rvar = $plimpl-><M::MPLImpl.createPerlVariable>
4861     ('$', null, 'r');
4862     $rvar-><AS::PerlCode:ManakaiPerlVariable::ManakaiDOM:Perl
4863     .variableScope> ('my');
4864     if ($def) {
4865     $rs-><M::PLAnyCon.appendNewAssignment> ($rvar => $def);
4866     } else {
4867     $rs-><M::PLInCon.appendCodeFragment> ($rvar);
4868     }
4869     $get_code-><M::PLBlockCon.appendCodeFragment> ($rs);
4870    
4871     ## Main code
4872     $get_code-><M::PLBlockCon.appendCodeFragment> ($code);
4873    
4874     ## Return value
4875     $get_code-><M::PLBlockCon.appendStatement> (q<$r>);
4876    
4877     $get->{<Q::DIS:plDefined>} = true;
4878     } else { ## Getter code not defined
4879     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4880     (<Q::DOMException:CoreException>,
4881     for_arg => <Q::ManakaiDOM:Perl>);
4882     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4883     (<Q::DOMException:NOT_SUPPROTED_ERR>,
4884     for_arg => <Q::ManakaiDOM:Perl>);
4885     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4886     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
4887     for_arg => <Q::ManakaiDOM:Perl>);
4888     $_-><AS::ManakaiDISResourceDefinition.isReferred>
4889     ($get->{src}) for $cls, $const, $subtype;
4890     my $context_param = $get-><M::ManakaiDISResourceDefinition
4891     .plGetContextParameter>;
4892     $self-><M::ManakaiDISResourceDefinition
4893     .plAppendThrow>
4894     ($get_code, $cls, $const, $subtype,
4895     {%$context_param});
4896     $get->{<Q::DIS:plDefined>} = false;
4897     $self->{<Q::DIS:plDefined>} = false;
4898     }
4899    
4900     my $set = $self-><M::ManakaiDISResourceDefinition
4901     .getChildResourceByType> (<Q::DISLang:AttributeSet>);
4902     my $set_code = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
4903     if ($set) {
4904     my $data_type = $set-><AG::ManakaiDISResourceDefinition
4905     .disActualDataTypeResource>;
4906     my $code = $set-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
4907     if ($code) {
4908     ## Input
4909     $set_code-><M::PLBlockCon.appendStatement>
4910     (q<my ($self, $given) = @_>);
4911     my $param_processor
4912     = $set-><M::ManakaiDISResourceDefinition
4913     .plGetMethodInputNormalizer>;
4914     if ($param_processor) {
4915     my $pcode = $param_processor-><AG::ManakaiDISResourceDefinition
4916     .plCodeFragment>->clone;
4917     $pcode-><M::MPLCodeFragment.replaceVariable>
4918     ('$INPUT' => '$given');
4919     $set_code-><M::PLBlockCon.appendCodeFragment> ($pcode);
4920     }
4921    
4922     ## Main code
4923     $set_code-><M::PLBlockCon.appendCodeFragment> ($code);
4924    
4925     $set->{<Q::DIS:plDefined>} = true;
4926     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
4927     } else { ## Setter code not defined
4928 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
4929 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4930     (<Q::DOMException:CoreException>,
4931     for_arg => <Q::ManakaiDOM:Perl>);
4932     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4933     (<Q::DOMException:NOT_SUPPROTED_ERR>,
4934     for_arg => <Q::ManakaiDOM:Perl>);
4935     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4936     (<Q::MDOMX:MDOM_IMPL_ATTR_NOT_IMPLEMENTED>,
4937     for_arg => <Q::ManakaiDOM:Perl>);
4938     $_-><AS::ManakaiDISResourceDefinition.isReferred>
4939     ($set->{src}) for $cls, $const, $subtype;
4940     my $context_param = $get-><M::ManakaiDISResourceDefinition
4941     .plGetContextParameter>;
4942     $self-><M::ManakaiDISResourceDefinition
4943     .plAppendThrow>
4944     ($set_code, $cls, $const, $subtype,
4945     {%$context_param});
4946     }
4947     $set->{<Q::DIS:plDefined>} = false;
4948     $self->{<Q::DIS:plDefined>} = false;
4949     } else { ## No attribute setter
4950 wakaba 1.21 $set_code-><M::PLBlockCon.appendStatement> (q<my ($self) = @_>);
4951 wakaba 1.19 my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4952     (<Q::DOMException:CoreException>,
4953     for_arg => <Q::ManakaiDOM:Perl>);
4954     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4955     (<Q::DOMException:NO_MODIFICATION_ALLOWED_ERR>,
4956     for_arg => <Q::ManakaiDOM:Perl>);
4957     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4958     (<Q::DOMException:READ_ONLY_ATTRIBUTE_ERR>,
4959     for_arg => <Q::ManakaiDOM:Perl>);
4960     $_-><AS::ManakaiDISResourceDefinition.isReferred>
4961     ($self->{src}) for $cls, $const, $subtype;
4962     my $context_param = $get-><M::ManakaiDISResourceDefinition
4963     .plGetContextParameter>;
4964     $self-><M::ManakaiDISResourceDefinition
4965     .plAppendThrow>
4966     ($set_code, $cls, $const, $subtype,
4967     {%$context_param});
4968     $self->{<Q::DIS:plDefined>} = $get->{<Q::DIS:plDefined>};
4969     }
4970    
4971 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4972 wakaba 1.19 = $plimpl-><M::MPLImpl.createPerlSub>
4973 wakaba 1.12 ($self-><AG::ManakaiDISResourceDefinition.plName>);
4974 wakaba 1.19 $r-><AS::MPLSub.prototype> (q<$;$>);
4975 wakaba 1.12
4976 wakaba 1.19 ## TODO: Don't output "if" if non-debug build
4977 wakaba 1.12
4978 wakaba 1.19 $r-><M::PLBlockCon.appendNewIf>
4979     ($plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4980     (q<@_ == 1>),
4981     $get_code,
4982     $set_code);
4983 wakaba 1.20 } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4984 wakaba 1.21 (<Q::ManakaiDOM:Const>)) {
4985     my $data_type = $self-><AG::ManakaiDISResourceDefinition
4986     .disActualDataTypeResource>;
4987     my $value = $self->{src}
4988     -><M::ManakaiDISElement.plValueCodeFragment>
4989     (<Q::dis:Value>, $self->{db},
4990     for_arg => $self->{for},
4991     forp_arg => $self->{forp},
4992     data_type_uri => $data_type
4993     -><AG::ManakaiDISResourceDefinition.uri>);
4994     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4995     .plImplementation>;
4996     $r = $plimpl-><M::MPLImpl.createPerlSub>
4997     ($self-><AG::ManakaiDISResourceDefinition.plName>);
4998     $r-><M::PLBlockCon.appendCodeFragment> ($value);
4999     $r-><AS::MPLSub.prototype> ('');
5000     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5001 wakaba 1.20 (<Q::ManakaiDOM:Class>)) {
5002     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
5003     .plImplementation>;
5004     $r = $plimpl-><M::MPLImpl.createPerlPackage>
5005     ($self-><AG::ManakaiDISResourceDefinition
5006     .plFullyQualifiedName>);
5007     ## This class inherits...
5008     for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5009     .getPropertyResourceList>
5010     (<Q::dis:ISA>,
5011     default_media_type => <Q::dis:TFQNames>)}) {
5012     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5013     .plFullyQualifiedName>;
5014     if (defined $spack_name) {
5015     $r-><M::PLPack.addISAPackage> ($spack_name);
5016     }
5017     }
5018     ## This class implements...
5019     for my $scls (@{$self-><M::ManakaiDISPropertyAccessor
5020     .getPropertyResourceList>
5021     (<Q::dis:Implement>, recursive_isa => true,
5022     default_media_type => <Q::dis:TFQNames>)}) {
5023     my $spack_name = $scls-><AG::ManakaiDISResourceDefinition
5024     .plFullyQualifiedName>;
5025     if (defined $spack_name) {
5026     $r-><M::PLPack.addImplementPackage> ($spack_name);
5027     }
5028     }
5029    
5030     ## TODO: Use's
5031    
5032     ## Class members
5033     my @cr = @{$self-><M::ManakaiDISPropertyAccessor
5034     .getPropertyResourceList>
5035     (<Q::DIS:childResource>)};
5036 wakaba 1.21 my @const;
5037 wakaba 1.20 for my $cr (@cr) {
5038     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5039     (<Q::DISLang:Method>) or
5040     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5041     (<Q::DISLang:Attribute>)) {
5042     my $is_attr = $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5043     (<Q::DISLang:Attribute>) ? true : false;
5044     my $pname = $cr-><AG::ManakaiDISResourceDefinition.plName>;
5045     my $op = $cr-><AG::ManakaiDISResourceDefinition
5046     .plMethodOperator>;
5047     my $psub = $cr-><AG::ManakaiDISResourceDefinition
5048     .plCodeFragment>;
5049     if (defined $pname) {
5050     if ($r-><M::PLPack.getSub> ($pname)) {
5051     __UNDEEP{__EXCEPTION{PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5052     PerlCode:localName => {$pname},
5053     DIS:uri => {$cr->{uri}},
5054     DIS:sourceNode => {$cr->{src}},
5055     }__}__;
5056     }
5057     $r-><M::PLPack.setSub> ($pname => $psub);
5058    
5059     if (defined $op and not $cr-><AG::ManakaiDISResourceDefinition
5060     .isAnonymous>) {
5061     if ($op =~ /^[A-Z]+$/) {
5062     if ($r-><M::PLPack.getSubAliasName> ($op)) {
5063     __UNDEEP{__EXCEPTION{
5064     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5065     PerlCode:localName => {$op},
5066     DIS:uri => {$cr->{uri}},
5067     DIS:sourceNode => {$cr->{src}},
5068     }__}__;
5069     }
5070     $r-><M::PLPack.setSubAliasName> ($op => $pname);
5071     } else {
5072     if ($r-><M::PLPack.getOverloadMethodName> ($op)) {
5073     __UNDEEP{__EXCEPTION{
5074     PERL_OPERATOR_ALREADY_OVERLOADED_ERR::
5075     PerlCode:operator => {$op},
5076     DIS:uri => {$cr->{uri}},
5077     DIS:sourceNode => {$cr->{src}},
5078     }__}__;
5079     }
5080     $r-><M::PLPack.setOverloadMethodName> ($op => $pname);
5081     }
5082     }
5083     } elsif (defined $op) {
5084     $r-><M::PLPack.setOverloadSub> ($op => $psub);
5085     } else {
5086     __UNDEEP{__EXCEPTION{PERL_UNUSED_SUBROUTINE_ERR::
5087     DIS:uri => {$cr->{uri}},
5088     DIS:sourceNode => {$cr->{src}},
5089     }__}__;
5090     }
5091 wakaba 1.21 } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5092     (<Q::ManakaiDOM:ConstGroup>)) {
5093     for my $gcr (@{$cr-><M::ManakaiDISPropertyAccessor
5094     .getPropertyResourceList>
5095     (<Q::DIS:childResource>)}) {
5096     if ($gcr-><M::ManakaiDISResourceDefinition.isTypeURI>
5097     (<Q::ManakaiDOM:Const>)) {
5098     my $sub = $gcr-><AG::ManakaiDISResourceDefinition
5099     .plCodeFragment>;
5100     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5101     __UNDEEP{__EXCEPTION{
5102     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5103     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5104     DIS:uri => {$gcr->{uri}},
5105     DIS:sourceNode => {$gcr->{src}},
5106     }__}__;
5107     }
5108     $r-><M::PLPack.setSub>
5109     ($sub-><AG::MPLSub.localName> => $sub);
5110     push @const, $gcr;
5111     }
5112     }
5113     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5114     (<Q::ManakaiDOM:Const>)) {
5115     my $sub = $cr-><AG::ManakaiDISResourceDefinition.plCodeFragment>;
5116     if ($r-><M::PLPack.getSub> ($sub-><AG::MPLSub.localName>)) {
5117     __UNDEEP{__EXCEPTION{
5118     PERL_SUBROUTINE_ALREADY_DEFINED_ERR::
5119     PerlCode:localName => {$sub-><AG::MPLSub.localName>},
5120     DIS:uri => {$cr->{uri}},
5121     DIS:sourceNode => {$cr->{src}},
5122     }__}__;
5123     }
5124     $r-><M::PLPack.setSub> ($sub-><AG::MPLSub.localName> => $sub);
5125     push @const, $cr;
5126 wakaba 1.20 }
5127     }
5128 wakaba 1.21 ## TODO: variables
5129    
5130     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5131     (<Q::DOMException:AnyExceptionClass>)) {
5132     my $err_def = $plimpl-><M::MPLImpl.createPerlSub> ('___error_def');
5133     $err_def-><AS::MPLSub.prototype> ('');
5134     $err_def-><M::PLBlockCon.appendCode>
5135     ($plimpl-><M::MPLImpl.perlList>
5136     ([{
5137     map {
5138     $_-><AG::ManakaiDISResourceDefinition.plName> => {
5139     <Q::DOMCore:code> => 0 + $_
5140     -><AG::ManakaiDISResourceDefinition.plCodeFragment>,
5141     description => $_
5142     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
5143     # ($_->{ExpandedURI q< DOMCore:severity>}
5144     # ? (ExpandedURI q< DOMCore:severity>
5145     # => $_->{ExpandedURI q< DOMCore:severity>},
5146     # ExpandedURI q< DOMCore:type>
5147     # => $_->{ExpandedURI q< DOMCore:type>})
5148     # : ()),
5149     <Q::MDOMX:subtype> => {
5150     map {
5151     $_-><AG::ManakaiDISResourceDefinition.nameURI>
5152     => {
5153     description => $_
5154     -><AG::ManakaiDISResourceDefinition.plMufDescriptionText>,
5155     # ($_->{ExpandedURI q< DOMCore:severity>}
5156     # ? (ExpandedURI q< DOMCore:severity>
5157     # => $_->{ExpandedURI q< DOMCore:severity>},
5158     # ExpandedURI q< DOMCore:type>
5159     # => $_->{ExpandedURI q< DOMCore:type>})
5160     # : ()),
5161     },
5162     } grep {
5163     $_-><M::ManakaiDISResourceDefinition.isTypeURI>
5164     (<Q::ManakaiDOM:ExceptionOrWarningSubType>)
5165     } @{$_-><M::ManakaiDISPropertyAccessor
5166     .getPropertyResourceList>
5167     (<Q::DIS:childResource>)}
5168     },
5169     },
5170     } @const
5171     }]));
5172     $r-><M::PLPack.setSub> (___error_def => $err_def);
5173     }
5174 wakaba 1.13 } else { ## Not supported
5175 wakaba 1.19 $r = $self->{<Q::plCodeFragment>} = null;
5176 wakaba 1.12 } # rdf:type
5177     }__;
5178    
5179     @Attr:
5180     @@Name:plImplementation
5181     @@enDesc:
5182     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
5183     @@Type: MPLImpl
5184     @@Get:
5185     @@@enDesc:
5186     The Perl code implementation object.
5187     @@@nullCase:
5188     This resource has no source tree associated.
5189     @@@RaiseException:
5190     @@@@@:NO_PERL_CODE_IMPL_ERR
5191     @@@@enDesc:
5192     There is no implementation that implements
5193     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
5194     @@@PerlDef:
5195     if ($self->{src}) {
5196     __DEEP{
5197     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
5198     $self->{src})-><AG::SWCFGDoc.implementation>
5199     -><M::DOMMinImpl.getFeature>
5200     (<Q::Util:PerlCode> => '1.0');
5201     }__;
5202     unless (defined $r) {
5203     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
5204    
5205     }__;
5206     }
5207     }
5208    
5209     @Method:
5210     @@Name: getChildResourceByType
5211     @@enDesc:
5212     Gets a static child resource selected by its type.
5213     @@Param:
5214     @@@Name:typeURI
5215     @@@Type:ResourceURI
5216     @@@enDesc:
5217     A URI reference identifying a resource type.
5218     @@Return:
5219     @@@Type: ManakaiDISResourceDefinition
5220     @@@enDesc:
5221     The first (by document order) child resource whose
5222     type matches with <P::resType>.
5223     @@@nullCase:
5224     @@@@enDesc:
5225     There is no resource whose type is <P::resType>.
5226     @@@PerlDef:
5227     __DEEP{
5228     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5229     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5230     ($cr_uri);
5231     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
5232     $r = $cr;
5233     last;
5234     }
5235     }
5236     }__;
5237 wakaba 1.13
5238     @Method:
5239     @@Name: getChildResourceByNameAndType
5240     @@enDesc:
5241     Gets a static child resource selected by its local name and type.
5242     @@Param:
5243     @@@Name: localName
5244     @@@Type:
5245     DISCore:LocalName::ManakaiDOM:all
5246     @@@enDesc:
5247     A local name.
5248     @@Param:
5249     @@@Name:typeURI
5250     @@@Type:ResourceURI
5251     @@@enDesc:
5252     A URI reference identifying a resource type.
5253     @@Return:
5254     @@@Type: ManakaiDISResourceDefinition
5255     @@@enDesc:
5256     The first (by document order) child resource whose
5257     type matches for <P::localName> and <P::resType>.
5258     @@@nullCase:
5259     @@@@enDesc:
5260     There is no resource whose name is <P::localName> and
5261     whose type is <P::resType>.
5262     @@@PerlDef:
5263     __DEEP{
5264     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5265     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5266     ($cr_uri);
5267 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
5268 wakaba 1.13 if (defined $ln and $ln eq $localName and
5269     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
5270     $r = $cr;
5271     last;
5272     }
5273     }
5274     }__;
5275    
5276     @Method:
5277     @@Name: getConstResourceByName
5278     @@enDesc:
5279     Gets a constant value resource by its local name.
5280     @@Param:
5281     @@@Name:localName
5282     @@@Type:
5283     DISLang:String::ManakaiDOM:all
5284     @@@enDesc:
5285     Constant name.
5286     @@Return:
5287     @@@Type: ManakaiDISResourceDefinition
5288     @@@enDesc:
5289     The constant resource identified by <P::localName>.
5290     @@@nullCase:
5291     @@@@enDesc:
5292     There is no such constant resource.
5293     @@@PerlDef:
5294     __DEEP{
5295     my @constGroup;
5296     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
5297     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
5298     ($cr_uri);
5299 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
5300 wakaba 1.13 if ($ln and $ln eq $localName and
5301     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5302     (<Q::ManakaiDOM:Const>)) {
5303     $r = $cr;
5304     last;
5305     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
5306     (<Q::ManakaiDOM:ConstGroup>)) {
5307     push @constGroup, $cr;
5308     }
5309     }
5310     unless ($r) {
5311     for my $cg (@constGroup) {
5312     $r = $cg-><M::ManakaiDISResourceDefinition
5313     .getChildResourceByNameAndType>
5314     ($localName, <Q::ManakaiDOM:Const>);
5315     last if $r;
5316     }
5317     }
5318     }__;
5319    
5320     @Method:
5321     @@Name: plPreprocessPerlCode
5322     @@enDesc:
5323     Preprocesses a Perl block-level code fragment.
5324     @@Param:
5325     @@@Name:codeArg
5326     @@@Type:
5327     lang:Perl::ManakaiDOM:all
5328     @@@enDesc:
5329     A Perl block-level code (statements and/or blocks).
5330 wakaba 1.15 @@NodeParam:
5331     @@NamedParam:
5332     @@@Name:methodResource
5333     @@@Type:ManakaiDISResourceDefinition
5334     @@@enDesc:
5335     The resource definition of the Perl method to which
5336     the <P::codeArg> belongs.
5337     @@@nullCase:
5338     @@@@enDesc:
5339     The <P::codeArg> does not belong to any method.
5340 wakaba 1.17 @@NamedParam:
5341     @@@Name:sourceFile
5342     @@@Type:
5343     DISLang:String::ManakaiDOM:all
5344     @@@enDesc:
5345     The source file name of the <P::codeArg>.
5346     @@@nullCase:
5347     @@@@enDesc:
5348     No source file information available.
5349     @@NamedParam:
5350     @@@Name:sourceLine
5351     @@@Type:
5352     DOMMain:unsigned-long::ManakaiDOM:all
5353     @@@enDesc:
5354     The line number in the <P::sourceFile> from which
5355     the <P::codeArg> begins.
5356     @@@nullCase:
5357     @@@@enDesc:
5358     No source file information available.
5359 wakaba 1.13 @@Return:
5360     @@@Type:
5361     lang:Perl::ManakaiDOM:all
5362     @@@enDesc:
5363     Preprocessed Perl code.
5364 wakaba 1.15 @@@BlockElementException:
5365     @@@InlineElementException:
5366 wakaba 1.13 @@@PerlDef:
5367 wakaba 1.15 unless ($self->{src}) {
5368     __EXCEPTION{NO_SOURCE_NODE_ERR::
5369     DIS:uri => {$self->{uri}},
5370     }__;
5371     }
5372     __DEEP{
5373     our $RegQNameChar;
5374     our $RegBlockContent;
5375     use re 'eval';
5376     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
5377     .plImplementation>;
5378     $r = $plimpl-><M::MPLImpl.createPerlBlock>;
5379 wakaba 1.17 if (defined $sourceLine) {
5380     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
5381     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
5382     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
5383     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
5384     } elsif ($node) {
5385     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
5386     (key => [qw/Name QName Type type/]);
5387     $r-><AS::PLBlockCon.currentSourceFile> ($np);
5388     $r-><AS::PLBlockCon.currentSourceLine> (1);
5389     $r-><AS::PLBlockCon.sourceFile> ($np);
5390     $r-><AS::PLBlockCon.sourceLine> (1);
5391     }
5392 wakaba 1.15
5393 wakaba 1.16 for my $source_code (split /\b(_ _(?:(?!_ _)$RegQNameChar)+
5394 wakaba 1.15 (?:\{$RegBlockContent\})?
5395 wakaba 1.16 _ _)\b/x, $codeArg) {
5396 wakaba 1.15 ## Block-level element
5397 wakaba 1.16 if ($source_code =~ /_\_\z/ and
5398     $source_code =~ s/^_\_((?:(?!_\_)$RegQNameChar)+)//) {
5399 wakaba 1.15 my $et = $self->{src}
5400     -><M::ManakaiDISElement.qnameToURI>
5401     ($1,
5402     node => $node,
5403     default_namespace_uri => <Q::disPerl:>);
5404     if ($source_code =~ s/^\{//) {
5405     $source_code =~ s/\}__\z//;
5406     } else {
5407     $source_code = '';
5408     }
5409    
5410     # ## ISSUE: __FILE__ & __LINE__ will break if multiline substition happens.
5411    
5412     if ($et eq <Q::disPerl:DEEP> or $et eq <Q::disPerl:UNDEEP>) {
5413     my $block = $r-><M::PLBlockCon.appendBlock>;
5414     $block-><M::PLBlockCon.appendStatement>
5415     ('local $Error::Depth = $Error::Depth '.
5416     ($et eq <Q::disPerl:DEEP> ? '+' : '-').
5417     ' 1');
5418     $block-><M::PLBlockCon.appendCodeFragment>
5419 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
5420     .plPreprocessPerlCode>
5421     ($source_code, node => $node,
5422     method_resource => $methodResource,
5423     source_file => $r-><AG::PLBlockCon
5424     .currentSourceFile>,
5425     source_line => $r-><AG::PLBlockCon
5426     .currentSourceLine>));
5427     $r-><M::PLBlockCon.skipLines> ($source_code);
5428 wakaba 1.15 } elsif ({
5429     <Q::disPerl:EXCEPTION> => 1,
5430     <Q::disPerl:WARNING> => 1,
5431     }->{$et}) {
5432 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5433 wakaba 1.15 if ($source_code =~ s/^((?:(?!::).)+)(::\s*)?//s) {
5434     my ($cls, $const, $subtype)
5435     = @{$self->{db}-><M::ManakaiDISDatabase.xcrefToResource>
5436 wakaba 1.16 ($1, $self->{src},
5437     node => $node,
5438     for_arg => $self->{for})};
5439 wakaba 1.15 my $param = $self-><M::ManakaiDISResourceDefinition
5440     .plParsePreprocessParameter>
5441     ($source_code, node => $node);
5442     my $context_param
5443     = $self-><M::ManakaiDISResourceDefinition
5444     .plGetContextParameter>;
5445    
5446     $self-><M::ManakaiDISResourceDefinition
5447     .plAppendThrow>
5448     ($r, $cls, $const, $subtype,
5449     {%$param, %$context_param});
5450     } else {
5451     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR::
5452     DIS:sourceNode => {$node},
5453     DIS:sourceCode => {$source_code},
5454     DIS:elementType => {$et},
5455     }__}__;
5456     }
5457     } elsif ($et eq <Q::disPerl:CODE>) {
5458 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5459 wakaba 1.15 my $code_name;
5460     $source_code =~ s/^\s+//;
5461     if ($source_code =~ s/^((?>(?!::).)+)//s) {
5462     $code_name = $1;
5463     } else {
5464     __UNDEEP{
5465     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
5466     DIS:sourceCode => {$source_code},
5467     DIS:sourceNode => {$node},
5468     DIS:elementType => {$et},
5469     }__;
5470     }__;
5471     }
5472     $source_code =~ s/^::\s*//;
5473     my $param = $self-><M::ManakaiDISResourceDefinition
5474     .plParsePreprocessParameter>
5475     ($source_code, node => $node);
5476     my $code_uri = $self->{src}-><M::ManakaiDISElement
5477     .tfqnamesToURI>
5478     ($code_name, null, $self->{for},
5479     node => $node);
5480     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
5481     ($code_uri);
5482     $code-><AS::ManakaiDISResourceDefinition.isReferred>
5483     ($node || $self->{src});
5484     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
5485     (<Q::dis2pm:BlockCode>)) {
5486     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5487     DIS:uri => {$code_uri},
5488     DIS:sourceNode => {$node},
5489     DIS:sourceCode => {$source_code},
5490     DIS:expectedType => {<Q::dis2pm:BlockCode>},
5491     }__;}__;
5492     }
5493     my $pc = $code-><AG::ManakaiDISResourceDefinition
5494     .plCodeFragment>->clone;
5495     unless (defined $pc) {
5496     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
5497     DIS:sourceNode => {$node},
5498     DIS:sourceCode => {$source_code},
5499     DIS:uri => {$code_uri},
5500     }__}__;
5501     }
5502     for my $var (grep {/^\$/} keys %$param) {
5503     my $value;
5504     if ($param->{$var}->{type} eq 'variable') {
5505     $value = $plimpl-><M::MPLImpl.createPerlVariable>
5506     ('$', null, $param->{$var}->{value});
5507     } elsif ($param->{$var}->{type} eq 'code') {
5508     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
5509     ($param->{$var}->{value});
5510     } else {
5511     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
5512     ($param->{$var}->{value});
5513     }
5514     $pc-><M::MPLCodeFragment.replaceVariable>
5515     ($var => $value);
5516     }
5517 wakaba 1.16 $r-><M::PLBlockCon.appendCodeFragment> ($pc);
5518 wakaba 1.15 } elsif ($et eq <Q::ManakaiDOM:InputNormalize>) {
5519 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5520 wakaba 1.15 unless ($methodResource) {
5521     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_METHOD_ERR::
5522     DIS:sourceNode => {$node},
5523     DIS:sourceCode => {$source_code},
5524     DIS:elementType => {$et},
5525     }__}__;
5526     }
5527     my $param = $methodResource
5528     -><M::ManakaiDISResourceDefinition
5529     .getChildResourceByNameAndType>
5530     ($source_code, <Q::DISLang:MethodParameter>);
5531     unless ($param) {
5532     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5533     DIS:sourceNode => {$node},
5534     DIS:sourceCode => {$source_code},
5535     DIS:elementType => {$et},
5536     DIS:localName => {$source_code},
5537     DIS:expectedType => {<Q::DISLang:MethodParameter>},
5538     }__}__;
5539     }
5540     my $norm = $param-><M::ManakaiDISResourceDefinition
5541     .plGetMethodInputNormalizer>;
5542     if ($norm) {
5543     my $norm_code = $norm-><AG::ManakaiDISResourceDefinition
5544     .plCodeFragment>->clone;
5545     $norm_code-><M::MPLCodeFragment.replaceVariable>
5546     ('$INPUT' => $param-><AG::ManakaiDISResourceDefinition
5547     .plVariableName>);
5548     $r-><M::PLBlockCon.appendCodeFragment> ($norm_code);
5549     }
5550     } elsif ($et eq <Q::disPerl:FOR>) {
5551 wakaba 1.17 if ($source_code =~ s/^(((?>(?!::).)*)::\s*)//) {
5552     $r-><M::PLBlockCon.skipLines> ($1);
5553     V: for (split /\s*\|\s*/, $2) {
5554 wakaba 1.15 my $for_uri = $self->{src}
5555     -><M::ManakaiDISElement.qnameToURI>
5556     ($_, node => $node);
5557     if ($self-><M::ManakaiDISResourceDefinition
5558     .isForURI> ($for_uri)) {
5559     $r-><M::PLBlockCon.appendCodeFragment>
5560 wakaba 1.17 ($self-><M::ManakaiDISResourceDefinition
5561     .plPreprocessPerlCode>
5562     ($source_code, node => $node,
5563     method_resource => $methodResource,
5564     source_file => $r-><AG::PLBlockCon.
5565     currentSourceFile>,
5566     source_line => $r-><AG::PLBlockCon.
5567     currentSourceLine>));
5568 wakaba 1.15 last V;
5569     }
5570     } # V
5571 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5572 wakaba 1.15 } else {
5573     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_FOR_ERR::
5574     DIS:sourceNode => {$node},
5575     DIS:sourceCode => {$source_code},
5576     DIS:elementType => {$et},
5577     }__}__;
5578     }
5579     } elsif ($et eq <Q::disPerl:ASSERT>) {
5580 wakaba 1.17 $r-><M::PLBlockCon.skipLines> ($source_code);
5581 wakaba 1.15 my $assert_type;
5582     if ($source_code =~ s/^\s*($RegQNameChar+)\s*::\s*//o) {
5583     $assert_type = $self->{src}
5584     -><M::ManakaiDISElement.qnameToURI>
5585     ($1, node => $node);
5586     } else {
5587     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ASSERT_TYPE_ERR::
5588     DIS:sourceNode => {$node},
5589     DIS:sourceCode => {$source_code},
5590     DIS:elementType => {$et},
5591     }__}__;
5592     }
5593     # if output assertion then
5594     =pod
5595     my $assert_block = $r-><M::PLBlockCon.appendBlock>;
5596    
5597     my $param = $self-><M::ManakaiDISResourceDefinition
5598     .plParsePreprocessParameter>
5599     ($source_code, node => $node);
5600     my $context_param
5601     = $self-><M::ManakaiDISResourceDefinition
5602     .plGetContextParameter>;
5603    
5604     if ($assert_type eq <Q::DISPerl:isPositive>) {
5605    
5606     $pre = perl_statement
5607     perl_assign
5608     'my $asActual' =>
5609     '('.perl_code ($param->{actual}, %opt).')';
5610     $cond = '$asActual > 0';
5611     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = 'a positive value';
5612     $xparam->{ExpandedURI q<DOMMain:actualValue>}
5613     = perl_code_literal q<$asActual>;
5614     } elsif ($atype eq ExpandedURI q<DISPerl:invariant>) {
5615     $cond = '0';
5616     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = $param->{msg};
5617     $xparam->{ExpandedURI q<DOMMain:actualValue>} = '(invariant)';
5618     } else {
5619     valid_err (q[Assertion type <].$atype.q[> is not supported],
5620     node => $opt{node});
5621     }
5622    
5623     $r = $pre . perl_if
5624     $cond,
5625     undef,
5626    
5627    
5628     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
5629     (<Q::DOMException:CoreException>);
5630     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
5631     (<Q::MDOMX:MDOM_DEBUG_BUG>);
5632     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
5633     (<Q::DOMMain:ASSERTION_ERR>);
5634 wakaba 1.16 $_-><AS::ManakaiDISResourceDefinition.isReferred>
5635 wakaba 1.15 ($node || $self->{src}) for $cls, $const, $subtype;
5636     $self-><M::ManakaiDISResourceDefinition
5637     .plAppendThrow>
5638     ($assert_block, $cls, $const, $subtype,
5639     {%$param, %$context_param,
5640     <Q::DOMMain:assertionType> => {
5641     type => 'quoted', value => $assert_type,
5642     },
5643     <Q::DOMMain:traceText> => {
5644     type => 'code',
5645     value => q<(sprintf 'at %s line %s%s%s',
5646     __FILE__, __LINE__, "\n\t",
5647     Carp::longmess ())>,
5648     }});
5649    
5650     =cut
5651    
5652     } elsif ({
5653     <Q::disPerl:FILE> => 1,
5654     <Q::disPerl:LINE> => 1,
5655     <Q::disPerl:PACKAGE> => 1,
5656     }->{$et}) {
5657     $r-><M::PLAnyCon.appendAtom>
5658     ('__'.{
5659     <Q::disPerl:FILE> => 'FILE',
5660     <Q::disPerl:LINE> => 'LINE',
5661     <Q::disPerl:PACKAGE> => 'PACKAGE',
5662     }->{$et}.'__');
5663     if (length $source_code) {
5664     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR::
5665     DIS:sourceNode => {$node},
5666     DIS:sourceCode => {$source_code},
5667     DIS:elementType => {$et},
5668     }__}__;
5669     }
5670     } else {
5671     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
5672     DIS:sourceNode => {$node},
5673     DIS:sourceCode => {$source_code},
5674     DIS:elementType => {$et},
5675     }__}__;
5676     }
5677     } else { ## Other than block-level element
5678     $r-><M::PLBlockCon.appendCodeFragment>
5679     ($self-><M::ManakaiDISResourceDefinition
5680 wakaba 1.16 .plPreprocessPerlStatement>
5681 wakaba 1.17 ($source_code, contains_statements => true,
5682     source_file => $r-><AG::PLBlockCon
5683     .currentSourceFile>,
5684     source_line => $r-><AG::PLBlockCon
5685     .currentSourceLine>));
5686     $r-><M::PLBlockCon.skipLines> ($source_code);
5687 wakaba 1.15 }
5688     } # for
5689     }__; # DEEP
5690    
5691    
5692     ## Checks \p character classes
5693     # while ($s =~ /\\p{([^{}]+)}/gs) {
5694     # my $name = $1;
5695     # $State->{ExpandedURI q<dis2pm:Package>}
5696     # ->{$State->{ExpandedURI q<dis2pm:currentPackage>}}
5697     # ->{ExpandedURI q<dis2pm:requiredCharClass>}
5698     # ->{$name} ||= $opt{node} || 1;
5699     # }
5700    
5701 wakaba 1.13
5702     @Method:
5703     @@Name: plPreprocessPerlStatement
5704     @@enDesc:
5705     Preprocesses a Perl inline code fragment
5706     (code fragment smaller than statement).
5707     @@Param:
5708     @@@Name:codeArg
5709     @@@Type:
5710     lang:Perl::ManakaiDOM:all
5711     @@@enDesc:
5712     A Perl code fragment.
5713     @@NodeParam:
5714 wakaba 1.16 @@NamedParam:
5715     @@@Name:containsStatements
5716     @@@Type:
5717     DOMMain:boolean::ManakaiDOM:all
5718     @@@enDesc:
5719     Whether one or more statements might be contained
5720     in <P::codeArg> or not.
5721 wakaba 1.17 @@NamedParam:
5722     @@@Name:sourceFile
5723     @@@Type:
5724     DISLang:String::ManakaiDOM:all
5725     @@@enDesc:
5726     The source file name of the <P::codeArg>.
5727     @@@nullCase:
5728     @@@@enDesc:
5729     No source file information available.
5730     @@NamedParam:
5731     @@@Name:sourceLine
5732     @@@Type:
5733     DOMMain:unsigned-long::ManakaiDOM:all
5734     @@@enDesc:
5735     The line number in the <P::sourceFile> from which
5736     the <P::codeArg> begins.
5737     @@@nullCase:
5738     @@@@enDesc:
5739     No source file information available.
5740 wakaba 1.13 @@Return:
5741 wakaba 1.16 @@@Type:MPLCodeFragment
5742 wakaba 1.13 @@@enDesc:
5743     Preprocessed Perl code.
5744 wakaba 1.16 @@@InCase:
5745     @@@@Type:
5746     PerlCode:ManakaiPerlBlock::ManakaiDOM:Perl
5747     @@@@enDesc:
5748 wakaba 1.19 If <P::containsStatements> is <DOM::false>.
5749 wakaba 1.16 @@@InCase:
5750     @@@@Type:
5751     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
5752     @@@@enDesc:
5753 wakaba 1.19 If <P::containsStatements> is <DOM::true>.
5754 wakaba 1.13 @@@InlineElementException:
5755     @@@PerlDef:
5756     unless ($self->{src}) {
5757     __EXCEPTION{NO_SOURCE_NODE_ERR::
5758     DIS:uri => {$self->{uri}},
5759     }__;
5760     }
5761     __DEEP{
5762     our $RegQNameChar;
5763     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
5764     .plImplementation>;
5765 wakaba 1.16 if ($containsStatements) {
5766     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
5767 wakaba 1.17 if (defined $sourceLine) {
5768     $r-><AS::PLBlockCon.sourceFile> ($sourceFile);
5769     $r-><AS::PLBlockCon.sourceLine> ($sourceLine);
5770     $r-><AS::PLBlockCon.currentSourceFile> ($sourceFile);
5771     $r-><AS::PLBlockCon.currentSourceLine> ($sourceLine);
5772     } elsif ($node) {
5773     my $np = $node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.nodePath>
5774     (key => [qw/Name QName Type type/]);
5775     $r-><AS::PLBlockCon.sourceFile> ($np);
5776     $r-><AS::PLBlockCon.sourceLine> (1);
5777     $r-><AS::PLBlockCon.currentSourceFile> ($np);
5778     $r-><AS::PLBlockCon.currentSourceLine> (1);
5779     }
5780 wakaba 1.16 } else {
5781     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
5782     }
5783     for my $source_code (split /(?<![\^\?qwr])(\x3C$RegQNameChar[^<>]+>
5784     )/ox, $codeArg) {
5785 wakaba 1.13 if ($source_code =~ s/^\x3C//) {
5786     $source_code =~ s/>$//;
5787     if ($source_code =~ /=$/) {
5788     ## TODO: Warning
5789     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
5790     # q{should "=" be used place of "=>"?};
5791     }
5792     if ($source_code =~ s/^(.+?):://) {
5793     my $et = $self->{src}
5794     -><M::ManakaiDISElement.qnameToURI>
5795     ($1,
5796     node => $node,
5797     default_namespace_uri => <Q::disPerl:>);
5798     if ($et eq <Q::disPerl:Q>) { ## QName constant
5799     $r-><M::PLAnyCon.appendStringLiteral>
5800     ($self->{src}
5801     -><M::ManakaiDISElement.qnameToURI>
5802     ($source_code, node => $node));
5803     } elsif ({
5804     <Q::disPerl:M> => 1,
5805     <Q::disPerl:ClassM> => 1,
5806     <Q::disPerl:AG> => 1,
5807     <Q::disPerl:AS> => 1,
5808     }->{$et}) { ## Method call
5809     my ($class_qname, $method_qname)
5810     = split /\s*\.\s*/, $source_code, 2;
5811     my $class_uri
5812     = $self->{src}
5813     -><M::ManakaiDISElement.tfqnamesToURI>
5814     ($class_qname,
5815     $self-><AG::ManakaiDISResourceDefinition
5816     .ownerClassURI>,
5817     $self->{for},
5818     node => $node);
5819     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5820     ($class_uri);
5821 wakaba 1.16 unless ($class-><AG::ManakaiDISResourceDefinition
5822     .isDefined>) {
5823     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5824     DIS:sourceNode => {$node},
5825     DIS:sourceCode => {$source_code},
5826     DIS:uri => {$class_uri},
5827     DIS:elementType => {$et},
5828     DIS:expectedType => {<Q::DISLang:AnyClass>},
5829     }__}__;
5830     }
5831 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5832 wakaba 1.13 ($node || $self->{src});
5833     if ($et eq <Q::disPerl::ClassM> and
5834     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
5835     (<Q::ManakaiDOM:IF>)) {
5836     __UNDEEP{
5837     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
5838     DIS:uri => {$class_uri},
5839     DIS:elementType => {$et},
5840     DIS:sourceNode => {$node || $self->{src}},
5841     DIS:sourceCode => {$source_code},
5842 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
5843 wakaba 1.13 }__;
5844     }__;
5845     }
5846     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
5847     (<Q::ManakaiDOM:IF>)) {
5848 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
5849     ($class => $r);
5850 wakaba 1.13 }
5851 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
5852 wakaba 1.13 .getChildResourceByNameAndType>
5853     ($method_qname,
5854     {
5855     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
5856     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
5857     }->{$et} || <Q::DISLang:Method>);
5858     if (not $method or
5859     not $method-><AG::ManakaiDISResourceDefinition
5860     .isDefined>) {
5861     __UNDEEP{
5862     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5863     DIS:localName => {$method_qname},
5864     DIS:elementType => {$et},
5865     DIS:sourceNode => {$node || $self->{src}},
5866     DIS:sourceCode => {$source_code},
5867 wakaba 1.14 DIS:expectedType => {{
5868     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
5869     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
5870     }->{$et} || <Q::DISLang:Method>},
5871 wakaba 1.13 }__;
5872     }__;
5873     }
5874     my $class_name = '';
5875     if ($et eq <Q::disPerl:ClassM>) {
5876     $class_name = $class-><AG::ManakaiDISResourceDefinition
5877     .plFullyQualifiedName> . '->';
5878     }
5879     my $method_name = $method-><AG::ManakaiDISResourceDefinition
5880     .plName>;
5881     $r-><M::PLAnyCon.appendBare>
5882     ($class_name . $method_name);
5883     } elsif ({
5884     <Q::disPerl:Class> => 1,
5885     <Q::disPerl:ClassName> => 1,
5886     <Q::disPerl:IF> => 1,
5887     <Q::disPerl:IFName> => 1,
5888     }->{$et}) { ## Perl package name
5889     my $class_uri
5890     = $self->{src}
5891     -><M::ManakaiDISElement.tfqnamesToURI>
5892     ($source_code,
5893     $self-><AG::ManakaiDISResourceDefinition
5894     .ownerClassURI>,
5895     $self->{for},
5896     node => $node);
5897     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5898     ($class_uri);
5899 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5900 wakaba 1.13 ($node || $self->{src});
5901 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
5902 wakaba 1.13 .plFullyQualifiedName>;
5903 wakaba 1.14 unless ($pack) {
5904     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
5905     DIS:sourceNode => {$node || $self->{src}},
5906     DIS:sourceCode => {$source_code},
5907     DIS:uri => {$class_uri},
5908     DIS:elementType => {$et},
5909     }__}__;
5910     }
5911 wakaba 1.13 if ({
5912     <Q::disPerl:ClassName> => 1,
5913     <Q::disPerl:IFName> => 1,
5914     }->{$et}) {
5915     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
5916     } else {
5917     $r-><M::PLAnyCon.appendBare> ($pack);
5918     }
5919     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
5920     my $code_name;
5921     $source_code =~ s/^\s+//;
5922     if ($source_code =~ s/^((?>(?!::).)+)//s) {
5923     $code_name = $1;
5924     } else {
5925     __UNDEEP{
5926     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
5927     DIS:sourceCode => {$source_code},
5928     DIS:sourceNode => {$node || $self->{src}},
5929     }__;
5930     }__;
5931     }
5932     $source_code =~ s/^::\s*//;
5933     my $param = $self-><M::ManakaiDISResourceDefinition
5934     .plParsePreprocessParameter>
5935     ($source_code, node => $node);
5936     my $code_uri = $self->{src}-><M::ManakaiDISElement
5937     .tfqnamesToURI>
5938     ($code_name, null, $self->{for},
5939     node => $node);
5940     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
5941     ($code_uri);
5942 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
5943 wakaba 1.13 ($node || $self->{src});
5944     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
5945     (<Q::dis2pm:InlineCode>)) {
5946     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5947     DIS:uri => {$code_uri},
5948     DIS:sourceNode => {$node || $self->{src}},
5949     DIS:sourceCode => {$source_code},
5950     DIS:expectedType => {<Q::dis2pm:InlineCode>},
5951     }__;}__;
5952     }
5953     my $pc = $code-><AG::ManakaiDISResourceDefinition
5954     .plCodeFragment>->clone;
5955     unless (defined $pc) {
5956     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
5957     DIS:sourceNode => {$node || $self->{src}},
5958     DIS:sourceCode => {$source_code},
5959     DIS:uri => {$code_uri},
5960     }__}__;
5961     }
5962     for my $var (grep {/^\$/} keys %$param) {
5963     my $value;
5964     if ($param->{$var}->{type} eq 'variable') {
5965     $value = $plimpl-><M::MPLImpl.createPerlVariable>
5966     ('$', null, $param->{$var}->{value});
5967     } elsif ($param->{$var}->{type} eq 'code') {
5968     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
5969     ($param->{$var}->{value});
5970     } else {
5971     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
5972     ($param->{$var}->{value});
5973     }
5974     $pc-><M::MPLCodeFragment.replaceVariable>
5975     ($var => $value);
5976     }
5977 wakaba 1.16 $r-><M::PLInCon.appendCodeFragment> ($pc);
5978 wakaba 1.13 } elsif ($et eq <Q::disPerl:C>) {
5979     my ($class_qname, $const_name) = split /\./, $source_code, 2;
5980     my $class_uri
5981     = $self->{src}
5982     -><M::ManakaiDISElement.tfqnamesToURI>
5983     ($class_qname,
5984     $self-><AG::ManakaiDISResourceDefinition
5985     .ownerClassURI>,
5986     $self->{for},
5987     node => $node);
5988     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
5989     ($class_uri);
5990 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
5991 wakaba 1.13 ($node || $self->{src});
5992     my $const = $class-><M::ManakaiDISResourceDefinition
5993     .getConstResourceByName> ($const_name);
5994     unless (defined $const) {
5995     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5996     DIS:sourceNode => {$node || $self->{src}},
5997     DIS:sourceCode => {$source_code},
5998     DIS:localName => {$const_name},
5999 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
6000 wakaba 1.13 }__}__;
6001     }
6002 wakaba 1.14 my $pc = $const-><AG::ManakaiDISResourceDefinition
6003 wakaba 1.13 .plCodeFragment>->clone;
6004     unless (defined $pc) {
6005     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
6006     DIS:sourceNode => {$node || $self->{src}},
6007     DIS:sourceCode => {$source_code},
6008     DIS:localName => {$const_name},
6009     }__}__;
6010     }
6011     $r-><M::PLInCon.appendCodeFragment> ($pc);
6012     } else {
6013     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
6014     DIS:elementType => {$et},
6015     DIS:sourceNode => {$node || $self->{src}},
6016 wakaba 1.16 DIS:sourceCode => {$source_code},
6017 wakaba 1.13 }__}__;
6018     }
6019     } else {
6020     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
6021     DIS:sourceNode => {$node || $self->{src}},
6022     DIS:sourceCode => {$source_code},
6023 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
6024 wakaba 1.13 }__}__;
6025     }
6026     } else {
6027 wakaba 1.18 for my $source_code (split /\b( t r u e \b|
6028     f a l s e \b|
6029     n u l l \b|
6030     t r y \s* \{)/x, $source_code) {
6031 wakaba 1.16 if ({
6032     'tr'.'ue' => true,
6033     'fal'.'se' => true,
6034     'nu'.'ll' => true,
6035     }->{$source_code}) {
6036     $r-><M::PLAnyCon.appendAtom> ({
6037     'tr'.'ue' => 1,
6038     'fal'.'se' => 0,
6039     'nu'.'ll' => 'undef',
6040     }->{$source_code});
6041 wakaba 1.18 } elsif ($source_code =~ /^t r y \s* \x7B$/x) {
6042     $r-><M::PLInCon.appendCode> ('tr'.
6043     'y '."\x7B".'local $Error::Depth = $Error::Depth + 3;');
6044 wakaba 1.20 $r-><M::MPLCodeFragment.addUsePerlModuleName>
6045     ('Message::Util::Error');
6046 wakaba 1.16 } else {
6047     $r-><M::PLInCon.appendCode> ($source_code);
6048     }
6049     }
6050     } # Inline instruction or not
6051 wakaba 1.13 } # for
6052     }__; # DEEP
6053    
6054     @Attr:
6055     @@Name: ownerClassURI
6056     @@enDesc:
6057     The URI reference of the class resource this resource
6058     belongs to.
6059     @@Type: ResourceURI
6060     @@Get:
6061     @@@enDesc:
6062     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
6063     If this resource is a class, then the URI reference
6064     of this resource is returned.
6065     @@@nullCase:
6066     @@@@enDesc:
6067     This resource does not belong to any class.
6068     @@@PerlDef:
6069     if (exists $self->{<Q::DIS:ownerClass>}) {
6070     $r = $self->{<Q::DIS:ownerClass>};
6071     } else {
6072     my $res = $self;
6073     __DEEP{
6074     {
6075     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
6076     (<Q::ManakaiDOM:Class>)) {
6077     $r = $res->{uri};
6078     } else {
6079     $res = $res-><M::ManakaiDISPropertyAccessor
6080     .getPropertyResource> (<Q::dis2pm:parentResource>);
6081     redo if $res;
6082     }
6083     }
6084     }__;
6085     $self->{<Q::DIS:ownerClass>} = $r;
6086     }
6087    
6088     @IntMethod:
6089     @@Name: plParsePreprocessParameter
6090     @@enDesc:
6091     Parses a parameter specification in preprocessing instruction
6092     and return it as a hash reference.
6093     \
6094     {NOTE:: The callee have to ensure that this resource has its
6095     <CODE::src> before the call to this method.
6096     \
6097     }
6098     @@Param:
6099     @@@Name: paramSpec
6100     @@@Type:
6101     DISLang:String::ManakaiDOM:all
6102     @@@enDesc:
6103     A parameter specification to parse.
6104     @@NodeParam:
6105     @@Return:
6106     @@@Type:
6107     Perl:hash::ManakaiDOM:all
6108     @@@enDesc:
6109     Hash containing parameters. Each hash value is also
6110     a hash reference, containing two keys <CODE::type>
6111     (its value is either <CODE::bare>, <CODE::quoted>,
6112     <CODE::code> or <CODE::variable>) and
6113     <CODE::value>.
6114     @@@RaiseException:
6115     @@@@@:BROKEN_PARAM_SPEC_ERR
6116     @@@@enDesc:
6117     The <P::paramSpec> is not well-formed.
6118     @@@PerlDef:
6119     BEGIN{
6120     our $RegQNameChar = qr/[^\s<>"'\\\[\]\{\},=\$\@%]/;
6121     use re 'eval';
6122     our $RegBlockContent;
6123     $RegBlockContent = qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{
6124     $RegBlockContent})\})*)/s;
6125     }
6126    
6127     our $RegQNameChar;
6128     our $RegBlockContent;
6129     $r = {};
6130     while ($paramSpec =~ s/^
6131     ## Parameter name
6132     (\$? $RegQNameChar+)\s*
6133    
6134     (?: =>? \s*
6135     ## ">" is now optional for inline element (">" is delimiter)
6136    
6137     ## Parameter value
6138     (
6139 wakaba 1.15 ## Variable or Bare string
6140     \ \$? $RegQNameChar+
6141 wakaba 1.13 |
6142     ## Quoted string
6143     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
6144     |
6145     ## Code
6146 wakaba 1.15 \ \{$RegBlockContent\}
6147 wakaba 1.13
6148     )
6149    
6150     \s*)?
6151    
6152     (?:,\s*|$)//ox) {
6153    
6154     my ($n, $v) = ($1, $2);
6155     if (defined $v) {
6156     if ($v =~ /^'/) {
6157     $v = {type => 'quoted',
6158     value => substr ($v, 1, length ($v) - 2)};
6159     } elsif ($v =~ /^\{/) {
6160     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
6161     } elsif ($v =~ /^\$/) {
6162 wakaba 1.21 $v = {type => 'variable', value => substr $v, 1};
6163 wakaba 1.13 } else {
6164     $v = {type => 'bare', value => $v};
6165     }
6166     } else {
6167     $v = {type => 'boolean', value => true};
6168     }
6169    
6170     if ($n =~ /^\$/) {
6171     $r->{$n} = $v;
6172     } else {
6173     __DEEP{
6174     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
6175     ($n, node => $node || $self->{src})} = $v;
6176     }__;
6177     }
6178     } # while
6179    
6180     if (length $paramSpec) {
6181     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
6182     DIS:sourceCode => {$paramSpec},
6183     DIS:sourceNode => {$node || $self->{src}},
6184     }__;
6185     }
6186    
6187 wakaba 1.15 @IntMethod:
6188     @@Name: plGetContextParameter
6189     @@enDesc:
6190     Returns contextual parameters which describes the <QUOTE::location>
6191     of this resource.
6192     @@Return:
6193     @@@Type:
6194     Perl:hash::ManakaiDOM:all
6195     @@@enDesc:
6196     Hash of parameters as <M::.plParsePreprocessParameter> returns.
6197     @@@PerlDef:
6198     $r = {};
6199     __DEEP{
6200     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6201     (<Q::DISLang:MethodReturn>)) {
6202     my $method = $self-><M::ManakaiDISPropertyAccessor
6203     .getPropertyResource> (<Q::dis2pm:parentResource>);
6204     $r->{<Q::MDOMX:method>}
6205     = {type => 'quoted',
6206     value => $method-><AG::ManakaiDISResourceDefinition.plName>};
6207     my $class = $method-><M::ManakaiDISPropertyAccessor
6208     .getPropertyResource> (<Q::dis2pm:parentResource>);
6209     $r->{<Q::MDOMX:class>}
6210     = {type => 'quoted',
6211     value => $class-><AG::ManakaiDISResourceDefinition
6212     .plFullyQualifiedName>};
6213     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6214     (<Q::DISLang:AttributeGet>)) {
6215     my $attr = $self-><M::ManakaiDISPropertyAccessor
6216     .getPropertyResource> (<Q::dis2pm:parentResource>);
6217     $r->{<Q::MDOMX:attr>}
6218     = {type => 'quoted',
6219     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
6220     my $class = $attr-><M::ManakaiDISPropertyAccessor
6221     .getPropertyResource> (<Q::dis2pm:parentResource>);
6222     $r->{<Q::MDOMX:class>}
6223     = {type => 'quoted',
6224     value => $class-><AG::ManakaiDISResourceDefinition
6225     .plFullyQualifiedName>};
6226     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'get'};
6227     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
6228     (<Q::DISLang:AttributeSet>)) {
6229     my $attr = $self-><M::ManakaiDISPropertyAccessor
6230     .getPropertyResource> (<Q::dis2pm:parentResource>);
6231     $r->{<Q::MDOMX:attr>}
6232     = {type => 'quoted',
6233     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
6234     my $class = $attr-><M::ManakaiDISPropertyAccessor
6235     .getPropertyResource> (<Q::dis2pm:parentResource>);
6236     $r->{<Q::MDOMX:class>}
6237     = {type => 'quoted',
6238     value => $class-><AG::ManakaiDISResourceDefinition
6239     .plFullyQualifiedName>};
6240     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'set'};
6241     } else {
6242     $r->{<Q::MDOMX:resourceURI>} = {type => 'quoted',
6243     value => $self->{uri}};
6244     }
6245     }__;
6246    
6247     @Method:
6248     @@Name: plGetMethodInputNormalizer
6249     @@enDesc:
6250     Returns an input processor. This method assumes that
6251 wakaba 1.19 this resource is a method parameter (<Q::DISLang:MethodParameter>)
6252     or an attribute setter (<Q::DISLang:AttributeSet>).
6253 wakaba 1.15 @@Return:
6254     @@@Type:ManakaiDISResourceDefinition
6255     @@@enDesc:
6256     A <Q::DISLang:InputProcessor> corresponding to
6257     the parameter defined by this resource.
6258     \
6259     {NOTE:: <Q::ManakaiDOM:inputNormalize> property is
6260     obsolete in favor of <Q::DISLang:InputProcessor>;
6261     this method does not support the former.
6262     \
6263     }
6264     @@@nullCase:
6265     @@@@enDesc:
6266     No input processor found.
6267     @@@PerlDef:
6268     my $type;
6269     try {
6270     $type = $self-><AG::ManakaiDISResourceDefinition
6271     .disActualDataTypeResource>;
6272 wakaba 1.16 #$type_node = $self->< AG::ManakaiDISResourceDefinition
6273 wakaba 1.15 # .disActualDataTypeNode>;
6274     } catch <Class::ManakaiDISException> with {
6275     my $err = shift;
6276     unless ($err->{<Q::MDOMX:subtype>} eq <Q::DIS:NO_DIS_TYPE_ERR>) {
6277     $err->throw;
6278     }
6279     };
6280     if ($type) {
6281     __DEEP{
6282     $r = $type-><M::ManakaiDISResourceDefinition.getChildResourceByType>
6283     (<Q::DISLang:InputProcessor>);
6284     }__;
6285     }
6286    
6287     @IntMethod:
6288     @@Name: plAppendThrow
6289     @@enDesc:
6290     Appends a <Perl::report> method call statement for exception reporting.
6291     @@Param:
6292     @@@Name: parentNode
6293     @@@enDesc:
6294     The parent Perl code node to which a new statement is appended.
6295     @@@Type: PLBlockCon
6296     @@Param:
6297     @@@Name: xclass
6298     @@@Type: ManakaiDISResourceDefinition
6299     @@@enDesc:
6300     An exception class.
6301     @@Param:
6302     @@@Name: xcode
6303     @@@Type: ManakaiDISResourceDefinition
6304     @@@enDesc:
6305     An exception code constant.
6306     @@Param:
6307     @@@Name: xsubtype
6308     @@@Type: ManakaiDISResourceDefinition
6309     @@@enDesc:
6310     An exception subtype.
6311     @@@nullCase:
6312     @@@@enDesc:
6313     No subtype.
6314     @@Param:
6315     @@@Name: xparam
6316     @@@Type:
6317     Perl:hash::ManakaiDOM:all
6318     @@@enDesc:
6319     A hash containing parameters passed to the <Perl:report> method.
6320     A hash key is to be a parameter name. Hash values
6321     should also be hashes. A hash value hash has two values:
6322     <CODE::type> and <CODE::value>. A <CODE::value>
6323     value is a parameter value. If <CODE::type> is
6324     <CODE::code>, then <CODE::value> is assumed as a Perl code fragment.
6325     Otherwise, <CODE::value> is quoted to be interpreted as a string as is.
6326     @@Return:
6327 wakaba 1.16 @@@RaiseException:
6328     @@@@@: RESOURCE_NOT_DEFINED_ERR
6329     @@@@enDesc:
6330     Either <P::xclass>, <P::xcode> or <P::xsubtype>
6331     is not defined.
6332 wakaba 1.15 @@@PerlDef:
6333     my $statement = $parentNode-><M::PLBlockCon.appendStatement>
6334     ('report '.
6335     $xclass-><AG::ManakaiDISResourceDefinition.plFullyQualifiedName>.
6336     ' -object => $self');
6337 wakaba 1.16 my $xclass_module = $xclass-><AG::ManakaiDISResourceDefinition
6338     .definingModule>;
6339     unless ($xclass-><AG::ManakaiDISResourceDefinition.isDefined> or
6340     not $xclass_module) {
6341     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
6342     DIS:sourceNode => {$self->{src}},
6343     DIS:uri => {$xclass->{uri}},
6344     DIS:localName => {$xclass->{localName}},
6345     DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
6346     }__;
6347     }
6348 wakaba 1.20 $self-><M::ManakaiDISResourceDefinition.plAddRequireResource>
6349     ($xclass_module => $statement);
6350 wakaba 1.15 $xparam->{-type} = {type => 'quoted',
6351     value => $xcode-><AG::ManakaiDISResourceDefinition
6352     .plName>};
6353     $xparam->{<Q::MDOMX:subtype>} = {type => 'quoted',
6354     value => $xsubtype->{nameURI}}
6355     if $xsubtype;
6356     for my $name (keys %$xparam) {
6357     my $pname = $name;
6358     $pname =~ s/(['\\])/\\$1/g;
6359     $pname = qq<'$pname'>;
6360     $statement-><M::PLInCon.appendCode>
6361     (', ' . $pname . ' => ');
6362     if ($xparam->{$name}->{type} eq 'code') {
6363     if (ref $xparam->{$name}->{value}) {
6364     $statement-><M::PLInCon.appendCodeFragment>
6365     ($xparam->{$name}->{value});
6366     } else {
6367 wakaba 1.16 $statement-><M::PLInCon.appendCodeFragment>
6368 wakaba 1.15 ($self-><M::ManakaiDISResourceDefinition
6369     .plPreprocessPerlStatement>
6370     ($xparam->{$name}->{value}));
6371     }
6372     } else { ## String as is
6373     $statement-><M::PLAnyCon.appendStringLiteral>
6374     ($xparam->{$name}->{value});
6375     }
6376     }
6377    
6378 wakaba 1.18 @Attr:
6379     @@Name: plIsNullable
6380     @@enDesc:
6381     Whether this resource is <QUOTE::nullable> or not.
6382     <QUOTE::Nullability> is defined for method parameters,
6383     method returns, attribute getters and attribute setters.
6384     @@Type:
6385     DOMMain:boolean::ManakaiDOM:all
6386     @@Get:
6387     @@@RaiseException:
6388     @@@@@:NO_DIS_TYPE_ERR
6389     @@@@enDesc:
6390     There is a <Q::ManakaiDOM:InCase> child resource
6391     that does not have <Q::dis:Type> attribute.
6392     @@@PerlDef:
6393     __DEEP{
6394     for my $incase (@{$self-><M::ManakaiDISPropertyAccessor
6395     .getPropertyResourceList>
6396     (<Q::DIS:childResource>)}) {
6397     next unless $incase-><M::ManakaiDISResourceDefinition.isTypeURI>
6398     (<Q::ManakaiDOM:InCase>);
6399     if ($incase-><AG::ManakaiDISResourceDefinition.disIsNullValue> or
6400     $incase-><AG::ManakaiDISResourceDefinition
6401     .disActualDataTypeResource>
6402     -><M::ManakaiDISResourceDefinition
6403     .isSubsetOfURI> (<Q::DOMMain:boolean>)) {
6404     $r = true;
6405     last;
6406     }
6407     }
6408     }__;
6409    
6410     @Attr:
6411     @@Name: disIsNullValue
6412     @@enDesc:
6413     Whether this resource have <DOM::null> value or not.
6414     A resource have <DOM::null> value iff it has
6415     <Q::dis:Value> attribute node that in turn has
6416     <Q::dis:is-null> attribute whose value set to <DOM::true>.
6417     @@Type:
6418     DOMMain:boolean::ManakaiDOM:all
6419     @@Get:
6420     @@@PerlDef:
6421     if ($self->{src}) {
6422     __DEEP{
6423     my $val = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6424     (<Q::dis:Value>,
6425     for_arg => $self->{for},
6426     forp_arg => $self->{forp});
6427     if ($val) {
6428     my $isnull = $val-><M::ManakaiDISElement.disGetAttribute>
6429     (<Q::dis:is-null>,
6430     for_arg => $self->{for},
6431     forp_arg => $self->{forp});
6432     if ($isnull and $isnull-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
6433     .value>) {
6434     $r = true;
6435     }
6436     }
6437     }__;
6438     }
6439 wakaba 1.19
6440     @Attr:
6441     @@Name:plIsDefined
6442     @@enDesc:
6443     Whether a Perl implementation for this resource is available or not.
6444     @@Type:
6445     DOMMain:boolean::ManakaiDOM:all
6446     @@Get:
6447     @@@TrueCase:
6448     @@@@enDesc:
6449     This resource has its Perl definition and it is implemented.
6450     @@@FalseCase:
6451     @@@@enDesc:
6452     Either this resource does not have any Perl definition
6453     or it does have but it is not implemented yet.
6454     @@@PerlDef:
6455     if (exists $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>}) {
6456     $r = $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>};
6457     } else {
6458     __DEEP{
6459     my $typeuri = {
6460     <Q::ManakaiDOM:Class> => [
6461     <Q::DISLang:Method>, <Q::DISLang:Attribute>,
6462     ],
6463     <Q::DISLang:Method> => [
6464     <Q::DISLang:MethodReturn>,
6465     ],
6466     <Q::DISLang:Attribute> => [
6467     <Q::DISLang:AttributeGet>, <Q::DISLang::AttributeSet>,
6468     ],
6469     };
6470     OUTMOST:
6471     for my $mytype (keys %$typeuri) {
6472     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI> ($mytype)) {
6473     for my $ctype ($typeuri->{$mytype}) {
6474     for my $cres (@{$self-><M::ManakaiDISPropertyAccessor
6475     .getPropertyResourceList>
6476     (<Q::DIS:childResource>)}) {
6477     if ($cres-><M::ManakaiDISResourceDefinition.isTypeURI>
6478     ($ctype)) {
6479     unless ($cres-><AG::ManakaiDISResourceDefinition
6480     .plIsDefined>) {
6481     $r = false; last OUTMOST;
6482     }
6483     }
6484     }
6485     next OUTMOST;
6486     }
6487     }
6488     } # OUTMOST
6489     }__;
6490     $self->{<Q::TreeCore:node>}->{<Q::DIS:plDefined>} = $r;
6491     }
6492 wakaba 1.20
6493     @IntMethod:
6494     @@Name: plAddRequireResource
6495     @@enDesc:
6496     Adds a resource to the list of resources that should
6497     be <Perl::require>d from a Perl code fragment.
6498     @@Param:
6499     @@@Name: resourceArg
6500     @@@Type: ManakaiDISResourceDefinition
6501     @@@enDesc:
6502     A resource that is <Perl::require>d by <P::codeArg>.
6503     @@Param:
6504     @@@Name: codeArg
6505     @@@Type: MPLCodeFragment
6506     @@@enDesc:
6507     A code fragment. <P::resourceArg> is added to the
6508     list of <Perl::require>d resources of this code fragment.
6509     @@Return:
6510     @@@PerlDef:
6511     __DEEP{
6512     $codeArg-><M::MPLCodeFragment.disAddRequireURI>
6513     ($resourceArg-><AG::ManakaiDISResourceDefinition.uri>);
6514     }__;
6515 wakaba 1.21
6516     @IntMethod:
6517     @@Name: plMufDescriptionText
6518     @@enDesc:
6519     {TODO:: Formal documentation-access API required.
6520     \
6521     }
6522     @@Return:
6523     @@@Type:
6524     DISLang:String::ManakaiDOM:all
6525     @@@PerlDef:
6526     __DEEP{
6527     my $muf = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6528     (<Q::dis:Def>, for_arg => $self->{for},
6529     forp_arg => $self->{forp},
6530     media_type => <Q::lang:muf>);
6531     if ($muf) {
6532     $r = $muf-><M::SWCFGNode.value>;
6533     $r =~ s/<Q::([^<>]+)>/$self->{src}-><M::ManakaiDISElement.
6534     qnameToURI> ($1, node => $muf)/ge;
6535     $r =~ s/\s+/ /g;
6536     $r =~ s/^ //;
6537     $r =~ s/ $//;
6538     } else {
6539     my $desc = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6540     (<Q::dis:Description>, for_arg => $self->{for},
6541     forp_arg => $self->{forp},
6542     media_type => <Q::lang:disdoc>,
6543     default_media_type => <Q::lang:disdoc>);
6544     if ($desc) {
6545     $r = $desc-><M::SWCFGNode.value>;
6546     $r =~ s/\s+/ /g;
6547     $r =~ s/^ //;
6548     $r =~ s/ $//;
6549     $r =~ s/%/%percent;/g;
6550     }
6551     }
6552     }__;
6553     @@@ImplNote:
6554     @@@@lang:en
6555     @@@@@: Currently only common-used patterns are supported.
6556 wakaba 1.2 ##DISResourceDefinition
6557    
6558 wakaba 1.19 PropDef:
6559     @QName:plDefined
6560     @enDesc:
6561     Whether a Perl definition for this resource is implemented or not.
6562    
6563 wakaba 1.13 ElementTypeBinding:
6564 wakaba 1.15 @Name: BlockElementException
6565     @ElementType:
6566     ManakaiDOM:raises
6567     @ShadowContent:
6568     @@@: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
6569     @@Description:
6570     @@@lang:en
6571     @@@@:
6572     An exception type specification is required but not specified.
6573     @ShadowSibling:
6574     @@ManakaiDOM:raises:
6575     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
6576     @@@Description:
6577     @@@@lang:en
6578     @@@@@:
6579     A code qualified name is required but not specified.
6580     @@ManakaiDOM:raises:
6581     @@@@: RESOURCE_NOT_DEFINED_ERR
6582     @@@Description:
6583     @@@@lang:en
6584     @@@@@:
6585     A referred resource is not defined or has different type.
6586     @@ManakaiDOM:raises:
6587     @@@@: PERL_CODE_NOT_DEFINED_ERR
6588     @@@Description:
6589     @@@@lang:en
6590     @@@@@:
6591     A referred resource does not have its Perl definition.
6592     @@ManakaiDOM:raises:
6593     @@@@: PERL_PREPROCESS_NO_METHOD_ERR
6594     @@@Description:
6595     @@@@lang:en
6596     @@@@@:
6597     A preprocessing instruction which is allowed only in
6598     methods is embeded in a context which is not in any method.
6599     @@ManakaiDOM:raises:
6600     @@@@: PERL_PREPROCESS_NO_FOR_ERR
6601     @@@Description:
6602     @@@@lang:en
6603     @@@@@:
6604     A <QUOTE::for> qualified name is required but not specified.
6605     @@ManakaiDOM:raises:
6606     @@@@: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
6607     @@@Description:
6608     @@@@lang:en
6609     @@@@@:
6610     An assertion type qualified name is required but not specified.
6611     @@ManakaiDOM:raises:
6612     @@@@: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
6613     @@@Description:
6614     @@@@lang:en
6615     @@@@@:
6616     A preprocessing instruction block is specified
6617     but not allowed for this element type.
6618    
6619     ElementTypeBinding:
6620 wakaba 1.13 @Name: InlineElementException
6621     @ElementType:
6622     ManakaiDOM:raises
6623     @ShadowContent:
6624     @@@: NO_SOURCE_NODE_ERR
6625     @@Description:
6626     @@@lang:en
6627     @@@@:
6628     This resource definition does not have associated node
6629     in the source tree.
6630     @ShadowSibling:
6631     @@ManakaiDOM:raises:
6632     @@@@: INTERFACE_CLASS_METHOD_ERR
6633     @@@Description:
6634     @@@@lang:en
6635     @@@@@:
6636     An attempt is made to call a class (static) method
6637     via an interface, not class.
6638     @@ManakaiDOM:raises:
6639     @@@@: RESOURCE_NOT_DEFINED_ERR
6640     @@@Description:
6641     @@@@lang:en
6642     @@@@@:
6643     A package, method or attribute is not defined or not
6644     a resoure of that type.
6645     @@ManakaiDOM:raises:
6646     @@@@: NO_LOCAL_NAME_ERR
6647     @@@Description:
6648     @@@@lang:en
6649     @@@@@:
6650     A referred resource does not have its local name so
6651     that it is impossible to refer it by name.
6652     @@ManakaiDOM:raises:
6653     @@@@: RESERVED_PERL_METHOD_NAME_ERR
6654     @@@Description:
6655     @@@@lang:en
6656     @@@@@:
6657     A referred method has its name reserved for special-purpose.
6658     @@ManakaiDOM:raises:
6659     @@@@: BROKEN_PARAM_SPEC_ERR
6660     @@@Description:
6661     @@@@lang:en
6662     @@@@@:
6663     A parameter specification is not well-formed.
6664     @@ManakaiDOM:raises:
6665     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
6666 wakaba 1.14 @@@Description:
6667     @@@@lang:en
6668     @@@@@:
6669     A preprocessing instruction does not contain
6670     Perl code fragment name.
6671 wakaba 1.13 @@ManakaiDOM:raises:
6672     @@@@: PERL_CODE_NOT_DEFINED_ERR
6673 wakaba 1.14 @@@Description:
6674     @@@@lang:en
6675     @@@@@:
6676     The referred resource does not have its Perl definition.
6677 wakaba 1.13 @@ManakaiDOM:raises:
6678     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
6679 wakaba 1.14 @@@Description:
6680     @@@@lang:en
6681     @@@@@:
6682     A preprocessing instruction does not contain its element type name.
6683 wakaba 1.13 @@ManakaiDOM:raises:
6684     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
6685 wakaba 1.14 @@@Description:
6686     @@@@lang:en
6687     @@@@@:
6688     An unknown element type is encounted.
6689     @@ManakaiDOM:raises:
6690     @@@@: NO_PERL_PACKAGE_NAME_ERR
6691     @@@Description:
6692     @@@@lang:en
6693     @@@@@:
6694     No Perl package name is defined for a class or interface.
6695 wakaba 1.13
6696     PropDef:
6697     @QName: ownerClass
6698     @enDesc:
6699     The class to which this resource belongs.
6700     @Type: ResourceURI
6701     @rdfs:range:
6702     rdf:Resource
6703     @rdfs:domain:
6704     ManakaiDOM:Class
6705    
6706 wakaba 1.12 ResourceDef:
6707     @QName: DOMMinImpl
6708     @rdf:type:
6709     ManakaiDOM:IF
6710     @AliasFor:
6711     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
6712    
6713     ResourceDef:
6714 wakaba 1.20 @QName: PLPack
6715     @rdf:type:
6716     ManakaiDOM:Class
6717     @AliasFor:
6718     PerlCode:ManakaiPerlPackageScope::ManakaiDOM:Perl
6719    
6720     ResourceDef:
6721 wakaba 1.12 @QName: SWCFGNode
6722     @rdf:type:
6723     ManakaiDOM:IF
6724     @AliasFor:
6725     swcfg21:SWCFGNode::swcfg21:ForLatest
6726    
6727     ResourceDef:
6728     @QName: SWCFGDoc
6729     @rdf:type:
6730     ManakaiDOM:IF
6731     @AliasFor:
6732     swcfg21:SWCFGDocument::swcfg21:ForLatest
6733    
6734     ResourceDef:
6735     @QName: MPLImpl
6736     @rdf:type:
6737     ManakaiDOM:Class
6738     @AliasFor:
6739     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
6740    
6741     ResourceDef:
6742     @QName: MPLCodeFragment
6743     @rdf:type:
6744     ManakaiDOM:Class
6745     @AliasFor:
6746     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
6747    
6748     ResourceDef:
6749 wakaba 1.13 @QName: PLInCon
6750     @rdf:type:
6751     ManakaiDOM:Class
6752     @AliasFor:
6753     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
6754    
6755     ResourceDef:
6756 wakaba 1.15 @QName: PLBlockCon
6757     @rdf:type:
6758     ManakaiDOM:Class
6759     @AliasFor:
6760     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
6761    
6762     ResourceDef:
6763 wakaba 1.13 @QName: PLAnyCon
6764     @rdf:type:
6765     ManakaiDOM:Class
6766     @AliasFor:
6767     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
6768    
6769     ResourceDef:
6770     @QName: MPLSS
6771     @rdf:type:
6772     ManakaiDOM:Class
6773     @AliasFor:
6774     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
6775    
6776     ResourceDef:
6777 wakaba 1.12 @QName: MPLSub
6778     @rdf:type:
6779     ManakaiDOM:Class
6780     @AliasFor:
6781     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
6782    
6783     ResourceDef:
6784     @QName: MPLUnparsedCode
6785     @rdf:type:
6786     ManakaiDOM:Class
6787     @AliasFor:
6788     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
6789    
6790     PropDef:
6791     @QName: plCodeFragment
6792     @enDesc:
6793     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
6794    
6795     XParamDef:
6796     @QName: errResource
6797     @enDesc:
6798     A resource on which an error has occurred.
6799    
6800 wakaba 1.8 XParamDef:
6801     @QName: generatedName
6802     @enDesc:
6803     A generated name.
6804    
6805 wakaba 1.2 ClsDef:
6806     @ClsQName: ManakaiDISPropertyAccessor
6807 wakaba 1.3 @enDesc:
6808 wakaba 1.2 Accessor methods for resource or module properties.
6809    
6810     @Method:
6811 wakaba 1.8 @@Name: getPropertyBoolean
6812     @@enDesc:
6813     Gets boolean property value.
6814     @@PropNameParam:
6815     @@Param:
6816     @@@Name:default
6817     @@@Type:
6818     DOMMain:boolean::ManakaiDOM:all
6819     @@@enDesc:
6820     The default value that is returned if no explicit property
6821     value specification found for this resource.
6822     @@Return:
6823     @@@Type:
6824     DOMMain:boolean::ManakaiDOM:all
6825     @@@enDesc:
6826     The property value.
6827     @@@PerlDef:
6828     if (exists $self->{$propName}) {
6829     $r = defined $self->{$propName} ? $self->{$propName} : $default;
6830     } elsif ($self->{src}) {
6831 wakaba 1.18 my $attr_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6832 wakaba 1.8 ($propName, for_arg => $self->{for},
6833     forp_arg => $self->{forp});
6834 wakaba 1.18 $r = $self->{$propName} = ($attr_node
6835     ? ($attr_node-><M::SWCFGNode.value>
6836     ? true : false)
6837     : null);
6838 wakaba 1.8 $r = $default unless defined $r;
6839     } else {
6840     $r = $default;
6841     }
6842    
6843     @Method:
6844 wakaba 1.2 @@Name: getPropertyText
6845     @@enDesc:
6846     Gets property value text.
6847     @@PropNameParam:
6848     @@Param:
6849     @@@Name:default
6850     @@@Type:
6851 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
6852 wakaba 1.2 @@@enDesc:
6853     The default value that is returned if no explicit property
6854     value specification found for this resource.
6855     @@@nullCase:
6856     @@@@enDesc:
6857     No default value supplied; <DOM::null> is returned if
6858     no value specified.
6859     @@Return:
6860     @@@Type:
6861 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
6862 wakaba 1.2 @@@enDesc:
6863     The property value string.
6864     @@@nullCase:
6865     @@@@enDesc:
6866     No value nor default value has specified.
6867     @@@PerlDef:
6868     if (exists $self->{$propName}) {
6869     $r = defined $self->{$propName} ? $self->{$propName} : $default;
6870     } elsif ($self->{src}) {
6871     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6872     ($propName, for_arg => $self->{for},
6873     forp_arg => $self->{forp});
6874 wakaba 1.8 if ($r) {
6875     $r = $self->{$propName}
6876 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
6877 wakaba 1.8 $r = $default unless defined $r;
6878     } else {
6879     $r = $default;
6880     $self->{$propName} = null;
6881     }
6882 wakaba 1.2 } else {
6883     $r = $default;
6884     }
6885    
6886     @Method:
6887     @@Name: getPropertyResource
6888     @@enDesc:
6889     Gets property value resource.
6890     @@PropNameParam:
6891 wakaba 1.10 @@NamedParam:
6892     @@@Name: defaultMediaType
6893     @@@Type: ResourceURI
6894     @@@enDesc:
6895     The URI reference of the default media type which is used
6896     when the property value is retrieved from the source tree
6897     and the source tree element does not have its <Q::dis:ContentType>
6898     attribute specified.
6899     @@@nullCase:
6900     @@@@enDesc:
6901     Defaulted to <Q::dis:TypeQName>.
6902 wakaba 1.2 @@Return:
6903     @@@Type: ManakaiDISResourceDefinition
6904     @@@enDesc:
6905     The property value resource.
6906     @@@nullCase:
6907     @@@@enDesc:
6908     No value has specified.
6909 wakaba 1.8 @@@UndeclaredPrefixException:
6910 wakaba 1.12 @@@RaiseException:
6911     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
6912     @@@@enDesc:
6913     The media type of the attribute node in the source tree
6914     corresponding to this resource is not supported.
6915 wakaba 1.2 @@@PerlDef:
6916     if (defined $self->{$propName}) {
6917 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
6918     ($self->{$propName});
6919 wakaba 1.8 } elsif ($self->{src}) {
6920     __DEEP{
6921     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
6922     ($propName, for_arg => $self->{for},
6923     forp_arg => $self->{forp});
6924     if ($r) {
6925 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
6926     unless defined $defaultMediaType;
6927     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
6928 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
6929     for_arg => $self->{for},
6930     forp_arg => $self->{forp})) {
6931 wakaba 1.10 $self->{$propName}
6932     = $r-><AG::ManakaiDISElement.qnameValueURI>;
6933     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
6934 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
6935     for_arg => $self->{for},
6936     forp_arg => $self->{forp})) {
6937 wakaba 1.10 $self->{$propName}
6938     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
6939     ($self->{src}-><AG::swcfg21:SWCFGNode
6940     ::swcfg21:ForLatest.nodeID>,
6941     $self->{for});
6942     } else {
6943     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
6944     (for_arg => $self->{for},
6945     forp_arg => $self->{forp});
6946     __UNDEEP{
6947     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
6948     DIS:uri => {$mt},
6949     DIS:sourceNode => {$r},
6950     }__;
6951     }__;
6952     }
6953 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
6954     ($self->{$propName});
6955 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
6956 wakaba 1.8 }
6957     }__;
6958 wakaba 1.2 }
6959    
6960     @Method:
6961 wakaba 1.10 @@Name: getPropertyResourceList
6962     @@enDesc:
6963     Gets property value resource list.
6964     @@PropNameParam:
6965     @@NamedParam:
6966     @@@Name: recursiveISA
6967     @@@Type:
6968 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
6969 wakaba 1.10 @@@enDesc:
6970     Whether property resource values of <Q::dis:ISA> resources
6971     of this resource should also be included to the returned list or not.
6972     @@NamedParam:
6973     @@@Name: defaultMediaType
6974     @@@Type: ResourceURI
6975     @@@enDesc:
6976     The URI reference of the default media type which is used
6977     when the property value is retrieved from the source tree
6978     and the source tree element does not have its <Q::dis:ContentType>
6979     attribute specified.
6980     @@@nullCase:
6981     @@@@enDesc:
6982     Defaulted to <Q::dis:TypeQName>.
6983     @@Return:
6984     @@@Type: ResourceList
6985     @@@enDesc:
6986     An array reference of the property value resources.
6987     \
6988     {NOTE:: This list is <QUOTE::dead>.
6989     \
6990     }
6991     @@@UndeclaredPrefixException:
6992 wakaba 1.12 @@@RaiseException:
6993     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
6994     @@@@enDesc:
6995     The media type of the attribute node in the source tree
6996     corresponding to this resource is not supported.
6997 wakaba 1.10 @@@PerlDef:
6998     $r = [];
6999     if (defined $self->{$propName}) {
7000     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
7001     ? $self->{$propName} : []}) {
7002     push @$r,
7003     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
7004     }
7005     } elsif ($self->{src}) {
7006     __DEEP{
7007     $self->{$propName} = [];
7008     $defaultMediaType = <Q::dis:TypeQName>
7009     unless defined $defaultMediaType;
7010     for my $res_name_node
7011     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
7012     ($propName, for_arg => $self->{for},
7013     forp_arg => $self->{forp})}) {
7014     my $res_uri;
7015     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
7016 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
7017     for_arg => $self->{for},
7018     forp_arg => $self->{forp})) {
7019 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
7020     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
7021 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
7022     for_arg => $self->{for},
7023     forp_arg => $self->{forp})) {
7024 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
7025     ($self->{src}-><AG::swcfg21:SWCFGNode
7026     ::swcfg21:ForLatest.nodeID>,
7027     $self->{for});
7028     } else {
7029     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
7030     (for_arg => $self->{for},
7031     forp_arg => $self->{forp});
7032     __UNDEEP{
7033     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
7034     DIS:uri => {$mt},
7035     DIS:sourceNode => {$res_name_node},
7036     }__;
7037     }__;
7038     }
7039     push @{$self->{$propName}}, $res_uri;
7040     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
7041     ($res_uri);
7042     push @$r, $res;
7043 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
7044 wakaba 1.10 ($res_name_node);
7045     }
7046     }__;
7047     }
7048     if ($recursiveISA) {
7049     __DEEP{
7050     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
7051     my @p_res = @$r;
7052     for my $p_res (@p_res) {
7053     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
7054     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
7055     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
7056     .getPropertyResourceList>
7057     (<Q::dis:ISA>, recursive_isa => true,
7058     ___recursive_isa_done => $opt{___recursive_isa_done},
7059     default_media_type => $defaultMediaType)};
7060     }
7061     }__;
7062     }
7063    
7064     @Method:
7065 wakaba 1.2 @@Name: addPropertyResourceList
7066     @@enDesc:
7067     Adds a resource to a resource-list property value.
7068     \
7069     {ISSUE:: Should an exception be thrown if the property is
7070     not of list?
7071     \
7072     }
7073 wakaba 1.10 \
7074     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
7075     an item clears the list --- i.e. the property values
7076     in the source tree will be ignored. Call
7077     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
7078     before adding to avoid this behavior.
7079     \
7080     }
7081 wakaba 1.2 @@PropNameParam:
7082     @@Param:
7083     @@@Name: res
7084     @@@Type: ManakaiDISResourceDefinition
7085     @@@enDesc:
7086     A resource to add.
7087     @@Return:
7088     @@@PerlDef:
7089     if (ref $self->{$propName} eq 'ARRAY') {
7090     push @{$self->{$propName}}, $res->{uri};
7091     } elsif (not defined $self->{$propName}) {
7092     $self->{$propName} = [$res->{uri}];
7093     }
7094    
7095 wakaba 1.3 ElementTypeBinding:
7096     @Name: PropNameParam
7097     @ElementType:
7098     dis:ResourceDef
7099     @ShadowContent:
7100     @@rdf:type:
7101     DISLang:MethodParameter
7102     @@Name: propName
7103     @@Type: ResourceURI
7104     @@Description:
7105     @@@lang:en
7106     @@@@:
7107     The name of the property.
7108    
7109 wakaba 1.2 ##DISPropertyAccessor
7110    
7111     PropDef:
7112     @QName:isAnon
7113     @Description:
7114     @@lang:en
7115     @@@:
7116     Whether the subject resource is anonymous or not.
7117     @Type:
7118 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
7119 wakaba 1.2
7120     PropDef:
7121     @QName:isDefined
7122     @Description:
7123     @@lang:en
7124     @@@:
7125     Whether the subject resource is defined or not.
7126    
7127     PropDef:
7128 wakaba 1.3 @QName:isReferred
7129 wakaba 1.2 @Description:
7130     @@lang:en
7131     @@@:
7132     Whether the subject resource is referred or not.
7133     @Type:
7134     DOMMain:any
7135    
7136     PropDef:
7137     @QName:definingModule
7138     @Description:
7139     @@lang:en
7140     @@@:
7141     The <QUOTE::dis> module in which the subject resource is defined.
7142     @rdfs:domain:
7143     DISCore:Module
7144 wakaba 1.1
7145     ## -- Datatypes
7146    
7147     URITypeDef:
7148 wakaba 1.3 @QName: AnyURI
7149     @Description:
7150     @@lang:en
7151     @@@:
7152     Any URI references.
7153    
7154     URITypeDef:
7155     @QName: FileURI
7156     @enDesc:
7157     URI references identifying file.
7158    
7159     URITypeDef:
7160 wakaba 1.1 @QName: ForURI
7161     @Description:
7162     @@lang:en
7163     @@@:
7164     <QUOTE::For> URI references.
7165    
7166     DataTypeDef:
7167     @QName: ForURIList
7168     @Description:
7169     @@lang:en
7170     @@@:
7171     References to the array containing <QUOTE::for> URI references.
7172    
7173     URITypeDef:
7174 wakaba 1.3 @QName: ResourceURI
7175     @Description:
7176     @@lang:en
7177     @@@:
7178     A URI reference for a <QUOTE::dis> resource.
7179    
7180     URITypeDef:
7181 wakaba 1.1 @QName: MediaTypeURI
7182     @Description:
7183     @@lang:en
7184     @@@:
7185     Media type URI references.
7186 wakaba 1.3 @rdfs:subClassOf: ResourceURI
7187    
7188     URITypeDef:
7189     @QName: ModuleURI
7190     @enDesc:
7191     URI references for <QUOET::dis> modules.
7192     @rdfs:subClassOf: ResourceURI
7193    
7194     URITypeDef:
7195     @QName: NameURI
7196     @enDesc:
7197     URI references identifying a resource.
7198     @rdfs:subClassOf: ResourceURI
7199 wakaba 1.10
7200     DataTypeDef:
7201     @QName: ResourceList
7202     @enDesc:
7203     References to array containing resource definition objects.
7204     @rdfs:subClassOf:
7205     Perl:ARRAY::ManakaiDOM:all
7206 wakaba 1.3
7207     ElementTypeBinding:
7208     @Name: DataTypeDef
7209     @ElementType:
7210     dis:ResourceDef
7211     @ShadowContent:
7212     @@rdf:type:
7213     ManakaiDOM:DataType
7214    
7215     ElementTypeBinding:
7216     @Name: URITypeDef
7217     @ElementType:
7218     dis:ResourceDef
7219     @ShadowContent:
7220     @@rdf:type:
7221     ManakaiDOM:DataType
7222     @@rdfs:subClassOf: AnyURI
7223 wakaba 1.1
7224     ## -- Exceptions
7225    
7226     XParamDef:
7227 wakaba 1.5 @QName: anotherSourceNode
7228     @enDesc:
7229     Another source node in which an error has occurred. In cases
7230     of <QUOTE::already defined> errors, it is the node that
7231     defines the resource first.
7232     @Type: ManakaiDISNode
7233 wakaba 1.3
7234 wakaba 1.12 ResourceDef:
7235     @QName: UNDECLARED_NS_PREFIX_ERR
7236     @For: ForLatest
7237     @AliasFor:
7238     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
7239    
7240 wakaba 1.3 ExceptionDef:
7241     @ClsQName: ManakaiDISException
7242     @enDesc:
7243     Exceptions for the <QUOTE::dis> operations.
7244 wakaba 1.4 @ClsISA:
7245     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
7246 wakaba 1.3 @XConstGroupDef:
7247     @@ClsQName: ManakaiDISExceptionCode
7248     @@enDesc:
7249     Exception codes for <Class::ManakaiDISException>.
7250     @@XConstDef:
7251 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
7252     @@@Value:3
7253     @@@enDesc:
7254     An attempt is made to break the hierarchy.
7255     @@@XSubTypeDef:
7256     @@@@QName: MERGE_ITSELF_ERR
7257     @@@@enDesc:
7258     An attempt is made to merge the resource to itself.
7259     @@@@XSourceNodeParam:
7260     @@@@XParam:
7261     @@@@@QName:uri
7262     @@@@@enDesc:
7263     The URI reference of the resource to merge.
7264     @@@@enMufDef:
7265     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
7266     );> to itself
7267     @@XConstDef:
7268 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
7269     @@@Value:9
7270     @@@enDesc:
7271     An attempt is made to do something the implementation does not support.
7272     @@@XSubTypeDef:
7273     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
7274     @@@@enDesc:
7275     The implementation does not support the media type.
7276     @@@@XParam:
7277     @@@@@QName: uri
7278     @@@@@enDesc:
7279     The URI reference of the media type that is not supported.
7280     @@@@XSourceNodeParam:
7281 wakaba 1.12 @@@@enMufDef:
7282     Media type <%p (name => {<Q::DIS:uri>});> is not supported
7283 wakaba 1.3 @@@XSubTypeDef:
7284 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
7285     @@@@enDesc:
7286     An unsupported type of element is encounted.
7287     @@@@XSourceNodeParam:
7288     @@@@XParam:
7289     @@@@@QName:elementType
7290     @@@@@enDesc:
7291     The element type URI reference of the element.
7292 wakaba 1.16 @@@@enMufDef:
7293     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
7294 wakaba 1.13 @@@XSubTypeDef:
7295 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
7296 wakaba 1.3 @@@@enDesc:
7297 wakaba 1.12 There is no implementation that supports the
7298     <Feature::Util:PerlCode> feature, version
7299     <FeatureVer::1.0>.
7300 wakaba 1.3 @@XConstDef:
7301     @@@Name: INVALID_STATE_ERR
7302     @@@Value:11
7303     @@@enDesc:
7304     An attempt is made to use an object that is not (or no longer) usable.
7305     @@@XSubTypeDef:
7306     @@@@QName: NO_ASSOCIATED_DB_ERR
7307     @@@@enDesc:
7308     No <QUOTE::dis> database has been associated with this document.
7309 wakaba 1.4 @@XConstDef:
7310     @@@Name: INVALID_SOURCE_ERR
7311     @@@Value: 200
7312     @@@enDesc:
7313     The source input is well-formed but invalid.
7314     @@@XSubTypeDef:
7315     @@@@QName: NO_MODULE_QNAME_ERR
7316     @@@@enDesc:
7317     The <Q::dis:Module> element must have its <Q::dis:QName>
7318     attribute.
7319 wakaba 1.8 @@@@XSourceNodeParam:
7320     @@@XSubTypeDef:
7321     @@@@QName: NO_LOCAL_NAME_ERR
7322     @@@@enDesc:
7323     The resource does not have a local name.
7324     @@@@XSourceNodeParam:
7325 wakaba 1.4 @@@XSubTypeDef:
7326     @@@@QName: UNABLE_TO_GET_MODULE_ERR
7327     @@@@enDesc:
7328     The implementation is unable to get the module source.
7329     @@@@Def:
7330     @@@@@ContentType:
7331     lang:muf
7332     @@@@@lang:en
7333     @@@@@@:
7334     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
7335     @@@@XParam:
7336     @@@@@QName: uri
7337     @@@@@enDesc:
7338     The URI reference of the module.
7339     @@@@XParam:
7340     @@@@@QName: namespaceURI
7341     @@@@@enDesc:
7342     The namespace URI of the module name.
7343     @@@@XParam:
7344     @@@@@QName: localName
7345     @@@@@enDesc:
7346     The local name of the module name.
7347     @@@@XParam:
7348     @@@@@QName: for
7349     @@@@@enDesc:
7350     The <QUOTE::for> of the module.
7351 wakaba 1.5 @@@XSubTypeDef:
7352     @@@@QName: NO_FOR_QNAME_ERR
7353     @@@@enDesc:
7354     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
7355     @@@@XSourceNodeParam:
7356     @@@XSubTypeDef:
7357     @@@@QName: FOR_ALREADY_DEFINED_ERR
7358     @@@@enDesc:
7359     The <QUOTE::for> named as the same URI reference has
7360     already defined.
7361     @@@@XSourceNodeParam:
7362     @@@@XParam:
7363     @@@@@QName: anotherSourceNode
7364     @@@@@enDesc:
7365     The node that defines the <QUOTE::for> URI reference before.
7366 wakaba 1.7 @@@@XParam:
7367     @@@@@Name: uri
7368     @@@@@enDesc:
7369     The URI reference of the <QUOTE::for> attempted to define.
7370     @@@@enMufDef:
7371     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
7372 wakaba 1.5 @@@XSubTypeDef:
7373     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
7374     @@@@enDesc:
7375     The <QUOTE::dis> resource named as the same URI reference has
7376     already defined.
7377     @@@@XSourceNodeParam:
7378     @@@@XParam:
7379     @@@@@QName: anotherSourceNode
7380     @@@@@enDesc:
7381     The node that defines the <QUOTE::for> URI reference before.
7382 wakaba 1.7 @@@@XParam:
7383     @@@@@Name: uri
7384     @@@@@enDesc:
7385     The URI reference of the resource attempted to define.
7386     @@@@enMufDef:
7387     Resource <%p (name => {<Q::DIS:uri>});> is already defined
7388 wakaba 1.5 @@@XSubTypeDef:
7389     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
7390     @@@@enDesc:
7391     An element has occured where it is not allowed.
7392     @@@@enMufDef:
7393     Module <%p (name => {<Q::DIS:uri>});>:
7394     Element of type <%p (name => {<Q::DIS:elementType>});>
7395     is not allowed here
7396     @@@@XSourceNodeParam:
7397     @@@@XParam:
7398     @@@@@QName: elementType
7399     @@@@@enDesc:
7400     The expanded element type name of the element.
7401     @@@@XParam:
7402     @@@@@QName: uri
7403     @@@@@enDesc:
7404     The URI reference of the module.
7405 wakaba 1.7 @@@XSubTypeDef:
7406     @@@@QName: NO_REQUIRED_ATTR_ERR
7407     @@@@enDesc:
7408     A required attribute is not specified.
7409     @@@@XSourceNodeParam:
7410     @@@@XParam:
7411     @@@@@QName: elementType
7412     @@@@@enDesc:
7413     The expanded URI reference of the attribute name.
7414     @@@@enMufDef:
7415     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
7416 wakaba 1.8 @@@XSubTypeDef:
7417     @@@@QName: FOR_NOT_DEFINED_ERR
7418     @@@@enDesc:
7419     A <QUOTE::for> is referred but not defined.
7420     @@@@XSourceNodeParam:
7421     @@@@XParam:
7422     @@@@@QName: uri
7423     @@@@@enDesc:
7424     The URI reference of the <QUOTE::for> that is not defined.
7425     @@@@enMufDef:
7426     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
7427     @@@XSubTypeDef:
7428     @@@@QName: RESOURCE_NOT_DEFINED_ERR
7429     @@@@enDesc:
7430 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
7431     or the resource referred does not have the type expected.
7432 wakaba 1.8 @@@@XSourceNodeParam:
7433     @@@@XParam:
7434     @@@@@QName: uri
7435     @@@@@enDesc:
7436     The URI reference of the resource that is not defined.
7437 wakaba 1.13 @@@@XParam:
7438     @@@@@QName: elementType
7439     @@@@@enDesc:
7440     <QUOTE::dis> element type (either tree element type
7441     or preprocessing element type) of the element
7442     in which a reference to the undefined resource is contained.
7443     @@@@XParam:
7444     @@@@@QName: localName
7445     @@@@@enDesc:
7446     The local name of the undefined resource.
7447     @@@@XParam:
7448     @@@@QName: sourceCode
7449     @@@@enDesc:
7450     Source code fragment that referres this resource.
7451     @@@@XParam:
7452     @@@@@QName:expectedType
7453     @@@@@enDesc:
7454     Expected resource type.
7455 wakaba 1.8 @@@@enMufDef:
7456 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
7457 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
7458     suffix => {>});%p (name => {<Q::DIS:localName>},
7459     prefix => { "}, suffix => {"}); is not defined or wrong type%p
7460     (name => {<Q::DIS:expectedType>}, prefix => { (<},
7461     suffix => {> is expected)});
7462     @@@XSubTypeDef:
7463     @@@@QName: NO_SOURCE_NODE_ERR
7464     @@@@enDesc:
7465     A resource does not have associated node in the source tree.
7466     @@@@XSourceNodeParam:
7467     @@@@XParam:
7468     @@@@@QName:uri
7469     @@@@@enDesc:
7470     The URI reference of the resource.
7471 wakaba 1.8 @@@XSubTypeDef:
7472     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
7473     @@@@enDesc:
7474     A reserved Perl method name is used.
7475     @@@@XParam:
7476     @@@@@QName:uri
7477     @@@@@enDesc:
7478     The URI reference of the method resource.
7479     @@@@XSourceNodeParam:
7480     @@@@XParam:
7481     @@@@@QName: generatedName
7482     @@@@@enDesc:
7483     A reserved method name.
7484     @@@XSubTypeDef:
7485     @@@@QName: NO_DIS_TYPE_ERR
7486     @@@@enDesc:
7487     <Q::dis:Type> attribute is not found.
7488     @@@@XSourceNodeParam:
7489 wakaba 1.12 @@@XSubTypeDef:
7490     @@@@QName: NO_METHOD_RETURN_ERR
7491     @@@@enDesc:
7492     A <Q::DISLang:Method> resource does not have any
7493     <Q::DISLang:MethodReturn> child.
7494     @@@@XSourceNodeParam:
7495     @@@XSubTypeDef:
7496     @@@@QName: NO_ATTR_GET_ERR
7497     @@@@enDesc:
7498     A <Q::DISLang:Attribute> resource does not have any
7499     <Q::DISLang:AttributeGet> child.
7500     @@@@XSourceNodeParam:
7501 wakaba 1.13 @@@XSubTypeDef:
7502     @@@@QName:INTERFACE_CLASS_METHOD_ERR
7503     @@@@enDesc:
7504     An attempt is made to call a static (class) method
7505     from an interface.
7506     @@@@XSourceNodeParam:
7507     @@@@XParam:
7508     @@@@@QName:uri
7509     @@@@@enDesc:
7510     The URI reference of the interface.
7511     @@@@XParam:
7512     @@@@@QName:sourceCode
7513     @@@@@enDesc:
7514     Source code fragment that calls a class method.
7515     @@@@XParam:
7516     @@@@@QName:elementType
7517     @@@@@enDesc:
7518     The element type URI reference of the element
7519     that calls a method.
7520     @@@XSubTypeDef:
7521     @@@@QName: BROKEN_PARAM_SPEC_ERR
7522     @@@@enDesc:
7523     A parameter specification is broken.
7524     @@@@XParam:
7525     @@@@@QName: sourceCode
7526     @@@@@enDesc:
7527     Source code fragment that contains the broken parameter
7528     specification.
7529     @@@@XSourceNodeParam:
7530 wakaba 1.15 @@@@enMufDef:
7531     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
7532     suffix => {": });Broken parameter specification
7533 wakaba 1.13 @@@XSubTypeDef:
7534     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
7535     @@@@enDesc:
7536     A preprocessing instruction does not have its element
7537     type.
7538     @@@@XSourceNodeParam:
7539     @@@@XParam:
7540     @@@@@QName:sourceCode
7541     @@@@@enDesc:
7542     Source code fragment.
7543 wakaba 1.16 @@@@enMufDef:
7544     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
7545     suffix => {": });Element type name is not specified
7546 wakaba 1.13 @@@XSubTypeDef:
7547 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
7548 wakaba 1.13 @@@@enDesc:
7549 wakaba 1.15 No Perl package name is defined for the resource referred.
7550 wakaba 1.13 @@@@XSourceNodeParam:
7551     @@@@XParam:
7552 wakaba 1.15 @@@@@QName:sourceCode
7553 wakaba 1.13 @@@@@enDesc:
7554     Source code fragment.
7555     @@@@XParam:
7556 wakaba 1.15 @@@@@QName:uri
7557     @@@@@enDesc:
7558     THe URI reference of the resource referred.
7559     @@@@XParam:
7560     @@@@@QName:elementType
7561     @@@@@enDesc:
7562     The element type of Perl preprocessing instruction
7563     in which the resource is referred.
7564     @@@@enMufDef:
7565     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
7566     package name is not defined
7567     @@@XSubTypeDef:
7568     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
7569     @@@@enDesc:
7570     An exception type specification is required.
7571     @@@@XSourceNodeParam:
7572     @@@@XSourceCodeParam:
7573     @@@@XParam:
7574     @@@@@QName:elementType
7575     @@@@@enDesc:
7576     The element type of the preprocessing instruction.
7577     @@@XSubTypeDef:
7578     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
7579     @@@@enDesc:
7580     A code name specification is required.
7581     @@@@XSourceNodeParam:
7582     @@@@XSourceCodeParam:
7583     @@@@XParam:
7584 wakaba 1.13 @@@@@QName:elementType
7585     @@@@@enDesc:
7586 wakaba 1.15 The element type of the preprocessing instruction.
7587 wakaba 1.13 @@@XSubTypeDef:
7588     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
7589     @@@@enDesc:
7590 wakaba 1.15 The specified resource does not have its Perl definition.
7591 wakaba 1.13 @@@@XSourceNodeParam:
7592 wakaba 1.15 @@@@XSourceCodeParam:
7593 wakaba 1.13 @@@@XParam:
7594 wakaba 1.15 @@@@@QName:elementType
7595     @@@@@enDesc:
7596     The element type of the preprocessing instruction.
7597     @@@@XParam:
7598     @@@@@QName:uri
7599 wakaba 1.13 @@@@@enDesc:
7600 wakaba 1.15 The URI reference of the resource referred.
7601 wakaba 1.13 @@@@XParam:
7602     @@@@@QName:localName
7603     @@@@@enDesc:
7604     The local name of the resource referred.
7605 wakaba 1.15 @@@XSubTypeDef:
7606     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
7607     @@@@enDesc:
7608     A preprocessing instruction which is only allowed in
7609     method definitions is used in a code which is not a method.
7610     @@@@XSourceNodeParam:
7611     @@@@XSourceCodeParam:
7612 wakaba 1.13 @@@@XParam:
7613 wakaba 1.15 @@@@@QName:elementType
7614 wakaba 1.13 @@@@@enDesc:
7615 wakaba 1.15 The element type of the preprocessing instruction.
7616 wakaba 1.14 @@@XSubTypeDef:
7617 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
7618 wakaba 1.14 @@@@enDesc:
7619 wakaba 1.15 A <QUOTE::for> specification is required.
7620 wakaba 1.14 @@@@XSourceNodeParam:
7621 wakaba 1.15 @@@@XSourceCodeParam:
7622 wakaba 1.14 @@@@XParam:
7623 wakaba 1.15 @@@@@QName:elementType
7624 wakaba 1.14 @@@@@enDesc:
7625 wakaba 1.15 The element type of the preprocessing instruction.
7626     @@@XSubTypeDef:
7627     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
7628     @@@@enDesc:
7629     An assertion type specification is required.
7630     @@@@XSourceNodeParam:
7631     @@@@XSourceCodeParam:
7632 wakaba 1.14 @@@@XParam:
7633 wakaba 1.15 @@@@@QName:elementType
7634 wakaba 1.14 @@@@@enDesc:
7635 wakaba 1.15 The element type of the preprocessing instruction.
7636     @@@XSubTypeDef:
7637     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
7638     @@@@enDesc:
7639     A preprocessing instruction block occurred with
7640     element type which does not allow it.
7641     @@@@XSourceNodeParam:
7642     @@@@XSourceCodeParam:
7643 wakaba 1.14 @@@@XParam:
7644     @@@@@QName:elementType
7645     @@@@@enDesc:
7646 wakaba 1.15 The element type of the preprocessing instruction.
7647 wakaba 1.18 @@@XSubTypeDef:
7648     @@@@QName: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
7649     @@@@enDesc:
7650     A non-named method parameter following
7651     any named method parameter is occurred.
7652     @@@@XSourceNodeParam:
7653     @@@@XParam:
7654     @@@@@QName:uri
7655     @@@@@enDesc:
7656     The URI reference of the non-named method parameter resource.
7657     @@@@XParam:
7658     @@@@@QName:localName
7659     @@@@@enDesc:
7660     The local name of the non-named method parameter.
7661 wakaba 1.19 @@@XSubTypeDef:
7662     @@@@QName:DISPERL_NO_VALUE_ALLOWED_ERR
7663     @@@@enDesc:
7664     An element node have a value but the definition
7665     of that element type does not allow it.
7666     @@@@XSourceNodeParam:
7667     @@@@XParam:
7668     @@@@@QName:elementType
7669     @@@@@enDesc:
7670     The element type URI reference of the element.
7671     @@@XSubTypeDef:
7672     @@@@QName:NO_CONST_VALUE_ERR
7673     @@@@enDesc:
7674     The source element node for a constant value resource
7675     does not have <Q::dis:Value> attribute.
7676     @@@@XSourceNodeParam:
7677     @@@@XParam:
7678     @@@@@QName:elemntType
7679     @@@@@enDesc:
7680     The element type URI reference of the element from which
7681     a constant value resource is referred.
7682     @@@@XParam:
7683     @@@@@QName:uri
7684     @@@@@enDesc:
7685     The resource URI reference of the constant value resource.
7686     @@@@XParam:
7687     @@@@@QName:localName
7688     @@@@@enDesc:
7689     The local name of the constant value resource.
7690     @@@XSubTypeDef:
7691     @@@@QName:NO_ATTR_SET_ERR
7692     @@@@enDesc:
7693     An attribute setter is referred but the attribute
7694     does not define any setter.
7695     @@@@XSourceNodeParam:
7696     @@@@XParam:
7697     @@@@@QName:errResource
7698     @@@@@enDesc:
7699     The attribute resource.
7700     @@@@XParam:
7701     @@@@@QName:elementType
7702     @@@@@enDesc:
7703     The type of the element by which this attribute
7704     is referred.
7705 wakaba 1.20 @@@XSubTypeDef:
7706     @@@@QName: PERL_SUBROUTINE_ALREADY_DEFINED_ERR
7707     @@@@enDesc:
7708     A resource defines a Perl subroutine whose name is
7709     same as another subroutine.
7710     @@@@XSourceNodeParam:
7711     @@@@XParam:
7712     @@@@@QName:uri
7713     @@@@@enDesc:
7714     The URI reference of the resource that defines the Perl subroutine.
7715     @@@@XParam:
7716     @@@@@QName:
7717     PerlCode:localName
7718     @@@@@enDesc:
7719     The name of the Perl subroutine.
7720     @@@XSubTypeDef:
7721     @@@@QName: PERL_OPERATOR_ALREADY_OVERLOADED_ERR
7722     @@@@enDesc:
7723     A resource is defined to overload a Perl operator which
7724     is already overloaded by another resource.
7725     @@@@XSourceNodeParam:
7726     @@@@XParam:
7727     @@@@@QName:uri
7728     @@@@@enDesc:
7729     The URI reference of the resource that defines the overloading.
7730     @@@@XParam:
7731     @@@@@QName:
7732     PerlCode:operator
7733     @@@@@enDesc:
7734     The operator.
7735     @@@XSubTypeDef:
7736     @@@@QName: PERL_UNUSED_SUBROUTINE_ERR
7737     @@@@enDesc:
7738     A resource defines a Perl subroutine but it is not used.
7739     @@@@XSourceNodeParam:
7740     @@@@XParam:
7741     @@@@@QName:uri
7742     @@@@@enDesc:
7743     The URI reference of the resource.
7744 wakaba 1.4 ##DISException
7745 wakaba 1.13
7746     XParamDef:
7747     @QName:expectedType
7748     @Type: ResourceURI
7749     @enDesc:
7750     Expected resource type URI reference.
7751    
7752     XParamDef:
7753     @QName: sourceCode
7754     @Type:
7755     DISLang:String::ManakaiDOM:all
7756     @enDesc:
7757     The source code fragment in which an error occurred.
7758 wakaba 1.5
7759     XParamDef:
7760     @QName: elementType
7761     @Type: ResourceURI
7762     @enDesc:
7763     The name of the element type.
7764    
7765     XParamDef:
7766     @QName: uri
7767     @Type: ResourceURI
7768     @enDesc:
7769     The name of the resource, composed from <Q::namespaceURI>,
7770     <Q::localName> and <Q::for>.
7771    
7772     XParamDef:
7773     @QName: localName
7774     @Type:
7775 wakaba 1.18 DISCore:LocalName::ManakaiDOM:all
7776 wakaba 1.5 @enDesc:
7777     The local name of the resource, unique in <Q::namespaceURI> namespace.
7778    
7779     XParamDef:
7780     @QName: namespaceURI
7781     @Type: AnyURI
7782     @enDesc:
7783     The namespace URI reference of the resource name.
7784    
7785     XParamDef:
7786     @QName: for
7787     @Type: ForURI
7788     @enDesc:
7789     The <QUOTE::for> URI reference of the resource.
7790    
7791     ElementTypeBinding:
7792     @Name: XSourceNodeParam
7793     @ElementType:
7794     ManakaiDOM:exceptionOrWarningParameter
7795     @ShadowContent:
7796     @@QName: sourceNode
7797     @@Description:
7798     @@@lang:en
7799     @@@@:
7800     The node in which an error has occurred.
7801 wakaba 1.15
7802     ElementTypeBinding:
7803     @Name: XSourceCodeParam
7804     @ElementType:
7805     ManakaiDOM:exceptionOrWarningParameter
7806     @ShadowContent:
7807     @@QName: sourceCode
7808     @@Description:
7809     @@@lang:en
7810     @@@@:
7811     The source code in which an error has occurred.
7812 wakaba 1.4
7813     ClsDef:
7814     @ClsQName: ManakaiDISExceptionTarget
7815     @enDesc:
7816     Objects that is able to be the target of an exception.
7817     @IntMethod:
7818     @@Operator:
7819     @@@@:
7820     ManakaiDOM:MUErrorHandler
7821     @@@ContentType:
7822     dis:TypeQName
7823     @@Description:
7824     @@@lang:en
7825     @@@@:
7826     This method is a generic error handler; all manakai exceptions
7827     and warnings associated to an object are once reported to this method
7828     and then delivered to appropriate entities.
7829     \
7830     If the error is an exception (such as <X::DOMCore:DOMException> or
7831     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
7832     simply thrown. If the error is only a warning, it is reported
7833     via the <IF::DOMCore:DOMError> interface.
7834     \
7835     See <PerlModule::Message::Util::Error> documentation for more
7836     information on the error reporting mechanism.
7837     \
7838     {NOTE:: This kind of methods are named as <Perl::___report_error>
7839     in the convention of <PerlModule::Message::Util::Error>.
7840     \
7841     }
7842     @@Param:
7843     @@@Name:err
7844     @@@Type:
7845     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
7846     @@@Description:
7847     @@@@lang:en
7848     @@@@@:
7849     An exception object that describes what kind of error it is
7850     and how it should be recovered.
7851     \
7852     {NOTE:: Exception objects in manakai implementation
7853     inherit the class <PerlModule::Message::Util::Error>,
7854     that in turn inherits <PerlModule::Error>.
7855     \
7856     }
7857     @@Return:
7858     @@@PerlDef:
7859     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
7860     ::ManakaiDOM:Perl>)) {
7861     $err->throw;
7862     } else {
7863     \## TODO: Implement warning reporting
7864     warn $err->stringify;
7865     }
7866     ##DISExceptionTarget
7867    
7868     ForDef:
7869     @QName:
7870     DIS:ForIF
7871     ForDef:
7872     @QName:
7873     DIS:ForClass
7874    
7875     ElementTypeBinding:
7876     @Name: IFClsDef
7877     @ElementType:
7878     dis:ResourceDef
7879     @ShadowContent:
7880     @@rdf:type:
7881     @@@@:
7882     dis:MultipleResource
7883     @@@ForCheck: !ForClass !ForIF
7884     @@rdf:type:
7885     @@@@:
7886     ManakaiDOM:IF
7887     @@@ForCheck: ForIF
7888     @@rdf:type:
7889     @@@@:
7890     ManakaiDOM:Class
7891     @@@ForCheck: ForClass
7892     @@resourceFor: ForIF
7893     @@resourceFor:
7894     @@@@: ForClass
7895     @@@ForCheck: ForLatest
7896     @@DOMMain:implementFeature:
7897     @@@@:CoreFeature10
7898     @@@ForCheck: ForClass
7899     @@ForCheck:
7900     ManakaiDOM:Perl
7901 wakaba 1.3
7902     ElementTypeBinding:
7903     @Name: ClsDef
7904     @ElementType:
7905     dis:ResourceDef
7906     @ShadowContent:
7907     @@rdf:type:
7908     ManakaiDOM:Class
7909     @@AliasFor:
7910     @@@@:
7911 wakaba 1.11 ::DIS:ForLatest
7912 wakaba 1.3 @@@For:
7913 wakaba 1.11 !=DIS:ForLatest
7914 wakaba 1.3 @@ForCheck:
7915     ManakaiDOM:Perl
7916     @@DOMMain:implementFeature: CoreFeature10
7917    
7918     ElementTypeBinding:
7919     @Name: ExceptionDef
7920     @ElementType:
7921     dis:ResourceDef
7922     @ShadowContent:
7923     @@rdf:type:
7924     ManakaiDOM:ExceptionClass
7925     @@AliasFor:
7926     @@@@:
7927     ::ForLatest
7928     @@@For:
7929     !=ForLatest
7930     @@ForCheck:
7931     ManakaiDOM:Perl
7932     @@DOMMain:implementFeature: CoreFeature10
7933    
7934     ElementTypeBinding:
7935     @Name: ClsQName
7936     @ElementType:
7937     dis:QName
7938    
7939     ElementTypeBinding:
7940     @Name: ClsISA
7941     @ElementType:
7942     dis:ISA
7943    
7944     ElementTypeBinding:
7945     @Name: Method
7946     @ElementType:
7947     dis:ResourceDef
7948     @ShadowContent:
7949     @@rdf:type:
7950     DISLang:Method
7951    
7952     ElementTypeBinding:
7953     @Name: IntMethod
7954     @ElementType:
7955     dis:ResourceDef
7956     @ShadowContent:
7957     @@rdf:type:
7958     DISLang:Method
7959     @@ManakaiDOM:isForInternal:1
7960    
7961     ElementTypeBinding:
7962     @Name: Attr
7963     @ElementType:
7964     dis:ResourceDef
7965     @ShadowContent:
7966     @@rdf:type:
7967     DISLang:Attribute
7968    
7969     ElementTypeBinding:
7970     @Name: Return
7971     @ElementType:
7972     dis:ResourceDef
7973     @ShadowContent:
7974     @@rdf:type:
7975     DISLang:MethodReturn
7976    
7977     ElementTypeBinding:
7978     @Name: Get
7979     @ElementType:
7980     dis:ResourceDef
7981     @ShadowContent:
7982     @@rdf:type:
7983     DISLang:AttributeGet
7984    
7985     ElementTypeBinding:
7986     @Name: Set
7987     @ElementType:
7988     dis:ResourceDef
7989     @ShadowContent:
7990     @@rdf:type:
7991     DISLang:AttributeSet
7992    
7993     ElementTypeBinding:
7994     @Name: Param
7995     @ElementType:
7996     dis:ResourceDef
7997     @ShadowContent:
7998     @@rdf:type:
7999     DISLang:MethodParameter
8000    
8001     ElementTypeBinding:
8002     @Name: PerlDef
8003     @ElementType:
8004     dis:Def
8005     @ShadowContent:
8006     @@ContentType:
8007     lang:Perl
8008    
8009     ElementTypeBinding:
8010     @Name: disDef
8011     @ElementType:
8012     dis:Def
8013     @ShadowContent:
8014     @@ContentType:
8015     lang:dis
8016    
8017     ElementTypeBinding:
8018     @Name: InCase
8019     @ElementType:
8020     dis:ResourceDef
8021     @ShadowContent:
8022     @@rdf:type:
8023     ManakaiDOM:InCase
8024    
8025     ElementTypeBinding:
8026     @Name: nullCase
8027     @ElementType:
8028     dis:ResourceDef
8029     @ShadowContent:
8030     @@rdf:type:
8031     ManakaiDOM:InCase
8032     @@Value:
8033     @@@is-null:1
8034    
8035     ElementTypeBinding:
8036     @Name: TrueCase
8037     @ElementType:
8038     dis:ResourceDef
8039     @ShadowContent:
8040     @@rdf:type:
8041     ManakaiDOM:InCase
8042     @@Value:true
8043     @@Type:
8044 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8045 wakaba 1.3
8046    
8047     ElementTypeBinding:
8048     @Name: FalseCase
8049     @ElementType:
8050     dis:ResourceDef
8051     @ShadowContent:
8052     @@rdf:type:
8053     ManakaiDOM:InCase
8054     @@Value:false
8055     @@Type:
8056 wakaba 1.18 DOMMain:boolean::ManakaiDOM:all
8057 wakaba 1.3
8058     ElementTypeBinding:
8059     @Name: enDesc
8060     @ElementType:
8061     dis:Description
8062     @ShadowContent:
8063     @@lang:en
8064    
8065     ElementTypeBinding:
8066     @Name: PropDef
8067     @ElementType:
8068     dis:ResourceDef
8069     @ShadowContent:
8070     @@rdf:type:
8071     rdf:Property
8072     @@AliasFor:
8073     @@@@:
8074     ::ManakaiDOM:all
8075     @@@For:
8076     !=ManakaiDOM:all
8077    
8078     ElementTypeBinding:
8079     @Name: MethodRedef
8080     @ElementType:
8081     dis:ResourceDef
8082     @ShadowContent:
8083     @@rdf:type:
8084     DISLang:Method
8085     @@ManakaiDOM:isRedefining:1
8086    
8087     ElementTypeBinding:
8088     @Name: NamedParam
8089     @ElementType:
8090     dis:ResourceDef
8091     @ShadowContent:
8092     @@rdf:type:
8093     DISLang:MethodParameter
8094     @@DISPerl:isNamedParameter:1
8095    
8096     ElementTypeBinding:
8097     @Name: NodeParam
8098     @ElementType:
8099     dis:ResourceDef
8100     @ShadowContent:
8101     @@rdf:type:
8102     DISLang:MethodParameter
8103     @@DISPerl:isNamedParameter:1
8104     @@Name: node
8105     @@Type: ManakaiDISNode
8106     @@Description:
8107     @@@lang:en
8108     @@@@:
8109     The node in which the name has occurred. It is intended
8110     to be reported when an exception had been raised.
8111     @@ResourceDef:
8112     @@@rdf:type:
8113     ManakaiDOM:InCase
8114     @@@Value:
8115     @@@@is-null:1
8116     @@@Description:
8117     @@@@lang:en
8118     @@@@@:
8119     The source of the name is not a node.
8120    
8121     ElementTypeBinding:
8122     @Name: ForParam
8123     @ElementType:
8124     dis:ResourceDef
8125     @ShadowContent:
8126     @@rdf:type:
8127     DISLang:MethodParameter
8128     @@DISPerl:isNamedParameter:1
8129     @@Name: forArg
8130     @@Type: ForURI
8131     @@Description:
8132     @@@lang:en
8133     @@@@:
8134     The <QUOTE::for> URI reference.
8135     @@ResourceDef:
8136     @@@rdf:type:
8137     ManakaiDOM:InCase
8138     @@@Value:
8139     @@@@is-null:1
8140     @@@Description:
8141     @@@@lang:en
8142     @@@@@:
8143     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
8144    
8145     ElementTypeBinding:
8146     @Name: ForpParam
8147     @ElementType:
8148     dis:ResourceDef
8149     @ShadowContent:
8150     @@rdf:type:
8151     DISLang:MethodParameter
8152     @@DISPerl:isNamedParameter:1
8153     @@Name: forpArg
8154     @@Type: ForURIList
8155     @@Description:
8156     @@@lang:en
8157     @@@@:
8158     An array reference containing additional <QUOTE::for>
8159     constraints (<QUOTE::For+> list).
8160     @@ResourceDef:
8161     @@@rdf:type:
8162     ManakaiDOM:InCase
8163     @@@Value:
8164     @@@@is-null:1
8165     @@@Description:
8166     @@@@lang:en
8167     @@@@@:
8168     Equivalent to the empty array reference.
8169    
8170     ElementTypeBinding:
8171     @Name: MediaTypeParam
8172     @ElementType:
8173     dis:ResourceDef
8174     @ShadowContent:
8175     @@rdf:type:
8176     DISLang:MethodParameter
8177     @@DISPerl:isNamedParameter:1
8178     @@Name: mediaType
8179     @@Type: MediaTypeURI
8180     @@Description:
8181     @@@lang:en
8182     @@@@:
8183     The URI reference identifying a media type.
8184     @@ResourceDef:
8185     @@@rdf:type:
8186     ManakaiDOM:InCase
8187     @@@Value:
8188     @@@@is-null:1
8189     @@@Description:
8190     @@@@lang:en
8191     @@@@@:
8192     No media type specified.
8193    
8194     ElementTypeBinding:
8195     @Name: MediaTypeDefaultParam
8196     @ElementType:
8197     dis:ResourceDef
8198     @ShadowContent:
8199     @@rdf:type:
8200     DISLang:MethodParameter
8201     @@DISPerl:isNamedParameter:1
8202     @@Name: defaultMediaType
8203     @@Type: MediaTypeURI
8204     @@Description:
8205     @@@lang:en
8206     @@@@:
8207     The default media type, i.e. the type used when no explicit
8208     specification is not found in the source tree.
8209     @@ResourceDef:
8210     @@@rdf:type:
8211     ManakaiDOM:InCase
8212     @@@Value:
8213     @@@@is-null:1
8214     @@@Description:
8215     @@@@lang:en
8216     @@@@@:
8217     Defaulted to <Q::DOMMain:any>.
8218    
8219     ElementTypeBinding:
8220     @Name: RaiseException
8221     @ElementType:
8222     ManakaiDOM:raises
8223    
8224     ElementTypeBinding:
8225     @Name: UndeclaredPrefixException
8226     @ElementType:
8227     ManakaiDOM:raises
8228     @ShadowContent:
8229     @@@: UNDECLARED_NS_PREFIX_ERR
8230     @@Description:
8231     @@@lang:en
8232     @@@@:
8233     The implementation has encounted an undeclared namespace prefix.
8234    
8235     ElementTypeBinding:
8236     @Name: NoDBException
8237     @ElementType:
8238     ManakaiDOM:raises
8239     @ShadowContent:
8240     @@@: NO_DB_ASSOCIATED_ERR
8241     @@Description:
8242     @@@lang:en
8243     @@@@:
8244     No <QUOTE::dis> database is associated to this document.
8245    
8246     ElementTypeBinding:
8247     @Name: XConstGroupDef
8248     @ElementType:
8249     dis:ResourceDef
8250     @ShadowContent:
8251     @@rdf:type:
8252     ManakaiDOM:ConstGroup
8253     @@Type:
8254     DOMMain:unsigned-short::ManakaiDOM:all
8255     @@rdfs:subClassOf:
8256     DOMMain:unsigned-short::ManakaiDOM:all
8257    
8258     ElementTypeBinding:
8259     @Name: XConstDef
8260     @ElementType:
8261     dis:ResourceDef
8262     @ShadowContent:
8263     @@rdf:type:
8264     ManakaiDOM:Const
8265    
8266     ElementTypeBinding:
8267     @Name: XSubTypeDef
8268     @ElementType:
8269     dis:ResourceDef
8270     @ShadowContent:
8271     @@rdf:type:
8272     ManakaiDOM:ExceptionOrWarningSubType
8273    
8274     ElementTypeBinding:
8275     @Name: XParam
8276     @ElementType:
8277     ManakaiDOM:exceptionOrWarningParameter
8278    
8279     ElementTypeBinding:
8280     @Name: XParamDef
8281     @ElementType:
8282     dis:ResourceDef
8283     @ShadowContent:
8284     @@rdf:type:
8285     DOMMain:XWParameter
8286 wakaba 1.12 @@For:
8287     =ManakaiDOM:all
8288 wakaba 1.3
8289     ElementTypeBinding:
8290     @Name: enMufDef
8291     @ElementType:
8292     dis:Def
8293     @ShadowContent:
8294     @@ContentType:
8295     lang:muf
8296     @@lang:en
8297 wakaba 1.21
8298     ResourceDef:
8299     @QName:
8300     lang:muf
8301     @rdf:type:
8302     rdfs:Class
8303     @ImplNote:
8304     @@lang:en
8305     @@@:
8306     Should be moved to some other module.
8307 wakaba 1.3

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24