/[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.22 - (hide annotations) (download)
Thu Apr 28 15:22:59 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.21: +258 -80 lines
bin/dac2pm.pl: New script; lib/Message/Util/DIS.dis: Module generation implemented; lib/Makefile: New

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24