/[suikacvs]/messaging/manakai/lib/Message/Util/ManakaiNode.dis
Suika

Contents of /messaging/manakai/lib/Message/Util/ManakaiNode.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Mon Sep 19 16:17:52 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.14: +7 -7 lines
++ ./bin/ChangeLog	19 Sep 2005 12:05:15 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* mkdisdump.pl (progress_inc, progress_reset): New functions.

++ ./lib/Message/Util/ChangeLog	19 Sep 2005 12:14:55 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis: Parameter "databaseArg" added to various
	methods to support objects that have no associated
	database.
	(getNamespaceBindingList, getDefaultNamespaceURIRef): New
	methods.
	(NO_RDF_TYPE_ERR): New error type.
	(loadResource): Throws NO_RDF_TYPE_ERR if no rdf:type
	attribute specified for a resource definition.

++ ./lib/Message/Util/Error/ChangeLog	19 Sep 2005 12:21:57 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* Core.dis: Missing rdf:type attribute added to classes.

++ ./lib/Message/Util/DIS/ChangeLog	19 Sep 2005 12:23:54 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* Value.dis (sourceNodePath): New attribute.
	(DVNSValue, DVNSOrderedList): New interfaces and classes.

	* Perl.dis: Some alias definitions moved from ../DIS.dis.
	The "namespaceContext" parameters added to some methods.
	(plCodeFragment): Now Perl'ize new DISCore:Integer typed string.
	(plImplementation): Directly instantiates PCImplementation
	to reduce overheads to find an implementation by ImplementationRegistry.

++ ./lib/Message/DOM/ChangeLog	19 Sep 2005 12:08:55 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DOMMain.dis (ManakaiDOM:DOMMethod, ManakaiDOM:DOMMethodReturn,
	ManakaiDOM:DOMAttribute, ManakaiDOM:DOMAttrGet,
	ManakaiDOM:DOMAttrSet, ManakaiDOM:DOMMethodParam): Removed.
	(ManakaiDOMTimeStamp): Removed.

	* DOMBoot.dis, DOMMetaImpl.dis, DOMMetaImpl.pm: Removed (they are no
	longer in use).

2005-09-18  Wakaba  <wakaba@suika.fam.cx>

	* DOMMain.dis (StringOutOfBoundsException): New exception.

++ ./lib/manakai/ChangeLog	19 Sep 2005 12:23:20 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DISCore.dis (DISCore:Boolean): New preferred name
	to dis:Boolean.
	(DISCore:Integer): New type.
	(dis:Value): Default type is changed to DISCore:String.

