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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24