/[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.17 - (hide annotations) (download)
Sun Apr 3 04:23:06 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.16: +98 -13 lines
Line number insertion implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24