1 wakaba 1.1 Module:
2     @QName:
3     Util:ManakaiNode
4     @FullName:
5     @@lang: en
6     @@@:
7     Manakai Generic Node Implementation
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
10    
11     @Description:
12     @@lang:en
13     @@@:
14     The <Module::Util:ManakaiNode> module provides a basic
15     implementation for glaph (perhaps tree) structures.
16    
17     @Author:
18     @@FullName: Wakaba
19     @@Mail: w@suika.fam.cx
20     @License:
21     license:Perl+MPL
22     @Date:
23     @@@:
24 wakaba 1.15 $Date: 2005/09/17 15:03:03 $
25 wakaba 1.1 @@ContentType:
26     dis:Date.RCS
27    
28     @Require:
29     @@Module:
30     @@@Name: DISPerl
31 wakaba 1.4 @@@QName:
32     DISlib:DISPerl
33 wakaba 1.1 @@@WithFor:
34     ManakaiDOM:all
35 wakaba 1.2 @@Module:
36     @@@Name: ManakaiNode
37     @@@WithFor:
38     ManakaiDOM:Perl
39    
40     @DefaultFor:
41     ManakaiDOM:Perl
42 wakaba 1.1
43     Namespace:
44 wakaba 1.13 @DIS:
45     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
46 wakaba 1.1 @dis:
47     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
48     @dis2pm:
49     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
50 wakaba 1.4 @DISlib:
51     http://suika.fam.cx/~wakaba/archive/2004/dis/
52 wakaba 1.13 @doc:
53     http://suika.fam.cx/~wakaba/archive/2005/7/tutorial#
54 wakaba 1.14 @DOMMain:
55     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
56 wakaba 1.1 @lang:
57     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
58     @license:
59     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
60     @ManakaiDOM:
61     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
62 wakaba 1.10 @mn:
63     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
64 wakaba 1.1 @owl:
65     http://www.w3.org/2002/07/owl#
66     @Perl:
67     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
68     @rdf:
69     http://www.w3.org/1999/02/22-rdf-syntax-ns#
70     @rdfs:
71     http://www.w3.org/2000/01/rdf-schema#
72     @TreeCore:\
73     @Util:
74     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
75    
76     ResourceDef:
77     @QName:
78     Util:
79     @rdf:type:
80     dis:ModuleGroup
81     @FullName:
82     @@lang:en
83     @@@:
84     The manakai support modules
85     @AppName:
86 wakaba 1.10 @@@:
87     Message::Util::IF::
88     @@ForCheck:
89 wakaba 1.13 ManakaiDOM:ForIF !DIS|ForEmpty
90     @AppName:
91     @@@:
92     Message::Util::IF::
93     @@ForCheck:
94     ManakaiDOM:ForIF =DIS|ForEmpty
95     @AppName:
96     @@@:
97     Message::Util::IFLatest::
98     @@ForCheck:
99     ManakaiDOM:ForIF DIS|ForEmpty
100 wakaba 1.11 @AppName:
101     Message::Util::
102 wakaba 1.14 @DISPerl:classPackage:
103     Message::Util::
104     @DISPerl:interfacePackage:
105     @@@:
106     Message::Util::IF::
107     @@For: !DIS|ForEmpty
108     @@For: =DIS|ForEmpty
109     @DISPerl:interfacePackage:
110     @@@:
111     Message::Util::IFLatest::
112     @@ForCheck: DIS|ForEmpty
113 wakaba 1.1
114 wakaba 1.13 ForDef:
115     @QName: DIS|ForEmpty
116     @enDesc:
117     For any version
118     @ISA:
119     ManakaiDOM:Perl
120    
121 wakaba 1.1 ## -- Internal node object
122    
123     ClassDef:
124 wakaba 1.10 @resourceFor: ForFull
125     @resourceFor: ForCompact
126     @resourceFor:
127     ManakaiDOM:ForIF
128    
129     @QName:
130     @@@: NodeStem
131     @@ForCheck:
132     ManakaiDOM:ForIF
133    
134 wakaba 1.1 @QName:
135 wakaba 1.10 @@@:
136     ManakaiDOM:ManakaiDOMNodeObject
137     @@ForCheck: ForFull
138    
139     @QName:
140     @@@: ManakaiNodeStem
141     @@ForCheck: ForCompact
142    
143     @Implement:
144     @@@: NodeStem
145     @@ForCheck: ForFull
146    
147     @Implement:
148     @@@: NodeStem
149     @@ForCheck: ForCompact
150    
151 wakaba 1.1 @Description:
152     @@lang:en
153     @@@:
154     Internal (actual) node objects that is accessed via
155     <Class::ManakaiDOM:ManakaiDOMNodeReference> objects referring it.
156     @ImplNote:
157     @@lang:en
158     @@@:
159     No public interface should be defined for any class inheriting
160     this class - applications should access to nodes only via
161     <Class::ManakaiDOM:ManakaiDOMNodeReference> objects.
162     @ImplNote:
163 wakaba 1.13 @@ForCheck: ManakaiDOM|ForClass
164 wakaba 1.1 @@lang:en
165     @@@:
166 wakaba 1.13 A <Class::> object is a blessed hash
167 wakaba 1.1 reference. Each hash key and value pair is called as a
168     <DFN::property>. Currently, several core properties
169 wakaba 1.13 are defined as listed below. Applications of this class,
170     such as <Class::DOMCore:ManakaiDOMNode::ManakaiDOM:all>,
171     defines additional properties for their own purpose and scope.
172 wakaba 1.1 \
173 wakaba 1.13 {doc:fig:: <doc:caption::Core node properties>
174    
175     {doc:figBody::
176 wakaba 1.1 \
177     - <CODE::TreeCore:nodeID>::: The global-unique identifier for
178     this node object.
179     \
180     - <CODE::TreeCore:treeID>::: The global-unique identifier for the
181     tree containing this node object.
182     \
183     - <CODE::TreeCore:rc>::: The number that denotes how many reference
184     to this node there are.
185     \
186     - <CODE::TreeCore:origin>::: An array reference, containing
187     hash key names of <DFN::origin>
188     properties for this node.
189     \
190 wakaba 1.3 - <CODE::TreeCore:subnode0>::: An array reference, containing
191     hash key names of <DFN::subnode>
192     properties for this node.
193     \
194 wakaba 1.1 - <CODE::TreeCore:subnode>::: An array reference, containing
195 wakaba 1.3 hash key names of <DFN::subnode> list
196 wakaba 1.1 properties for this node.
197     \
198     - <CODE::TreeCore:subnode2>::: An array reference, containing
199 wakaba 1.3 hash key names of <DFN::subnode> (two steps) list
200 wakaba 1.1 properties for this node.
201     \
202     - <CODE::TreeCore:irefnode>::: An array reference, containing
203     hash key names of <DFN::irefnode>
204     properties for this node.
205     \
206     - <CODE::TreeCore:anydata>::: An array reference, containing
207 wakaba 1.3 hash key names of <DFN::anydata> list
208     properties for this node.
209 wakaba 1.1 \
210     - <CODE::TreeCore:anydata2>::: An array reference, containing
211 wakaba 1.3 hash key names of <DFN::anydata> (two steps) list properties
212 wakaba 1.1 for this node.
213 wakaba 1.13 }
214 wakaba 1.1 }
215    
216     @IntMethod:
217     @@Name: new
218     @@Description:
219     @@@lang:en
220     @@@@:
221     Constructs a new instance of
222     <Class::ManakaiDOM:ManakaiDOMNodeObject> and returns it.
223     @@Return:
224 wakaba 1.10 @@@Type: NodeStem
225 wakaba 1.1 @@@Description:
226     @@@@lang:en
227     @@@@@:
228     The newly created <Class::ManakaiDOM:ManakaiDOMNodeObject> instance.
229 wakaba 1.7 @@@PerlDef:
230 wakaba 1.1 $r = bless {
231     <Q::TreeCore:origin> => [],
232 wakaba 1.3 <Q::TreeCore:subnode0> => [],
233 wakaba 1.1 <Q::TreeCore:subnode> => [],
234     <Q::TreeCore:subnode2> => [],
235     <Q::TreeCore:irefnode> => [],
236     <Q::TreeCore:anydata> => [],
237     <Q::TreeCore:anydata2> => [],
238     <Q::TreeCore:rc> => 0,
239     <Q::TreeCore:treeID> => <Code::ManakaiDOM:generateUniqueID>,
240     <Q::TreeCore:nodeID> => <Code::ManakaiDOM:generateUniqueID>,
241     }, ref $self || $self;
242 wakaba 1.10
243 wakaba 1.1 @IntMethod:
244     @@Name: newReference
245     @@Description:
246     @@@lang:en
247     @@@@:
248     Creates a new reference to this node and returns it.
249 wakaba 1.6 @@DISCore:isDeprecated:
250     @@@@:1
251     @@@DISCore:alt: getNewReference
252 wakaba 1.10 @@ForCheck: ForFull
253 wakaba 1.1 @@Param:
254     @@@Name: class
255     @@@Type:
256 wakaba 1.7 Perl:package-name::ManakaiDOM:all
257 wakaba 1.1 @@@Description:
258     @@@@lang:en
259     @@@@@:
260     A Perl class package name with which the newly created
261     reference is blessed. The <P::class> class must be a
262     subclass of <Class::ManakaiDOM:ManakaiDOM:ManakaiDOMNodeReference>.
263     @@Return:
264     @@@Type:
265     ManakaiDOM:ManakaiDOMNodeReference
266     @@@Description:
267     @@@@lang:en
268     @@@@@:
269     The newly created node reference.
270     @@@PerlDef:
271     $r = bless {
272     <Q::TreeCore:node> => $self,
273 wakaba 1.7 }, ref $class ? ref $class : defined $class ? $class :
274 wakaba 1.1 <ClassName::ManakaiDOM:ManakaiDOMNodeReference>;
275     $self->{<Q::TreeCore:rc>}++;
276 wakaba 1.6
277     @ResourceDef:
278     @@QName: getNewReference
279     @@rdf:type:
280     dis2pm:BlockCode
281 wakaba 1.10 @@ForCheck: ForFull
282 wakaba 1.6 @@Description:
283     @@@lang:en
284     @@@@:
285     Creates a new node reference object.
286     @@ResourceDef:
287     @@@rdf:type:
288     DISPerl:CodeParameter
289     @@@Name: $object
290 wakaba 1.10 @@@Type: NodeStem
291 wakaba 1.6 @@@In:1
292     @@@enDesc:
293     A node object for which a reference is created.
294     @@@DISPerl:paramStyle: var
295     @@ResourceDef:
296     @@@rdf:type:
297     DISPerl:CodeParameter
298     @@@Name: $ref
299 wakaba 1.10 @@@Type: NodeRef
300 wakaba 1.6 @@@Out:1
301     @@@enDesc:
302     A node reference for <P::$object>. It may or may not
303     be same as <P::$object>.
304     @@@DISPerl:paramStyle: var
305     @@ResourceDef:
306     @@@rdf:type:
307     DISPerl:CodeParameter
308     @@@Name: $class
309     @@@Type:
310     Perl:package-name::ManakaiDOM:all
311     @@@enDesc:
312     A package name with which <P::$ref> is blessed.
313     @@@In:1
314     @@@DISPerl:paramStyle: any
315     @@PerlDef:
316     $object->{<Q::TreeCore:rc>}++;
317     $ref = bless {
318     <Q::TreeCore:node> => $object,
319     }, $class;
320    
321     @ResourceDef:
322     @@QName: getWeakReference
323     @@rdf:type:
324     dis2pm:BlockCode
325 wakaba 1.10 @@ForCheck: ForFull
326 wakaba 1.6 @@Description:
327     @@@lang:en
328     @@@@:
329     Creates a new weak node reference object.
330     \
331     The weak node reference is actually a node reference
332     except that this code fragment does not increment
333     the reference count of the object. When all non-weak
334     references to the object are destructed, then
335     the object is destructed and any operation via
336     weak references will lead unexpected result.
337     \
338     {NOTE:: It is intended that internal code creates a weak reference
339     so that it gets access to public interface.
340     \
341     }
342     @@ResourceDef:
343     @@@rdf:type:
344     DISPerl:CodeParameter
345     @@@Name: $object
346 wakaba 1.10 @@@Type: NodeStem
347 wakaba 1.6 @@@In:1
348     @@@enDesc:
349     A node object for which a reference is created.
350     @@@DISPerl:paramStyle: var
351     @@ResourceDef:
352     @@@rdf:type:
353     DISPerl:CodeParameter
354     @@@Name: $ref
355 wakaba 1.10 @@@Type: NodeRef
356 wakaba 1.6 @@@Out:1
357     @@@enDesc:
358     A node reference for <P::$object>. It may or may not
359     be same as <P::$object>.
360     @@@DISPerl:paramStyle: var
361     @@ResourceDef:
362     @@@rdf:type:
363     DISPerl:CodeParameter
364     @@@Name: $class
365     @@@Type:
366     Perl:package-name::ManakaiDOM:all
367     @@@enDesc:
368     A package name with which <P::$ref> is blessed.
369     @@@In:1
370     @@@DISPerl:paramStyle: any
371     @@PerlDef:
372     $ref = bless {
373 wakaba 1.8 <Q::TreeCore:node> => $object,
374     <Q::TreeCore:isWeak> => true,
375     }, $class;
376    
377     @ResourceDef:
378     @@QName: getWeakRef
379     @@rdf:type:
380     dis2pm:InlineCode
381 wakaba 1.10 @@ForCheck: ForFull
382 wakaba 1.8 @@Description:
383     @@@lang:en
384     @@@@:
385     Creates a new weak node reference object.
386     \
387     The weak node reference is actually a node reference
388     except that this code fragment does not increment
389     the reference count of the object. When all non-weak
390     references to the object are destructed, then
391     the object is destructed and any operation via
392     weak references will lead unexpected result.
393     \
394     {NOTE:: It is intended that internal code creates a weak reference
395     so that it gets access to public interface.
396     \
397     }
398     @@ResourceDef:
399     @@@rdf:type:
400     DISPerl:CodeParameter
401     @@@Name: $object
402 wakaba 1.10 @@@Type: NodeStem
403 wakaba 1.8 @@@In:1
404     @@@enDesc:
405     A node object for which a reference is created.
406     @@@DISPerl:paramStyle: var
407     @@ResourceDef:
408     @@@rdf:type:
409     DISPerl:CodeParameter
410     @@@Name: $class
411     @@@Type:
412     Perl:package-name::ManakaiDOM:all
413     @@@enDesc:
414     A package name with which <P::$ref> is blessed.
415     @@@In:1
416     @@@DISPerl:paramStyle: any
417     @@PerlDef:
418 wakaba 1.9 (bless {
419 wakaba 1.6 <Q::TreeCore:node> => $object,
420     <Q::TreeCore:isWeak> => true,
421 wakaba 1.9 }, $class)
422 wakaba 1.6
423 wakaba 1.1 @IntMethod:
424     @@Name: isExternallyReferred
425     @@Description:
426     @@@lang:en
427     @@@@:
428     Checks whether the tree containing this node has been referred
429     from the outside of the tree or not.
430     @@Return:
431     @@@Type:
432 wakaba 1.7 DISPerl:Boolean::ManakaiDOM:all
433 wakaba 1.1 @@@InCase:
434 wakaba 1.15 @@@@Value:
435     @@@@@@:1
436     @@@@@ContentType: DISCore|Boolean
437 wakaba 1.1 @@@@Description:
438     @@@@@lang:en
439     @@@@@@:
440     There is one or more nodes in the tree that has been
441     referred via <Class::ManakaiDOM:ManakaiDOMNodeReference> objects.
442     @@@InCase:
443 wakaba 1.15 @@@@Value:
444     @@@@@@:0
445     @@@@@ContentType: DISCore|Boolean
446 wakaba 1.1 @@@@Description:
447     @@@@@lang:en
448     @@@@@@: No external reference found.
449     @@@PerlDef:
450 wakaba 1.10 @@@@ForCheck: ForFull
451     @@@@@:
452 wakaba 1.1 if ($self->{<Q::TreeCore:rc>}) {
453     $r = true;
454     } else {
455     my @node = ($self);
456     my %checked;
457 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
458 wakaba 1.9 next unless UNIVERSAL::isa ($node,
459     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
460 wakaba 1.1 if ($node->{<Q::TreeCore:rc>}) {
461     $r = true;
462     last NODES;
463     } elsif ($checked{$node->{<Q::TreeCore:nodeID>}}) {
464     next NODES;
465     }
466     my @n;
467 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
468     if (ref $node->{$p} eq 'ARRAY') {
469     push @n, @{$node->{$p}};
470     } elsif (ref $node->{$p} eq 'HASH') {
471     push @n, values %{$node->{$p}};
472 wakaba 1.1 }
473     }
474 wakaba 1.3 for my $p (@n,
475     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
476     if (ref $p eq 'ARRAY') {
477     push @node, @$p;
478     } elsif (ref $p eq 'HASH') {
479     push @node, values %$p;
480 wakaba 1.1 }
481     }
482 wakaba 1.6 for my $p (@{$node->{<Q::TreeCore:origin>}}) {
483     unshift @node, $node->{$p} if $node->{$p};
484     ## NOTE: Puts the top of the list,
485     ## since upper-level nodes are expected to be referred
486     ## more than lower-levels.
487     }
488     for my $p (@{$node->{<Q::TreeCore:subnode0>}}) {
489 wakaba 1.3 push @node, $node->{$p} if $node->{$p};
490 wakaba 1.1 }
491     $checked{$node->{<Q::TreeCore:nodeID>}} = 1;
492     }
493     }
494 wakaba 1.10 @@@PerlDef:
495     @@@@ForCheck: ForCompact
496     @@@@@:
497     if ($self->{<Q::TreeCore:rc>}) {
498     $r = true;
499     } else {
500     my @node = ($self);
501     my %checked;
502 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
503 wakaba 1.10 next unless ref $node;
504     if ($node->{<Q::TreeCore:rc>}) {
505     $r = true;
506     last NODES;
507     } elsif ($checked{$node->{<Q::TreeCore:nodeID>}}) {
508     next NODES;
509     }
510     my @n;
511     for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
512     if (ref $node->{$p} eq 'ARRAY') {
513     push @n, @{$node->{$p}};
514     } elsif (ref $node->{$p} eq 'HASH') {
515     push @n, values %{$node->{$p}};
516     }
517     }
518     for my $p (@n,
519     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
520     if (ref $p eq 'ARRAY') {
521     push @node, @$p;
522     } elsif (ref $p eq 'HASH') {
523     push @node, values %$p;
524     }
525     }
526     for my $p (@{$node->{<Q::TreeCore:origin>}}) {
527     unshift @node, $node->{$p} if $node->{$p};
528     ## NOTE: Puts the top of the list,
529     ## since upper-level nodes are expected to be referred
530     ## more than lower-levels.
531     }
532     for my $p (@{$node->{<Q::TreeCore:subnode0>}}) {
533     push @node, $node->{$p} if $node->{$p};
534     }
535     $checked{$node->{<Q::TreeCore:nodeID>}} = 1;
536     }
537     }
538 wakaba 1.1
539     @IntMethod:
540     @@Name: destroy
541     @@Description:
542     @@@lang:en
543     @@@@:
544     Destructs the tree containing this node.
545     @@Return:
546     @@@PerlDef:
547 wakaba 1.10 @@@@ForCheck: ForFull
548     @@@@@:
549 wakaba 1.1 my @node = ($self);
550 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
551 wakaba 1.1 my @n;
552 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
553     if (ref $node->{$p} eq 'ARRAY') {
554     push @n, @{$node->{$p}};
555     } elsif (ref $node->{$p} eq 'HASH') {
556     push @n, values %{$node->{$p}};
557 wakaba 1.1 }
558     }
559 wakaba 1.3 for my $p (@n,
560     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
561     if (ref $p eq 'ARRAY') {
562 wakaba 1.10 push @node, grep {UNIVERSAL::isa ($_,
563     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
564 wakaba 1.5 and defined $_->{<Q::TreeCore:nodeID>}} @$p;
565 wakaba 1.3 } elsif (ref $p eq 'HASH') {
566 wakaba 1.10 push @node, grep {UNIVERSAL::isa ($_,
567     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
568 wakaba 1.5 and defined $_->{<Q::TreeCore:nodeID>}}
569 wakaba 1.3 values %$p;
570 wakaba 1.1 }
571     }
572 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
573     \ @{$node->{<Q::TreeCore:subnode0>}}) {
574     push @node, $node->{$p}
575     if defined $node->{$p} and
576     defined $node->{$p}->{<Q::TreeCore:nodeID>};
577 wakaba 1.1 }
578     %$node = ();
579     }
580 wakaba 1.10 @@@PerlDef:
581     @@@@ForCheck: ForCompact
582     @@@@@:
583     my @node = ($self);
584 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
585 wakaba 1.10 next unless ref $node and defined $node->{<Q::TreeCore:nodeID>};
586     my @n;
587     for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
588     if (ref $node->{$p} eq 'ARRAY') {
589     push @n, @{$node->{$p}};
590     } elsif (ref $node->{$p} eq 'HASH') {
591     push @n, values %{$node->{$p}};
592     }
593     }
594     for my $p (@n,
595     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
596     if (ref $p eq 'ARRAY') {
597     push @node, @$p;
598     } elsif (ref $p eq 'HASH') {
599     push @node, values %$p;
600     }
601     }
602     for my $p (@{$node->{<Q::TreeCore:origin>}},
603     \ @{$node->{<Q::TreeCore:subnode0>}}) {
604     push @node, $node->{$p};
605     }
606     %$node = ();
607     }
608 wakaba 1.1 @@ImplNote:
609     @@@lang:en
610     @@@@:
611     This method is different from Perl <Perl::DESTROY> special
612     purpose method.
613     \
614     An <QUOTE::uninitialized> warning in this method might mean
615     some method puts an <Perl::undef> into a list of nodes.
616    
617     @IntMethod:
618     @@Name: importTree
619     @@Description:
620     @@@lang:en
621     @@@@:
622     Changes the tree identifier of the nodes belong to another tree
623     to be same as this node's tree identifier.
624     @@Param:
625     @@@Name: node
626     @@@Type:
627     ManakaiDOM:ManakaiDOMNodeObject
628     @@@Description:
629     @@@@lang:en
630     @@@@@:
631     Any node from the tree to change its identifier.
632     @@Return:
633     @@@PerlDef:
634 wakaba 1.10 @@@@ForCheck: ForFull
635     @@@@@:
636 wakaba 1.1 unless ($node->{<Q::TreeCore:treeID>} eq
637     $self->{<Q::TreeCore:treeID>}) {
638     my @node = ($node);
639 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
640 wakaba 1.10 next unless UNIVERSAL::isa ($node,
641     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
642 wakaba 1.1 my @n;
643 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
644     if (ref $node->{$p} eq 'ARRAY') {
645     push @n, @{$node->{$p}};
646     } elsif (ref $node->{$p} eq 'HASH') {
647     push @n, values %{$node->{$p}};
648 wakaba 1.1 }
649     }
650 wakaba 1.3 for my $p (@n,
651     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
652     if (ref $p eq 'ARRAY') {
653 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
654     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
655 wakaba 1.5 and $_->{<Q::TreeCore:treeID>} ne
656 wakaba 1.3 $self->{<Q::TreeCore:treeID>}} @$p;
657     } elsif (ref $p eq 'HASH') {
658 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
659     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
660 wakaba 1.5 and $_->{<Q::TreeCore:treeID>} ne
661 wakaba 1.1 $self->{<Q::TreeCore:treeID>}}
662 wakaba 1.3 values %$p;
663 wakaba 1.1 }
664     }
665 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
666     \ @{$node->{<Q::TreeCore:subnode0>}}) {
667     push @node, $node->{$p}
668     if defined $node->{$p} and
669     $node->{$p}->{<Q::TreeCore:treeID>} ne
670 wakaba 1.1 $self->{<Q::TreeCore:treeID>};
671     }
672     $node->{<Q::TreeCore:treeID>} = $self->{<Q::TreeCore:treeID>};
673     }
674     }
675 wakaba 1.10 @@@PerlDef:
676     @@@@ForCheck: ForCompact
677     @@@@@:
678     my @node = ($node);
679 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
680 wakaba 1.10 next unless ref $node;
681     next if $node->{<Q::TreeCore:treeID>} eq
682     $self->{<Q::TreeCore:treeID>};
683     my @n;
684     for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
685     if (ref $node->{$p} eq 'ARRAY') {
686     push @n, @{$node->{$p}};
687     } elsif (ref $node->{$p} eq 'HASH') {
688     push @n, values %{$node->{$p}};
689     }
690     }
691     for my $p (@n,
692     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
693     if (ref $p eq 'ARRAY') {
694     push @node, @$p;
695     } elsif (ref $p eq 'HASH') {
696     push @node, values %$p;
697     }
698     }
699     for my $p (@{$node->{<Q::TreeCore:origin>}},
700     \ @{$node->{<Q::TreeCore:subnode0>}}) {
701     push @node, $node->{$p};
702     }
703     $node->{<Q::TreeCore:treeID>} = $self->{<Q::TreeCore:treeID>};
704     }
705 wakaba 1.1
706     @IntMethod:
707     @@Name: changeTreeID
708     @@Description:
709     @@@lang:en
710     @@@@:
711     Changes tree identifier of all nodes traversable from this node.
712     @@Param:
713     @@@Name: treeID
714     @@@Type:
715 wakaba 1.7 DISPerl:String::ManakaiDOM:all
716 wakaba 1.1 @@@Description:
717     @@@@lang:en
718     @@@@@:
719     The new tree identifier.
720     @@Return:
721     @@@PerlDef:
722 wakaba 1.10 @@@@ForCheck: ForFull
723     @@@@@:
724 wakaba 1.1 unless ($self->{<Q::TreeCore:treeID>} eq $treeID) {
725     my @node = ($self);
726 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
727 wakaba 1.9 next unless UNIVERSAL::isa ($node,
728     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
729 wakaba 1.1 my @n;
730 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
731     if (ref $node->{$p} eq 'ARRAY') {
732     push @n, @{$node->{$p}};
733     } elsif (ref $node->{$p} eq 'HASH') {
734     push @n, values %{$node->{$p}};
735 wakaba 1.1 }
736     }
737 wakaba 1.3 for my $p (@n,
738     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
739     if (ref $p eq 'ARRAY') {
740 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
741     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
742 wakaba 1.5 and
743     $_->{<Q::TreeCore:treeID>} ne $treeID} @$p;
744 wakaba 1.3 } elsif (ref $p eq 'HASH') {
745 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
746     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
747 wakaba 1.5 and $_->{<Q::TreeCore:treeID>} ne $treeID}
748 wakaba 1.3 values %$p;
749 wakaba 1.1 }
750     }
751 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
752     \ @{$node->{<Q::TreeCore:subnode0>}}) {
753     push @node, $node->{$p}
754     if defined $node->{$p} and
755     $node->{$p}->{<Q::TreeCore:treeID>} ne $treeID;
756 wakaba 1.1 }
757     $node->{<Q::TreeCore:treeID>} = $treeID;
758     }
759     }
760     @@@PerlDef:
761 wakaba 1.10 @@@@ForCheck: ForCompact
762     @@@@@:
763     my @node = ($self);
764 wakaba 1.12 NODES: while (defined (my $node = shift @node)) {
765 wakaba 1.10 next unless ref $node;
766     next if $node->{<Q::TreeCore:treeID>} eq $treeID;
767     my @n;
768     for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
769     if (ref $node->{$p} eq 'ARRAY') {
770     push @n, @{$node->{$p}};
771     } elsif (ref $node->{$p} eq 'HASH') {
772     push @n, values %{$node->{$p}};
773     }
774     }
775     for my $p (@n,
776     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
777     if (ref $p eq 'ARRAY') {
778     push @node, @$p;
779     } elsif (ref $p eq 'HASH') {
780     push @node, values %$p;
781     }
782     }
783     for my $p (@{$node->{<Q::TreeCore:origin>}},
784     \ @{$node->{<Q::TreeCore:subnode0>}}) {
785     push @node, $node->{$p};
786     }
787     $node->{<Q::TreeCore:treeID>} = $treeID;
788 wakaba 1.1 }
789    
790     @IntMethod:
791     @@Name: isSameNode
792     @@Description:
793     @@@lang:en
794     @@@@:
795     Returns whether a node is the same as this node or not.
796     \
797     {NOTE:: The sameness is different from the equality;
798     two nodes are same iff they are same hash reference.
799     \
800     }
801     @@Operator:
802     @@@ContentType:
803     lang:Perl
804     @@@@: eq
805     @@Param:
806     @@@Name: node
807 wakaba 1.10 @@@Type: NodeStem
808 wakaba 1.1 @@@Description:
809     @@@@lang:en
810     @@@@@:
811     A node to compare with.
812     @@Return:
813     @@@Type:
814 wakaba 1.7 DISPerl:Boolean::ManakaiDOM:all
815 wakaba 1.1 @@@Description:
816     @@@@lang:en
817     @@@@@: Whether the two nodes are same or not.
818     @@@PerlDef:
819 wakaba 1.10 @@@@ForCheck: ForFull
820     @@@@@:
821 wakaba 1.1 if (ref $node and
822     UNIVERSAL::isa ($node,
823     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>) and
824     $node->{<Q::TreeCore:nodeID>} eq $self->{<Q::TreeCore:nodeID>}) {
825     $r = true;
826     }
827 wakaba 1.10 @@@PerlDef:
828     @@@@ForCheck: ForCompact
829     @@@@@:
830     if (ref $node and
831     UNIVERSAL::isa ($node, <ClassName::NodeStem>) and
832     $node->{<Q::TreeCore:nodeID>} eq $self->{<Q::TreeCore:nodeID>}) {
833     $r = true;
834     }
835 wakaba 1.1 @IntMethod:
836     @@Name: orphanate
837     @@Description:
838     @@@lang:en
839     @@@@:
840     Notifies that this node (and its neibors if any) is no longer
841     part of the main tree. If the new tree containing this node
842     has been referred yet, then the tree is preserved except its
843     tree identifier has changed. Otherwise, i.e. the tree is
844     useless any more, then it is destructed.
845     \
846     {NOTE:: Interaction on deleting a relationship from multiply
847     organized <QUOTE::trees> (such as DOM tree and
848     styled displaying tree) is less studied. This
849     method might be modified or addition of another method(s)
850     might be required when style sheet, XBL, or other
851     technologies has been implemented.
852     \
853     }
854     @@Return:
855     @@@PerlDef:
856 wakaba 1.10 if ($self-><M::NodeStem.isExternallyReferred>) {
857     $self-><M::NodeStem.changeTreeID>
858     (<Code::ManakaiDOM:generateUniqueID>);
859 wakaba 1.1 } else {
860 wakaba 1.10 $self-><M::NodeStem.destroy>;
861 wakaba 1.1 }
862 wakaba 1.10 ##NodeStem
863 wakaba 1.1
864     ## -- Public node object
865    
866     ClassDef:
867 wakaba 1.10 @resourceFor: ForFull
868     @resourceFor: ForCompact
869     @resourceFor:
870     ManakaiDOM:ForIF
871    
872     @QName:
873     @@@: NodeRef
874     @@ForCheck:
875     ManakaiDOM:ForIF
876    
877 wakaba 1.1 @QName:
878 wakaba 1.10 @@@:
879     ManakaiDOM:ManakaiDOMNodeReference
880     @@ForCheck: ForFull
881    
882     @Implement:
883     @@@: NodeRef
884     @@ForCheck: ForFull
885    
886     @QName:
887     @@@: ManakaiNodeRef
888     @@ForCheck: ForCompact
889    
890     @Implement:
891     @@@: NodeRef
892     @@ForCheck: ForCompact
893    
894 wakaba 1.1 @Description:
895     @@lang:en
896     @@@:
897     References to the node object corresponding to it. From
898     applications' view, any node object is hidden and
899     <Class::ManakaiDOM:ManakaiDOMNodeReference> seems as if
900     the node itself.
901     @ImplNote:
902     @@lang:en
903     @@@:
904 wakaba 1.13 {P:: A <Class::ManakaiDOM:ManakaiDOMNodeReference> is a blessed hash
905 wakaba 1.1 reference; currently there is a hash key defined:
906     \
907     - <CODE::TreeCore:node>::: A node object
908     (<Class::ManakaiDOM:ManakaiDOMNodeObject>) to which
909     this is referring.
910 wakaba 1.13
911     - <CODE::TreeCore:isWeak>::: Whether the reference is <QUOTE::weak>
912     or not.
913     }
914    
915     @ResourceDef:
916     @@Name: free
917     @@rdf:type: DISLang|Method
918     @@enDesc:
919     Frees the grove referenced by this object. Once
920     this operation is done, results of operations to objects belonging
921     to the grove are unknown.
922     @@ForCheck: ForCompact
923     @@Return:
924     @@@PerlDef:
925     $self->{<Q::TreeCore:node>}-><M::NodeStem.destroy>;
926 wakaba 1.1
927     @IntMethod:
928     @@Name: destroy
929     @@Description:
930     @@@lang:en
931     @@@@: Destroy this reference object.
932     @@Operator:
933     @@@ContentType:
934     lang:Perl
935     @@@@: DESTROY
936     @@Return:
937     @@@PerlDef:
938     @@@@@:
939     my $node = $self->{<Q::TreeCore:node>};
940     if ($node) {
941     CORE::delete $self->{<Q::TreeCore:node>};
942 wakaba 1.6 unless ($self->{<Q::TreeCore:isWeak>}) {
943     $node->{<Q::TreeCore:rc>}--;
944 wakaba 1.10 unless ($node-><M::NodeStem.isExternallyReferred>) {
945     $node-><M::NodeStem.destroy>;
946 wakaba 1.6 }
947 wakaba 1.1 }
948     } else {
949     warn ref ($self) . q{->DESTROY: there is no associated }.
950     q{node object - you have a global variable or }.
951     qq{potential memory-leak detected\n};
952     }
953     @@@@ImplNote:
954     @@@@@lang:en
955     @@@@@@:
956     {P::Warning during the global destruction might mean:
957     \
958     - there be a loop in the manakai internal implementation -
959     it should be a bug.
960     \
961     - there be a loop created by application, e.g.
962     event handler containing a reference to any node
963     belonging to the same tree.
964     \
965     - there be a global variable that contains a node reference
966     and it is not altered or <Perl::undef>ed until the global
967     destruction.
968     \
969     - or other unknown bad situation.
970     \
971     }
972     @@ImplNote:
973     @@@lang:en
974     @@@@:
975     Don't override this method unintentionally - for example,
976     inheritting <PerlModule::Tie::Array> would hide this method
977     from that class, since that module defines its own
978     destructor.
979 wakaba 1.10 ##NodeRef
980 wakaba 1.6
981     PropDef:
982     @QName: isWeak
983     @enDesc:
984     Whether a reference is weak or not.
985     @rdfs:range:
986     ManakaiDOM:ManakaiDONNodeReference
987     @Type:
988     DOMMain:boolean::ManakaiDOM:all
989    
990     ElementTypeBinding:
991     @Name:PropDef
992     @ElementType:
993     dis:ResourceDef
994     @ShadowContent:
995     @@rdf:type:
996     rdf:Property
997    
998     ElementTypeBinding:
999     @Name:enDesc
1000     @ElementType:
1001     dis:Description
1002     @ShadowContent:
1003     @@lang:en
1004 wakaba 1.1
1005     ## -- Frequently used code fragments
1006    
1007     ResourceDef:
1008     @QName:
1009     ManakaiDOM:generateUniqueID
1010     @rdf:type:
1011     dis2pm:InlineCode
1012     @Description:
1013     @@lang:en
1014     @@@:
1015     Generates a global-unique opaque string.
1016     \
1017     {NOTE:: A URI reference is generated by this code.
1018     \
1019     }
1020     @AliasFor:
1021     @@@:
1022     ::ManakaiDOM:all
1023     @@For:
1024     !=ManakaiDOM:all
1025     @PerlDef:
1026     (
1027     sprintf 'mid:%d.%d.%s.dom.manakai@suika.fam.cx#',
1028     time, $$,
1029     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1030     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1031     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1032     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1033     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62]
1034     )
1035     ##ManakaiDOM:generateUniqueID
1036    
1037     ## -- lang:dis vocabulary
1038    
1039     TreeElementType:
1040     @QName:
1041     dis:GetProp
1042     @dataType:
1043     dis:TypeQName
1044     @rdfs:range:
1045     rdf:Property
1046     @Description:
1047     @@lang:en
1048     @@@:
1049     Gets the non-nodal value of a <Class::ManakaiDOM:ManakaiDOMNodeReference>
1050     property (actualy <Class::ManakaiDOM:ManakaiDOMNodeObject> property).
1051    
1052     TreeElementType:
1053     @QName:
1054     dis:SetProp
1055     @dataType:
1056     dis:TypeQName
1057     @rdfs:range:
1058     rdf:Property
1059     @Description:
1060     @@lang:en
1061     @@@:
1062     Sets the non-nodal value of a <Class::ManakaiDOM:ManakaiDOMNodeReference>
1063     property (actualy <Class::ManakaiDOM:ManakaiDOMNodeObject> property).
1064    
1065     ## -- Syntax sugar
1066    
1067     ElementTypeBinding:
1068     @Name: TreeElementType
1069     @ElementType:
1070     dis:ResourceDef
1071     @ShadowContent:
1072     @@rdf:type:
1073     DISLang:TreeElementType
1074     @@AliasFor:
1075     @@@@:
1076     ::ManakaiDOM:all
1077     @@@For:
1078     !=ManakaiDOM:all
1079    
1080     ElementTypeBinding:
1081     @Name: ClassDef
1082     @ElementType:
1083     dis:ResourceDef
1084     @ShadowContent:
1085     @@rdf:type:
1086     @@@@:
1087 wakaba 1.10 dis:MultipleResource
1088     @@@ForCheck:
1089     !ForFull !ForCompact !ManakaiDOM:ForIF
1090     @@rdf:type:
1091     @@@@:
1092     ManakaiDOM:IF
1093     @@@ForCheck:
1094     ManakaiDOM:ForIF
1095     @@rdf:type:
1096     @@@@:
1097     ManakaiDOM:Class
1098     @@@ForCheck: ForFull
1099     @@rdf:type:
1100     @@@@:
1101     ManakaiDOM:Class
1102     @@@ForCheck: ForCompact
1103 wakaba 1.2 @@ForCheck:
1104     ManakaiDOM:Perl
1105 wakaba 1.10
1106     ForDef:
1107     @QName:
1108     mn:ForFull
1109     @ISA:
1110     ManakaiDOM:ForClass
1111    
1112     ForDef:
1113     @QName:
1114     mn:ForCompact
1115     @ISA:
1116     ManakaiDOM:ForClass
1117 wakaba 1.1
1118     ElementTypeBinding:
1119     @Name: IntMethod
1120     @ElementType:
1121     dis:ResourceDef
1122     @ShadowContent:
1123     @@rdf:type:
1124     DISLang:Method
1125     @@ManakaiDOM:isForInternal:1
1126    
1127     ElementTypeBinding:
1128     @Name: Return
1129     @ElementType:
1130     dis:ResourceDef
1131     @ShadowContent:
1132     @@rdf:type:
1133     DISLang:MethodReturn
1134    
1135     ElementTypeBinding:
1136     @Name: Param
1137     @ElementType:
1138     dis:ResourceDef
1139     @ShadowContent:
1140     @@rdf:type:
1141     DISLang:MethodParameter
1142    
1143     ElementTypeBinding:
1144     @Name: PerlDef
1145     @ElementType:
1146     dis:Def
1147     @ShadowContent:
1148     @@ContentType:
1149     lang:Perl
1150    
1151     ElementTypeBinding:
1152     @Name: InCase
1153     @ElementType:
1154     dis:ResourceDef
1155     @ShadowContent:
1156     @@rdf:type:
1157     ManakaiDOM:InCase

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24