/[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.27 - (hide annotations) (download)
Sun Oct 9 13:57:18 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.26: +118 -2 lines
++ manakai/lib/Message/Markup/ChangeLog	9 Oct 2005 13:49:25 -0000
2005-10-09  Wakaba  <wakaba@suika.fam.cx>

	* SuikaWikiConfig21.dis (swcfg21:ownerDocument): Changed
	from a "mn:irefnode0" property to a "mn:xrefnode0" property.

++ manakai/lib/Message/Util/ChangeLog	9 Oct 2005 13:53:53 -0000
2005-10-09  Wakaba  <wakaba@suika.fam.cx>

	* ManakaiNode.dis: New "mn:xrefnode0" property type has
	been introduced and methods are fixed to support it.
	(mn:setXRefNode, mn:unsetXRefNode): New codes.

	* DIS.dis (loadResource): Skips a root resource definition
	if it is an alias and it has "dis:Name" attribute and
	referenced canonical definition is already read.  (Note
	that similar case that the resource definition has "dis:QName"
	attribute is already fixed in the same way.)

++ manakai/lib/Message/Util/DIS/ChangeLog	9 Oct 2005 13:56:34 -0000
2005-10-09  Wakaba  <wakaba@suika.fam.cx>

	* Perl.dis (plGeneratePerlModule): Generates information
	on new "mn:xrefnode0" property type.  Restored to generate
	error definition method code for classes, not only
	interfaces, if there are error codes.

++ manakai/lib/Message/DOM/ChangeLog	9 Oct 2005 13:48:37 -0000
2005-10-09  Wakaba  <wakaba@suika.fam.cx>

	* DOMHTML.dis, DOMWebForms.dis: Typos in element type prefix fixed.

	* DOMFeature.dis (DOMCore:implementation): Short name added.

	* DOMCore.dis (CLONE_NODE_TYPE_NOT_SUPPORTED_ERR): New error subcode.
	(DOMCore:node): New error parameter.
	(DOMCore:ownerDocument): Changed from "mn:irefnode0"
	to "mn:xrefnode0".  For this reason, all assignments
	to this property have been rewritten to references
	to code "mn:setXRefNode".
	(cloneNode): Implemented.
	(setAttributeNode): A missing "importTree" method call added.
	(setAttributeNodeNS): Perl code removed and changed
	to a reference to "setAttributeNode" method code.

	* DOMXML.dis (DOMCore:ownerDocument): Changed from "mn:irefnode0"
	property to "mn:xrefnode0" property.

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 wakaba 1.18 @DISCore:author: DISCore|Wakaba
18 wakaba 1.1 @License:
19     license:Perl+MPL
20     @Date:
21     @@@:
22 wakaba 1.27 $Date: 2005/09/30 13:06:18 $
23 wakaba 1.1 @@ContentType:
24     dis:Date.RCS
25    
26     @Require:
27     @@Module:
28 wakaba 1.4 @@@QName:
29     DISlib:DISPerl
30 wakaba 1.1 @@@WithFor:
31     ManakaiDOM:all
32 wakaba 1.2 @@Module:
33 wakaba 1.16 @@@QName: Util|ManakaiNode
34 wakaba 1.2 @@@WithFor:
35     ManakaiDOM:Perl
36    
37     @DefaultFor:
38     ManakaiDOM:Perl
39 wakaba 1.1
40     Namespace:
41 wakaba 1.13 @DIS:
42     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
43 wakaba 1.1 @dis:
44     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
45     @dis2pm:
46     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
47 wakaba 1.4 @DISlib:
48     http://suika.fam.cx/~wakaba/archive/2004/dis/
49 wakaba 1.13 @doc:
50     http://suika.fam.cx/~wakaba/archive/2005/7/tutorial#
51 wakaba 1.26 @kwd:
52     http://suika.fam.cx/~wakaba/archive/2005/rfc2119/
53 wakaba 1.1 @lang:
54     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
55     @license:
56     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
57     @ManakaiDOM:
58     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
59 wakaba 1.10 @mn:
60     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
61 wakaba 1.1 @Perl:
62     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
63     @rdf:
64     http://www.w3.org/1999/02/22-rdf-syntax-ns#
65     @rdfs:
66     http://www.w3.org/2000/01/rdf-schema#
67     @TreeCore:\
68     @Util:
69     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
70    
71     ResourceDef:
72     @QName:
73     Util:
74     @rdf:type:
75     dis:ModuleGroup
76     @FullName:
77     @@lang:en
78     @@@:
79     The manakai support modules
80 wakaba 1.17 @DISPerl:packageName:
81 wakaba 1.14 Message::Util::
82 wakaba 1.17 @DISPerl:interfacePackageName:
83     Message::Util::IF::
84 wakaba 1.13
85 wakaba 1.1 ## -- Internal node object
86    
87     ClassDef:
88 wakaba 1.10 @resourceFor: ForFull
89     @resourceFor: ForCompact
90     @resourceFor:
91     ManakaiDOM:ForIF
92    
93     @QName:
94     @@@: NodeStem
95     @@ForCheck:
96     ManakaiDOM:ForIF
97    
98 wakaba 1.1 @QName:
99 wakaba 1.10 @@@:
100     ManakaiDOM:ManakaiDOMNodeObject
101     @@ForCheck: ForFull
102    
103     @QName:
104     @@@: ManakaiNodeStem
105     @@ForCheck: ForCompact
106    
107     @Implement:
108     @@@: NodeStem
109     @@ForCheck: ForFull
110    
111     @Implement:
112     @@@: NodeStem
113     @@ForCheck: ForCompact
114    
115 wakaba 1.1 @Description:
116     @@lang:en
117     @@@:
118     Internal (actual) node objects that is accessed via
119     <Class::ManakaiDOM:ManakaiDOMNodeReference> objects referring it.
120     @ImplNote:
121     @@lang:en
122     @@@:
123     No public interface should be defined for any class inheriting
124     this class - applications should access to nodes only via
125     <Class::ManakaiDOM:ManakaiDOMNodeReference> objects.
126     @ImplNote:
127 wakaba 1.13 @@ForCheck: ManakaiDOM|ForClass
128 wakaba 1.1 @@lang:en
129     @@@:
130 wakaba 1.13 A <Class::> object is a blessed hash
131 wakaba 1.1 reference. Each hash key and value pair is called as a
132     <DFN::property>. Currently, several core properties
133 wakaba 1.13 are defined as listed below. Applications of this class,
134     such as <Class::DOMCore:ManakaiDOMNode::ManakaiDOM:all>,
135     defines additional properties for their own purpose and scope.
136 wakaba 1.1 \
137 wakaba 1.13 {doc:fig:: <doc:caption::Core node properties>
138    
139     {doc:figBody::
140 wakaba 1.1 \
141     - <CODE::TreeCore:origin>::: An array reference, containing
142     hash key names of <DFN::origin>
143     properties for this node.
144     \
145 wakaba 1.3 - <CODE::TreeCore:subnode0>::: An array reference, containing
146     hash key names of <DFN::subnode>
147     properties for this node.
148     \
149 wakaba 1.1 - <CODE::TreeCore:subnode>::: An array reference, containing
150 wakaba 1.3 hash key names of <DFN::subnode> list
151 wakaba 1.1 properties for this node.
152     \
153     - <CODE::TreeCore:subnode2>::: An array reference, containing
154 wakaba 1.3 hash key names of <DFN::subnode> (two steps) list
155 wakaba 1.1 properties for this node.
156     \
157     - <CODE::TreeCore:irefnode>::: An array reference, containing
158     hash key names of <DFN::irefnode>
159     properties for this node.
160     \
161     - <CODE::TreeCore:anydata>::: An array reference, containing
162 wakaba 1.3 hash key names of <DFN::anydata> list
163     properties for this node.
164 wakaba 1.1 \
165     - <CODE::TreeCore:anydata2>::: An array reference, containing
166 wakaba 1.3 hash key names of <DFN::anydata> (two steps) list properties
167 wakaba 1.1 for this node.
168 wakaba 1.13 }
169 wakaba 1.1 }
170    
171     @IntMethod:
172     @@Name: new
173     @@Description:
174     @@@lang:en
175     @@@@:
176     Constructs a new instance of
177     <Class::ManakaiDOM:ManakaiDOMNodeObject> and returns it.
178 wakaba 1.22 @@Param:
179     @@@ForCheck: ForCompact
180     @@@Name: className
181     @@@Type: DISLang|String||ManakaiDOM|all
182     @@@enDesc:
183     The name of a class which is typically used as reference
184     to the node. The class <kwd:SHOULD> implement the
185     <IF::NodeRef> interface. The <QUOTE::dis> definition
186     for the class <kwd:SHOULD> play the role of <Q::mn|NodeRefRole
187     ||ManakaiDOM|all>.
188 wakaba 1.1 @@Return:
189 wakaba 1.10 @@@Type: NodeStem
190 wakaba 1.1 @@@Description:
191     @@@@lang:en
192     @@@@@:
193     The newly created <Class::ManakaiDOM:ManakaiDOMNodeObject> instance.
194 wakaba 1.7 @@@PerlDef:
195 wakaba 1.20 @@@@ForCheck: ForFull
196     @@@@@:
197 wakaba 1.1 $r = bless {
198     <Q::TreeCore:origin> => [],
199 wakaba 1.3 <Q::TreeCore:subnode0> => [],
200 wakaba 1.1 <Q::TreeCore:subnode> => [],
201     <Q::TreeCore:subnode2> => [],
202     <Q::TreeCore:irefnode> => [],
203     <Q::TreeCore:anydata> => [],
204     <Q::TreeCore:anydata2> => [],
205 wakaba 1.19 <H::mn:rc> => 0,
206     <H::mn:treeID> => <Code::ManakaiDOM:generateUniqueID>,
207     <H::mn:nodeID> => <Code::ManakaiDOM:generateUniqueID>,
208 wakaba 1.1 }, ref $self || $self;
209 wakaba 1.20 @@@PerlDef:
210     @@@@ForCheck: ForCompact
211     @@@@@:
212 wakaba 1.25 my $grc = 0;
213 wakaba 1.20 $r = bless {
214 wakaba 1.25 <H::mn:type> => $className,
215     <H::mn:groveReferenceCounter> => \$grc,
216     <H::mn:rc> => 0,
217 wakaba 1.20 <H::mn:treeID> => \ (<Code::ManakaiDOM:generateUniqueID>),
218     <H::mn:nodeID> => <Code::ManakaiDOM:generateUniqueID>,
219     }, ref $self || $self;
220 wakaba 1.10
221 wakaba 1.1 @IntMethod:
222     @@Name: newReference
223     @@Description:
224     @@@lang:en
225     @@@@:
226     Creates a new reference to this node and returns it.
227 wakaba 1.10 @@ForCheck: ForFull
228 wakaba 1.1 @@Param:
229     @@@Name: class
230     @@@Type:
231 wakaba 1.7 Perl:package-name::ManakaiDOM:all
232 wakaba 1.1 @@@Description:
233     @@@@lang:en
234     @@@@@:
235     A Perl class package name with which the newly created
236     reference is blessed. The <P::class> class must be a
237     subclass of <Class::ManakaiDOM:ManakaiDOM:ManakaiDOMNodeReference>.
238     @@Return:
239     @@@Type:
240     ManakaiDOM:ManakaiDOMNodeReference
241     @@@Description:
242     @@@@lang:en
243     @@@@@:
244     The newly created node reference.
245     @@@PerlDef:
246     $r = bless {
247 wakaba 1.19 <H::mn:node> => $self,
248 wakaba 1.7 }, ref $class ? ref $class : defined $class ? $class :
249 wakaba 1.1 <ClassName::ManakaiDOM:ManakaiDOMNodeReference>;
250 wakaba 1.19 $self->{<H::mn:rc>}++;
251 wakaba 1.6
252     @ResourceDef:
253     @@QName: getNewReference
254     @@rdf:type:
255     dis2pm:BlockCode
256 wakaba 1.20 @@ForCheck: ForCompact
257 wakaba 1.6 @@Description:
258     @@@lang:en
259     @@@@:
260     Creates a new node reference object.
261     @@ResourceDef:
262     @@@rdf:type:
263     DISPerl:CodeParameter
264     @@@Name: $object
265 wakaba 1.10 @@@Type: NodeStem
266 wakaba 1.6 @@@In:1
267     @@@enDesc:
268     A node object for which a reference is created.
269     @@@DISPerl:paramStyle: var
270     @@ResourceDef:
271     @@@rdf:type:
272     DISPerl:CodeParameter
273     @@@Name: $ref
274 wakaba 1.10 @@@Type: NodeRef
275 wakaba 1.6 @@@Out:1
276     @@@enDesc:
277     A node reference for <P::$object>. It may or may not
278     be same as <P::$object>.
279     @@@DISPerl:paramStyle: var
280     @@ResourceDef:
281     @@@rdf:type:
282     DISPerl:CodeParameter
283     @@@Name: $class
284     @@@Type:
285     Perl:package-name::ManakaiDOM:all
286     @@@enDesc:
287     A package name with which <P::$ref> is blessed.
288     @@@In:1
289     @@@DISPerl:paramStyle: any
290     @@PerlDef:
291 wakaba 1.19 $object->{<H::mn:rc>}++;
292 wakaba 1.25 ${$object->{<H::mn:groveReferenceCounter>}}++;
293 wakaba 1.6 $ref = bless {
294 wakaba 1.19 <H::mn:node> => $object,
295 wakaba 1.6 }, $class;
296    
297     @ResourceDef:
298     @@QName: getWeakReference
299     @@rdf:type:
300     dis2pm:BlockCode
301 wakaba 1.20 @@ForCheck: ForCompact
302 wakaba 1.6 @@Description:
303     @@@lang:en
304     @@@@:
305     Creates a new weak node reference object.
306     \
307     The weak node reference is actually a node reference
308     except that this code fragment does not increment
309     the reference count of the object. When all non-weak
310     references to the object are destructed, then
311     the object is destructed and any operation via
312     weak references will lead unexpected result.
313     \
314     {NOTE:: It is intended that internal code creates a weak reference
315     so that it gets access to public interface.
316     \
317     }
318     @@ResourceDef:
319     @@@rdf:type:
320     DISPerl:CodeParameter
321     @@@Name: $object
322 wakaba 1.10 @@@Type: NodeStem
323 wakaba 1.6 @@@In:1
324     @@@enDesc:
325     A node object for which a reference is created.
326     @@@DISPerl:paramStyle: var
327     @@ResourceDef:
328     @@@rdf:type:
329     DISPerl:CodeParameter
330     @@@Name: $ref
331 wakaba 1.10 @@@Type: NodeRef
332 wakaba 1.6 @@@Out:1
333     @@@enDesc:
334     A node reference for <P::$object>. It may or may not
335     be same as <P::$object>.
336     @@@DISPerl:paramStyle: var
337     @@ResourceDef:
338     @@@rdf:type:
339     DISPerl:CodeParameter
340     @@@Name: $class
341     @@@Type:
342     Perl:package-name::ManakaiDOM:all
343     @@@enDesc:
344     A package name with which <P::$ref> is blessed.
345     @@@In:1
346     @@@DISPerl:paramStyle: any
347     @@PerlDef:
348     $ref = bless {
349 wakaba 1.19 <H::mn:node> => $object,
350     <H::mn:isWeak> => true,
351 wakaba 1.8 }, $class;
352    
353     @ResourceDef:
354     @@QName: getWeakRef
355     @@rdf:type:
356     dis2pm:InlineCode
357 wakaba 1.10 @@ForCheck: ForFull
358 wakaba 1.8 @@Description:
359     @@@lang:en
360     @@@@:
361     Creates a new weak node reference object.
362     \
363     The weak node reference is actually a node reference
364     except that this code fragment does not increment
365     the reference count of the object. When all non-weak
366     references to the object are destructed, then
367     the object is destructed and any operation via
368     weak references will lead unexpected result.
369     \
370     {NOTE:: It is intended that internal code creates a weak reference
371     so that it gets access to public interface.
372     \
373     }
374     @@ResourceDef:
375     @@@rdf:type:
376     DISPerl:CodeParameter
377     @@@Name: $object
378 wakaba 1.10 @@@Type: NodeStem
379 wakaba 1.8 @@@In:1
380     @@@enDesc:
381     A node object for which a reference is created.
382     @@@DISPerl:paramStyle: var
383     @@ResourceDef:
384     @@@rdf:type:
385     DISPerl:CodeParameter
386     @@@Name: $class
387     @@@Type:
388     Perl:package-name::ManakaiDOM:all
389     @@@enDesc:
390     A package name with which <P::$ref> is blessed.
391     @@@In:1
392     @@@DISPerl:paramStyle: any
393     @@PerlDef:
394 wakaba 1.9 (bless {
395 wakaba 1.19 <H::mn:node> => $object,
396     <H::mn:isWeak> => true,
397 wakaba 1.9 }, $class)
398 wakaba 1.6
399 wakaba 1.1 @IntMethod:
400     @@Name: isExternallyReferred
401     @@Description:
402     @@@lang:en
403     @@@@:
404     Checks whether the tree containing this node has been referred
405     from the outside of the tree or not.
406     @@Return:
407     @@@Type:
408 wakaba 1.7 DISPerl:Boolean::ManakaiDOM:all
409 wakaba 1.1 @@@InCase:
410 wakaba 1.15 @@@@Value:
411     @@@@@@:1
412     @@@@@ContentType: DISCore|Boolean
413 wakaba 1.1 @@@@Description:
414     @@@@@lang:en
415     @@@@@@:
416     There is one or more nodes in the tree that has been
417     referred via <Class::ManakaiDOM:ManakaiDOMNodeReference> objects.
418     @@@InCase:
419 wakaba 1.15 @@@@Value:
420     @@@@@@:0
421     @@@@@ContentType: DISCore|Boolean
422 wakaba 1.1 @@@@Description:
423     @@@@@lang:en
424     @@@@@@: No external reference found.
425     @@@PerlDef:
426 wakaba 1.10 @@@@ForCheck: ForFull
427     @@@@@:
428 wakaba 1.19 if ($self->{<H::mn:rc>}) {
429 wakaba 1.1 $r = true;
430     } else {
431     my @node = ($self);
432     my %checked;
433 wakaba 1.25 NODES: while (@node) {
434     my $node = shift @node;
435     next NODES unless UNIVERSAL::isa ($node,
436     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
437 wakaba 1.19 if ($node->{<H::mn:rc>}) {
438 wakaba 1.1 $r = true;
439     last NODES;
440 wakaba 1.19 } elsif ($checked{$node->{<H::mn:nodeID>}}) {
441 wakaba 1.1 next NODES;
442     }
443     my @n;
444 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
445     if (ref $node->{$p} eq 'ARRAY') {
446     push @n, @{$node->{$p}};
447     } elsif (ref $node->{$p} eq 'HASH') {
448     push @n, values %{$node->{$p}};
449 wakaba 1.1 }
450     }
451 wakaba 1.3 for my $p (@n,
452     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
453     if (ref $p eq 'ARRAY') {
454     push @node, @$p;
455     } elsif (ref $p eq 'HASH') {
456     push @node, values %$p;
457 wakaba 1.1 }
458     }
459 wakaba 1.6 for my $p (@{$node->{<Q::TreeCore:origin>}}) {
460     unshift @node, $node->{$p} if $node->{$p};
461     ## NOTE: Puts the top of the list,
462     ## since upper-level nodes are expected to be referred
463     ## more than lower-levels.
464     }
465     for my $p (@{$node->{<Q::TreeCore:subnode0>}}) {
466 wakaba 1.3 push @node, $node->{$p} if $node->{$p};
467 wakaba 1.1 }
468 wakaba 1.19 $checked{$node->{<H::mn:nodeID>}} = true;
469 wakaba 1.1 }
470     }
471 wakaba 1.10 @@@PerlDef:
472     @@@@ForCheck: ForCompact
473     @@@@@:
474 wakaba 1.19 if ($self->{<H::mn:rc>}) {
475 wakaba 1.10 $r = true;
476     } else {
477     my @node = ($self);
478     my %checked;
479 wakaba 1.25 NODES: while (@node) {
480     my $node = shift @node;
481     next NODES unless ref $node;
482 wakaba 1.19 if ($node->{<H::mn:rc>}) {
483 wakaba 1.10 $r = true;
484     last NODES;
485 wakaba 1.19 } elsif ($checked{$node->{<H::mn:nodeID>}}) {
486 wakaba 1.10 next NODES;
487     }
488     my @n;
489 wakaba 1.23 my $nt = $Message::Util::ManakaiNode::ManakaiNodeRef::Prop{
490     $node->{<H::mn:type>}
491     };
492 wakaba 1.25 for my $p (@{$nt->{<H::mn:subnode2>}}) {
493 wakaba 1.10 if (ref $node->{$p} eq 'ARRAY') {
494     push @n, @{$node->{$p}};
495     } elsif (ref $node->{$p} eq 'HASH') {
496     push @n, values %{$node->{$p}};
497     }
498     }
499     for my $p (@n,
500 wakaba 1.25 map {$node->{$_}} @{$nt->{<H::mn:subnode1>}}) {
501 wakaba 1.10 if (ref $p eq 'ARRAY') {
502     push @node, @$p;
503     } elsif (ref $p eq 'HASH') {
504     push @node, values %$p;
505     }
506     }
507 wakaba 1.25 for my $p (@{$nt->{<H::mn:origin0>}}) {
508 wakaba 1.10 unshift @node, $node->{$p} if $node->{$p};
509     ## NOTE: Puts the top of the list,
510     ## since upper-level nodes are expected to be referred
511     ## more than lower-levels.
512     }
513 wakaba 1.23 for my $p (@{$nt->{<H::mn:subnode0>}}) {
514 wakaba 1.10 push @node, $node->{$p} if $node->{$p};
515     }
516 wakaba 1.25 $checked{$node->{<H::mn:nodeID>}} = true;
517 wakaba 1.10 }
518     }
519 wakaba 1.1
520 wakaba 1.25 @ResourceDef:
521     @@QName: mn|isGroveReferenced
522     @@rdf:type: DISPerl|InlineCode
523     @@PerlDef:
524     (${$node->{<H::mn:groveReferenceCounter>}} > 0)
525     @@ForCheck: ForCompact
526    
527 wakaba 1.1 @IntMethod:
528     @@Name: destroy
529     @@Description:
530     @@@lang:en
531     @@@@:
532     Destructs the tree containing this node.
533     @@Return:
534     @@@PerlDef:
535 wakaba 1.10 @@@@ForCheck: ForFull
536     @@@@@:
537 wakaba 1.1 my @node = ($self);
538 wakaba 1.25 NODES: while (@node) {
539     my $node = shift @node;
540 wakaba 1.1 my @n;
541 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
542     if (ref $node->{$p} eq 'ARRAY') {
543     push @n, @{$node->{$p}};
544     } elsif (ref $node->{$p} eq 'HASH') {
545     push @n, values %{$node->{$p}};
546 wakaba 1.1 }
547     }
548 wakaba 1.3 for my $p (@n,
549     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
550     if (ref $p eq 'ARRAY') {
551 wakaba 1.10 push @node, grep {UNIVERSAL::isa ($_,
552     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
553 wakaba 1.19 and defined $_->{<H::mn:nodeID>}} @$p;
554 wakaba 1.3 } elsif (ref $p eq 'HASH') {
555 wakaba 1.10 push @node, grep {UNIVERSAL::isa ($_,
556     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
557 wakaba 1.19 and defined $_->{<H::mn:nodeID>}}
558 wakaba 1.3 values %$p;
559 wakaba 1.1 }
560     }
561 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
562     \ @{$node->{<Q::TreeCore:subnode0>}}) {
563     push @node, $node->{$p}
564     if defined $node->{$p} and
565 wakaba 1.19 defined $node->{$p}->{<H::mn:nodeID>};
566 wakaba 1.1 }
567 wakaba 1.27
568 wakaba 1.1 %$node = ();
569 wakaba 1.27 } # @node
570 wakaba 1.10 @@@PerlDef:
571     @@@@ForCheck: ForCompact
572     @@@@@:
573     my @node = ($self);
574 wakaba 1.27 my $tid = $self->{<H::mn:treeID>};
575     my %xrnode;
576 wakaba 1.25 NODES: while (@node) {
577     my $node = shift @node;
578     next NODES unless ref $node and defined $node->{<H::mn:nodeID>};
579 wakaba 1.10 my @n;
580 wakaba 1.23 my $nt = $Message::Util::ManakaiNode::ManakaiNodeRef::Prop{
581     $node->{<H::mn:type>}
582     };
583 wakaba 1.25 for my $p (@{$nt->{<H::mn:subnode2>}||[]}) {
584 wakaba 1.10 if (ref $node->{$p} eq 'ARRAY') {
585     push @n, @{$node->{$p}};
586     } elsif (ref $node->{$p} eq 'HASH') {
587     push @n, values %{$node->{$p}};
588     }
589     }
590     for my $p (@n,
591 wakaba 1.25 map {$node->{$_}} @{$nt->{<H::mn:subnode1>}||[]}) {
592 wakaba 1.10 if (ref $p eq 'ARRAY') {
593     push @node, @$p;
594     } elsif (ref $p eq 'HASH') {
595     push @node, values %$p;
596     }
597     }
598 wakaba 1.25 for my $p (@{$nt->{<H::mn:origin0>}||[]},
599     \ @{$nt->{<H::mn:subnode0>}||[]}) {
600 wakaba 1.10 push @node, $node->{$p};
601     }
602 wakaba 1.27
603     for my $p (@{$nt->{<H::mn:xrefnode0>}||[]}) {
604     if (defined $node->{$p} and
605     ${$node->{$p}->{<H::mn:treeID>}||$tid} ne $$tid) {
606     $node->{$p}->{<H::mn:rc>}--;
607     ${$node->{$p}->{<H::mn:groveReferenceCounter>}}--;
608     $xrnode{${$node->{$p}->{<H::mn:treeID>}}} = $node->{$p};
609     }
610     }
611    
612 wakaba 1.10 %$node = ();
613 wakaba 1.27 } # @node
614    
615     CORE::delete $xrnode{$$tid};
616     for my $node (values %xrnode) {
617     unless (<Code::isGroveReferenced:: $node = $node>) {
618     $node-><M::NodeStem.destroy>;
619     }
620 wakaba 1.10 }
621 wakaba 1.1 @@ImplNote:
622     @@@lang:en
623     @@@@:
624     This method is different from Perl <Perl::DESTROY> special
625     purpose method.
626     \
627     An <QUOTE::uninitialized> warning in this method might mean
628     some method puts an <Perl::undef> into a list of nodes.
629    
630     @IntMethod:
631     @@Name: importTree
632     @@Description:
633     @@@lang:en
634     @@@@:
635     Changes the tree identifier of the nodes belong to another tree
636     to be same as this node's tree identifier.
637     @@Param:
638     @@@Name: node
639     @@@Type:
640     ManakaiDOM:ManakaiDOMNodeObject
641     @@@Description:
642     @@@@lang:en
643     @@@@@:
644     Any node from the tree to change its identifier.
645     @@Return:
646     @@@PerlDef:
647 wakaba 1.10 @@@@ForCheck: ForFull
648     @@@@@:
649 wakaba 1.19 unless ($node->{<H::mn:treeID>} eq
650     $self->{<H::mn:treeID>}) {
651 wakaba 1.1 my @node = ($node);
652 wakaba 1.25 NODES: while (@node) {
653     my $node = shift @node;
654     next NODES unless UNIVERSAL::isa ($node,
655     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
656 wakaba 1.1 my @n;
657 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
658     if (ref $node->{$p} eq 'ARRAY') {
659     push @n, @{$node->{$p}};
660     } elsif (ref $node->{$p} eq 'HASH') {
661     push @n, values %{$node->{$p}};
662 wakaba 1.1 }
663     }
664 wakaba 1.3 for my $p (@n,
665     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
666     if (ref $p eq 'ARRAY') {
667 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
668     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
669 wakaba 1.19 and $_->{<H::mn:treeID>} ne
670     $self->{<H::mn:treeID>}} @$p;
671 wakaba 1.3 } elsif (ref $p eq 'HASH') {
672 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
673     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
674 wakaba 1.19 and $_->{<H::mn:treeID>} ne
675     $self->{<H::mn:treeID>}}
676 wakaba 1.3 values %$p;
677 wakaba 1.1 }
678     }
679 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
680     \ @{$node->{<Q::TreeCore:subnode0>}}) {
681     push @node, $node->{$p}
682     if defined $node->{$p} and
683 wakaba 1.19 $node->{$p}->{<H::mn:treeID>} ne
684     $self->{<H::mn:treeID>};
685 wakaba 1.1 }
686 wakaba 1.19 $node->{<H::mn:treeID>} = $self->{<H::mn:treeID>};
687 wakaba 1.1 }
688     }
689 wakaba 1.10 @@@PerlDef:
690     @@@@ForCheck: ForCompact
691     @@@@@:
692     my @node = ($node);
693 wakaba 1.25 my $newgrc = $self->{<H::mn:groveReferenceCounter>};
694     my $newtid = $self->{<H::mn:treeID>};
695 wakaba 1.27 my $oldtid = $node->{<H::mn:treeID>};
696     my @xrnode;
697 wakaba 1.25 NODES: while (@node) {
698     my $node = shift @node;
699     next NODES unless ref $node;
700     next NODES if ${$node->{<H::mn:treeID>}} eq $$newtid;
701 wakaba 1.10 my @n;
702 wakaba 1.23 my $nt = $Message::Util::ManakaiNode::ManakaiNodeRef::Prop{
703     $node->{<H::mn:type>}
704     };
705 wakaba 1.25 for my $p (@{$nt->{<H::mn:subnode2>}||[]}) {
706 wakaba 1.10 if (ref $node->{$p} eq 'ARRAY') {
707     push @n, @{$node->{$p}};
708     } elsif (ref $node->{$p} eq 'HASH') {
709     push @n, values %{$node->{$p}};
710     }
711     }
712     for my $p (@n,
713 wakaba 1.25 map {$node->{$_}} @{$nt->{<H::mn:subnode1>}||[]}) {
714 wakaba 1.10 if (ref $p eq 'ARRAY') {
715     push @node, @$p;
716     } elsif (ref $p eq 'HASH') {
717     push @node, values %$p;
718     }
719     }
720 wakaba 1.25 for my $p (@{$nt->{<H::mn:origin0>}||[]},
721     \ @{$nt->{<H::mn:subnode0>}||[]}) {
722 wakaba 1.10 push @node, $node->{$p};
723     }
724 wakaba 1.25
725 wakaba 1.27 for (@{$nt->{<H::mn:xrefnode0>}||[]}) {
726     push @xrnode, $node->{$_} if defined $node->{$_};
727     }
728    
729 wakaba 1.25 ${$node->{<H::mn:groveReferenceCounter>}} -= $node->{<H::mn:rc>};
730     $node->{<H::mn:treeID>} = $newtid;
731     $node->{<H::mn:groveReferenceCounter>} = $newgrc;
732     ${$node->{<H::mn:groveReferenceCounter>}} += $node->{<H::mn:rc>};
733 wakaba 1.10 }
734 wakaba 1.1
735 wakaba 1.27 for my $n (@xrnode) {
736     if (${$n->{<H::mn:treeID>}} eq $$oldtid) {
737     $n->{<H::mn:rc>}++;
738     ${$n->{<H::mn:groveReferenceCounter>}}++;
739     } elsif (${$n->{<H::mn:treeID>}} eq $$newtid) {
740     $n->{<H::mn:rc>}--;
741     ${$n->{<H::mn:groveReferenceCounter>}}--;
742     ## Is it necessary to test whether rc is 0 or not
743     ## and if so call "destroy" method? Maybe it need not
744     ## (or should not, rather).
745     }
746     }
747    
748 wakaba 1.1 @IntMethod:
749     @@Name: changeTreeID
750     @@Description:
751     @@@lang:en
752     @@@@:
753     Changes tree identifier of all nodes traversable from this node.
754 wakaba 1.27 @@enDesc:
755     @@@ForCheck: ForCompact
756     @@@@:
757     If a node has <Q::mn:xrefnode0> property value and it
758     is a node in the tree to which the node formally belongs,
759     then reference counters are updated to new status.
760 wakaba 1.1 @@Param:
761     @@@Name: treeID
762     @@@Type:
763 wakaba 1.7 DISPerl:String::ManakaiDOM:all
764 wakaba 1.1 @@@Description:
765     @@@@lang:en
766     @@@@@:
767     The new tree identifier.
768 wakaba 1.20 @@@InCase:
769 wakaba 1.21 @@@@Type: DISPerl|SCALAR||ManakaiDOM|all
770 wakaba 1.20 @@@@enDesc:
771     A reference to the new tree identifier.
772     The tree will reference the identifier as it.
773 wakaba 1.25 @@Param:
774     @@@ForCheck: ForCompact
775     @@@Name: groveRC
776     @@@Type: DISPerl|SCALAR||ManakaiDOM|all
777     @@@enDesc:
778     The new reference counter.
779 wakaba 1.1 @@Return:
780     @@@PerlDef:
781 wakaba 1.10 @@@@ForCheck: ForFull
782     @@@@@:
783 wakaba 1.19 unless ($self->{<H::mn:treeID>} eq $treeID) {
784 wakaba 1.1 my @node = ($self);
785 wakaba 1.25 NODES: while (@node) {
786     my $node = shift @node;
787     next NODES unless UNIVERSAL::isa ($node,
788 wakaba 1.9 <ClassName::ManakaiDOM:ManakaiDOMNodeObject>);
789 wakaba 1.1 my @n;
790 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:subnode2>}}) {
791     if (ref $node->{$p} eq 'ARRAY') {
792     push @n, @{$node->{$p}};
793     } elsif (ref $node->{$p} eq 'HASH') {
794     push @n, values %{$node->{$p}};
795 wakaba 1.1 }
796     }
797 wakaba 1.3 for my $p (@n,
798     map {$node->{$_}} @{$node->{<Q::TreeCore:subnode>}}) {
799     if (ref $p eq 'ARRAY') {
800 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
801     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
802 wakaba 1.5 and
803 wakaba 1.19 $_->{<H::mn:treeID>} ne $treeID} @$p;
804 wakaba 1.3 } elsif (ref $p eq 'HASH') {
805 wakaba 1.9 push @node, grep {UNIVERSAL::isa ($_,
806     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>)
807 wakaba 1.19 and $_->{<H::mn:treeID>} ne $treeID}
808 wakaba 1.3 values %$p;
809 wakaba 1.1 }
810     }
811 wakaba 1.3 for my $p (@{$node->{<Q::TreeCore:origin>}},
812     \ @{$node->{<Q::TreeCore:subnode0>}}) {
813     push @node, $node->{$p}
814     if defined $node->{$p} and
815 wakaba 1.19 $node->{$p}->{<H::mn:treeID>} ne $treeID;
816 wakaba 1.1 }
817 wakaba 1.19 $node->{<H::mn:treeID>} = $treeID;
818 wakaba 1.1 }
819     }
820     @@@PerlDef:
821 wakaba 1.10 @@@@ForCheck: ForCompact
822     @@@@@:
823 wakaba 1.20 my $tid = ref $treeID ? $treeID : \$treeID;
824 wakaba 1.27 my $oldtid = $self->{<H::mn:treeID>};
825     my @xrnode;
826 wakaba 1.10 my @node = ($self);
827 wakaba 1.25 NODES: while (@node) {
828     my $node = shift @node;
829     next NODES unless ref $node;
830     next NODES if ${$node->{<H::mn:treeID>}} eq $$tid;
831 wakaba 1.10 my @n;
832 wakaba 1.23 my $nt = $Message::Util::ManakaiNode::ManakaiNodeRef::Prop{
833     $node->{<H::mn:type>}
834     };
835 wakaba 1.25 for my $p (@{$nt->{<H::mn:subnode2>}||[]}) {
836 wakaba 1.10 if (ref $node->{$p} eq 'ARRAY') {
837     push @n, @{$node->{$p}};
838     } elsif (ref $node->{$p} eq 'HASH') {
839     push @n, values %{$node->{$p}};
840     }
841     }
842     for my $p (@n,
843 wakaba 1.25 map {$node->{$_}} @{$nt->{<H::mn:subnode1>}||[]}) {
844 wakaba 1.10 if (ref $p eq 'ARRAY') {
845     push @node, @$p;
846     } elsif (ref $p eq 'HASH') {
847     push @node, values %$p;
848     }
849     }
850 wakaba 1.25 for my $p (@{$nt->{<H::mn:origin0>}||[]},
851     \ @{$nt->{<H::mn:subnode0>}||[]}) {
852 wakaba 1.10 push @node, $node->{$p};
853     }
854 wakaba 1.25
855 wakaba 1.27 for (@{$nt->{<H::mn:xrefnode0>}||[]}) {
856     push @xrnode, $node->{$_} if defined $node->{$_};
857     }
858    
859 wakaba 1.25 ${$node->{<H::mn:groveReferenceCounter>}} -= $node->{<H::mn:rc>};
860 wakaba 1.20 $node->{<H::mn:treeID>} = $tid;
861 wakaba 1.25 $node->{<H::mn:groveReferenceCounter>} = $groveRC;
862     ${$node->{<H::mn:groveReferenceCounter>}} += $node->{<H::mn:rc>};
863 wakaba 1.1 }
864    
865 wakaba 1.27 for my $n (@xrnode) {
866     if (${$n->{<H::mn:treeID>}} eq $$oldtid) {
867     $n->{<H::mn:rc>}++;
868     ${$n->{<H::mn:groveReferenceCounter>}}++;
869     } elsif (${$n->{<H::mn:treeID>}} eq $$tid) {
870     $n->{<H::mn:rc>}--;
871     ${$n->{<H::mn:groveReferenceCounter>}}--;
872     ## Is it necessary to test whether rc is 0 or not
873     ## and if so call "destroy" method? Maybe it need not
874     ## (or should not, rather).
875     }
876     }
877    
878 wakaba 1.1 @IntMethod:
879     @@Name: isSameNode
880     @@Description:
881     @@@lang:en
882     @@@@:
883     Returns whether a node is the same as this node or not.
884     \
885     {NOTE:: The sameness is different from the equality;
886     two nodes are same iff they are same hash reference.
887     \
888     }
889     @@Operator:
890     @@@ContentType:
891     lang:Perl
892     @@@@: eq
893     @@Param:
894     @@@Name: node
895 wakaba 1.10 @@@Type: NodeStem
896 wakaba 1.1 @@@Description:
897     @@@@lang:en
898     @@@@@:
899     A node to compare with.
900     @@Return:
901     @@@Type:
902 wakaba 1.7 DISPerl:Boolean::ManakaiDOM:all
903 wakaba 1.1 @@@Description:
904     @@@@lang:en
905     @@@@@: Whether the two nodes are same or not.
906     @@@PerlDef:
907 wakaba 1.10 @@@@ForCheck: ForFull
908     @@@@@:
909 wakaba 1.1 if (ref $node and
910     UNIVERSAL::isa ($node,
911     <ClassName::ManakaiDOM:ManakaiDOMNodeObject>) and
912 wakaba 1.19 $node->{<H::mn:nodeID>} eq $self->{<H::mn:nodeID>}) {
913 wakaba 1.1 $r = true;
914     }
915 wakaba 1.10 @@@PerlDef:
916     @@@@ForCheck: ForCompact
917     @@@@@:
918     if (ref $node and
919 wakaba 1.23 UNIVERSAL::isa ($node, <ClassName::ManakaiNodeStem>) and
920 wakaba 1.19 $node->{<H::mn:nodeID>} eq $self->{<H::mn:nodeID>}) {
921 wakaba 1.10 $r = true;
922     }
923 wakaba 1.1 @IntMethod:
924     @@Name: orphanate
925     @@Description:
926     @@@lang:en
927     @@@@:
928     Notifies that this node (and its neibors if any) is no longer
929     part of the main tree. If the new tree containing this node
930     has been referred yet, then the tree is preserved except its
931     tree identifier has changed. Otherwise, i.e. the tree is
932     useless any more, then it is destructed.
933     \
934     {NOTE:: Interaction on deleting a relationship from multiply
935     organized <QUOTE::trees> (such as DOM tree and
936     styled displaying tree) is less studied. This
937     method might be modified or addition of another method(s)
938     might be required when style sheet, XBL, or other
939     technologies has been implemented.
940     \
941     }
942     @@Return:
943     @@@PerlDef:
944 wakaba 1.20 @@@@ForCheck: ForFull
945     @@@@@:
946     if ($self-><M::NodeStem.isExternallyReferred>) {
947     $self-><M::NodeStem.changeTreeID>
948     (<Code::ManakaiDOM:generateUniqueID>);
949     } else {
950     $self-><M::NodeStem.destroy>;
951     }
952     @@@PerlDef:
953     @@@@ForCheck: ForCompact
954     @@@@@:
955     if ($self-><M::NodeStem.isExternallyReferred>) {
956 wakaba 1.25 my $grc = 0;
957 wakaba 1.20 $self-><M::NodeStem.changeTreeID>
958 wakaba 1.25 (\(<Code::ManakaiDOM:generateUniqueID>), \$grc);
959 wakaba 1.20 } else {
960     $self-><M::NodeStem.destroy>;
961     }
962 wakaba 1.27
963     @ResourceDef:
964     @@ForCheck: ForCompact
965     @@QName: mn|setXRefNode
966     @@enDesc:
967     Sets a <Q::mn:xrefnode0> property.
968     @@rdf:type: DISPerl|BlockCode
969     @@PerlDef:
970     $referrer->{$propName} = $referent;
971     if (${$referrer->{<H::mn:treeID>}} ne ${$referent->{<H::mn:treeID>}}) {
972     $referent->{<H::mn:rc>}++;
973     ${$referent->{<H::mn:groveReferenceCounter>}}++;
974     }
975    
976     @ResourceDef:
977     @@ForCheck: ForCompact
978     @@QName: mn|unsetXRefNode
979     @@enDesc:
980     Unsets a <Q::mn:xrefnode0> property.
981     @@rdf:type: DISPerl|BlockCode
982     @@PerlDef:
983     if (defined $referrer->{$propName}) {
984     if (${$referrer->{<H::mn:treeID>}} ne ${$referent->{<H::mn:treeID>}}) {
985     $referent->{<H::mn:rc>}--;
986     ${$referent->{<H::mn:groveReferenceCounter>}}--;
987     unless (<Code::isGroveReferenced:: $node = $referent>) {
988     $referent-><M::NodeStem.destroy>;
989     }
990     }
991     CORE::delete $referrer->{$propName};
992     }
993 wakaba 1.10 ##NodeStem
994 wakaba 1.1
995     ## -- Public node object
996    
997     ClassDef:
998 wakaba 1.10 @resourceFor: ForFull
999     @resourceFor: ForCompact
1000     @resourceFor:
1001     ManakaiDOM:ForIF
1002    
1003     @QName:
1004     @@@: NodeRef
1005     @@ForCheck:
1006     ManakaiDOM:ForIF
1007    
1008 wakaba 1.1 @QName:
1009 wakaba 1.10 @@@:
1010     ManakaiDOM:ManakaiDOMNodeReference
1011     @@ForCheck: ForFull
1012    
1013     @Implement:
1014     @@@: NodeRef
1015     @@ForCheck: ForFull
1016    
1017     @QName:
1018     @@@: ManakaiNodeRef
1019     @@ForCheck: ForCompact
1020    
1021     @Implement:
1022     @@@: NodeRef
1023     @@ForCheck: ForCompact
1024    
1025 wakaba 1.22 @DISLang:role:
1026     @@@: mn|NodeRefRole
1027     @@ForCheck: ForCompact
1028    
1029 wakaba 1.1 @Description:
1030     @@lang:en
1031     @@@:
1032     References to the node object corresponding to it. From
1033     applications' view, any node object is hidden and
1034     <Class::ManakaiDOM:ManakaiDOMNodeReference> seems as if
1035     the node itself.
1036     @ImplNote:
1037     @@lang:en
1038     @@@:
1039 wakaba 1.13 {P:: A <Class::ManakaiDOM:ManakaiDOMNodeReference> is a blessed hash
1040 wakaba 1.1 reference; currently there is a hash key defined:
1041     \
1042     - <CODE::TreeCore:node>::: A node object
1043     (<Class::ManakaiDOM:ManakaiDOMNodeObject>) to which
1044     this is referring.
1045 wakaba 1.13
1046     - <CODE::TreeCore:isWeak>::: Whether the reference is <QUOTE::weak>
1047     or not.
1048     }
1049    
1050     @ResourceDef:
1051     @@Name: free
1052     @@rdf:type: DISLang|Method
1053     @@enDesc:
1054     Frees the grove referenced by this object. Once
1055     this operation is done, results of operations to objects belonging
1056     to the grove are unknown.
1057     @@ForCheck: ForCompact
1058     @@Return:
1059     @@@PerlDef:
1060 wakaba 1.19 $self->{<H::mn:node>}-><M::NodeStem.destroy>;
1061 wakaba 1.1
1062     @IntMethod:
1063     @@Name: destroy
1064     @@Description:
1065     @@@lang:en
1066     @@@@: Destroy this reference object.
1067     @@Operator:
1068     @@@ContentType:
1069     lang:Perl
1070     @@@@: DESTROY
1071     @@Return:
1072     @@@PerlDef:
1073 wakaba 1.25 @@@@ForCheck: ForFull
1074 wakaba 1.1 @@@@@:
1075 wakaba 1.19 my $node = $self->{<H::mn:node>};
1076 wakaba 1.1 if ($node) {
1077 wakaba 1.19 CORE::delete $self->{<H::mn:node>};
1078     unless ($self->{<H::mn:isWeak>}) {
1079     $node->{<H::mn:rc>}--;
1080 wakaba 1.10 unless ($node-><M::NodeStem.isExternallyReferred>) {
1081     $node-><M::NodeStem.destroy>;
1082 wakaba 1.6 }
1083 wakaba 1.1 }
1084     } else {
1085     warn ref ($self) . q{->DESTROY: there is no associated }.
1086     q{node object - you have a global variable or }.
1087     qq{potential memory-leak detected\n};
1088     }
1089 wakaba 1.25 @@@PerlDef:
1090     @@@@ForCheck: ForCompact
1091     @@@@@:
1092     my $node = $self->{<H::mn:node>};
1093     if ($node) {
1094     CORE::delete $self->{<H::mn:node>};
1095     unless ($self->{<H::mn:isWeak>}) {
1096     $node->{<H::mn:rc>}--;
1097     ${$node->{<H::mn:groveReferenceCounter>}}--;
1098     unless (<Code::isGroveReferenced:: $node = $node>) {
1099     $node-><M::NodeStem.destroy>;
1100     }
1101     }
1102     } else {
1103     warn ref ($self) . q{->DESTROY: there is no associated }.
1104     q{node object - you have a global variable or }.
1105     qq{potential memory-leak detected\n};
1106     }
1107 wakaba 1.1 @@@@ImplNote:
1108     @@@@@lang:en
1109     @@@@@@:
1110     {P::Warning during the global destruction might mean:
1111     \
1112     - there be a loop in the manakai internal implementation -
1113     it should be a bug.
1114     \
1115     - there be a loop created by application, e.g.
1116     event handler containing a reference to any node
1117     belonging to the same tree.
1118     \
1119     - there be a global variable that contains a node reference
1120     and it is not altered or <Perl::undef>ed until the global
1121     destruction.
1122     \
1123     - or other unknown bad situation.
1124     \
1125     }
1126     @@ImplNote:
1127     @@@lang:en
1128     @@@@:
1129     Don't override this method unintentionally - for example,
1130     inheritting <PerlModule::Tie::Array> would hide this method
1131     from that class, since that module defines its own
1132     destructor.
1133 wakaba 1.10 ##NodeRef
1134 wakaba 1.22
1135     ResourceDef:
1136     @QName: mn|NodeRefRole
1137     @rdf:type: DISLang|Role
1138     @For: =ManakaiDOM|all
1139     @enDesc:
1140     The <QUOTE::dis> definition for a class which plays the role
1141     of <Q::mn|NodeRefRole> provides a set of <QUOTE::dis> properties such
1142     as <Q::mn|subnode0> which identify the set of object internal
1143     property names (or hash key names) used to construct groves.
1144    
1145     PropDef:
1146     @QName: mn|type
1147     @mn:stemName: t
1148    
1149     PropDef:
1150     @QName: mn|noderef
1151     @dataType: DISCore|QName
1152     @multipleProperties: DISCore|UnorderedList
1153    
1154     PropDef:
1155     @QName: mn|subnode0
1156     @enDesc:
1157     A property of type <Q::mn|subnode0> takes a value of
1158     reference to another node (<Q::mn|NodeStem||ManakaiDOM|Perl>)
1159     in the same grove. The referenced node is considered
1160     to make a part of the node and just one <Q::mn|origin0>
1161     property of the referenced node <kwd:MUST> have a reference
1162     to the node. That is, these properties shows
1163     a origin-subnode-relationship.
1164     @dataType: DISCore|QName
1165     @multipleProperties: DISCore|UnorderedList
1166 wakaba 1.23 @mn:stemName: s0
1167 wakaba 1.22
1168     PropDef:
1169     @QName: mn|subnode1
1170     @enDesc:
1171     A property of type <Q::mn|subnode1> is similar to <Q::mn|subnode0>
1172     properties, but its value is an array or hash reference whose
1173     values are references to subnodes.
1174     @rdfs:subPropertyOf: mn|noderef
1175     @dataType: DISCore|QName
1176     @multipleProperties: DISCore|UnorderedList
1177 wakaba 1.23 @mn:stemName: s
1178 wakaba 1.22
1179     PropDef:
1180     @QName: mn|subnode2
1181     @enDesc:
1182     A property of type <Q::mn|subnode2> is similar to <Q::mn|subnode1>
1183     properties, but its value is an array or hash reference whose
1184     values are array or hash references whose values are
1185     references to subnodes.
1186     @rdfs:subPropertyOf: mn|noderef
1187     @dataType: DISCore|QName
1188     @multipleProperties: DISCore|UnorderedList
1189 wakaba 1.23 @mn:stemName: s2
1190 wakaba 1.22
1191     PropDef:
1192     @QName: mn|origin0
1193     @rdfs:subPropertyOf: mn|noderef
1194     @dataType: DISCore|QName
1195     @multipleProperties: DISCore|UnorderedList
1196 wakaba 1.23 @mn:stemName: o
1197 wakaba 1.27
1198     PropDef:
1199     @QName: mn|xrefnode0
1200     @rdfs:subPropertyOf: mn|noderef
1201     @dataType: DISCore|QName
1202     @multipleProperties: DISCore|UnorderedList
1203     @mn:stemName: x
1204     @rdf:type: DISSource|ResourceProperty
1205     @enDesc:
1206     An <Q::mn:xrefnode0> property references a node <html5:var::m> in the tree
1207     <html5:var::s> that might be different from the tree <html5:var::t> to which
1208     the subject node <html5::var::n> of the property belongs.
1209    
1210     When the property value is set and <html5:var::s> is
1211     different from <html5:var::t>, then reference counters for
1212     <html5:var::m> and <html5:var::s> are increased, so that
1213     the tree <html5:var::s> would not be deleted while this
1214     link has been maintained. When the property value is unset
1215     or an <M::NodeStem||ManakaiDOM|Perl.importTree> operation
1216     makes two trees to one, then two reference counters
1217     are decreased.
1218 wakaba 1.22
1219     PropDef:
1220     @QName: mn|irefnode0
1221     @rdfs:subPropertyOf: mn|noderef
1222     @dataType: DISCore|QName
1223     @multipleProperties: DISCore|UnorderedList
1224 wakaba 1.23 @mn:stemName: i
1225 wakaba 1.22
1226     PropDef:
1227     @QName: mn|anydata1
1228     @rdfs:subPropertyOf: mn|noderef
1229     @dataType: DISCore|QName
1230     @multipleProperties: DISCore|UnorderedList
1231 wakaba 1.23 @mn:stemName: a1
1232 wakaba 1.22
1233     PropDef:
1234     @QName: mn|anydata2
1235     @rdfs:subPropertyOf: mn|noderef
1236     @dataType: DISCore|QName
1237     @multipleProperties: DISCore|UnorderedList
1238 wakaba 1.23 @mn:stemName: a2
1239 wakaba 1.6
1240     PropDef:
1241 wakaba 1.19 @QName: mn|nodeID
1242     @enDesc:
1243     The globally unique identifier of the node.
1244     @mn:stemName: nid
1245    
1246     PropDef:
1247     @QName: mn|treeID
1248     @enDesc:
1249     The globally unique identifier of the grove to which the
1250     node belongs.
1251     @mn:stemName: tid
1252    
1253     PropDef:
1254     @QName: mn|rc
1255     @enDesc:
1256     The number of the reference that points the node.
1257     @mn:stemName: rc
1258    
1259     PropDef:
1260 wakaba 1.25 @QName: mn|groveReferenceCounter
1261     @enDesc:
1262     A reference to the number of references that reference
1263     a node in the grove.
1264     @mn:stemName: grc
1265    
1266     PropDef:
1267 wakaba 1.19 @QName: mn|node
1268     @mn:refName: node
1269     @rdfs:domain: mn|NodeRef||ManakaiDOM|Perl
1270     @rdfs:range: mn|NodeStem||ManakaiDOM|Perl
1271    
1272     PropDef:
1273     @QName: mn|isWeak
1274 wakaba 1.6 @enDesc:
1275     Whether a reference is weak or not.
1276 wakaba 1.19 @rdfs:domain: mn|NodeRef||ManakaiDOM|Perl
1277 wakaba 1.16 @Type: DISPerl|Boolean
1278 wakaba 1.19 @mn:refName: w
1279    
1280     PropDef:
1281     @QName: mn|stemName
1282     @enDesc:
1283     The key name of the property when it is used in <Class::ManakaiNodeStem
1284     ::ManakaiDOM:Perl>.
1285     @dataType: DISCore|String
1286     @multipleProperties: DISCore|Single
1287     @rdfs:domain: rdfs|Property
1288     @rdfs:subPropertyOf: DISPerl|propHashKey
1289    
1290     PropDef:
1291     @QName: mn|refName
1292     @enDesc:
1293     The key name of the property when it is used in <Class::ManakaiNodeRef
1294     ::ManakaiDOM:Perl>.
1295     @dataType: DISCore|String
1296     @multipleProperties: DISCore|Single
1297     @rdfs:domain: rdfs|Property
1298     @rdfs:subPropertyOf: DISPerl|propHashKey
1299 wakaba 1.6
1300     ElementTypeBinding:
1301     @Name:PropDef
1302     @ElementType:
1303     dis:ResourceDef
1304     @ShadowContent:
1305     @@rdf:type:
1306     rdf:Property
1307 wakaba 1.16 @@For: =ManakaiDOM|all
1308 wakaba 1.6
1309     ElementTypeBinding:
1310     @Name:enDesc
1311     @ElementType:
1312     dis:Description
1313     @ShadowContent:
1314     @@lang:en
1315 wakaba 1.1
1316     ## -- Frequently used code fragments
1317    
1318     ResourceDef:
1319     @QName:
1320     ManakaiDOM:generateUniqueID
1321     @rdf:type:
1322     dis2pm:InlineCode
1323     @Description:
1324     @@lang:en
1325     @@@:
1326     Generates a global-unique opaque string.
1327     \
1328     {NOTE:: A URI reference is generated by this code.
1329     \
1330     }
1331 wakaba 1.16
1332     @For: =ManakaiDOM|Perl
1333    
1334 wakaba 1.1 @PerlDef:
1335     (
1336 wakaba 1.24 sprintf 'tag:suika.fam.cx,2005-09:%x:%x%s',
1337 wakaba 1.1 time, $$,
1338     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1339     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1340     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1341     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62] .
1342     ['A'..'Z', 'a'..'z', '0'..'9']->[rand 62]
1343     )
1344     ##ManakaiDOM:generateUniqueID
1345    
1346     ## -- lang:dis vocabulary
1347    
1348     TreeElementType:
1349     @QName:
1350     dis:GetProp
1351     @dataType:
1352     dis:TypeQName
1353     @rdfs:range:
1354     rdf:Property
1355     @Description:
1356     @@lang:en
1357     @@@:
1358     Gets the non-nodal value of a <Class::ManakaiDOM:ManakaiDOMNodeReference>
1359     property (actualy <Class::ManakaiDOM:ManakaiDOMNodeObject> property).
1360    
1361     TreeElementType:
1362     @QName:
1363     dis:SetProp
1364     @dataType:
1365     dis:TypeQName
1366     @rdfs:range:
1367     rdf:Property
1368     @Description:
1369     @@lang:en
1370     @@@:
1371     Sets the non-nodal value of a <Class::ManakaiDOM:ManakaiDOMNodeReference>
1372     property (actualy <Class::ManakaiDOM:ManakaiDOMNodeObject> property).
1373    
1374     ## -- Syntax sugar
1375    
1376     ElementTypeBinding:
1377     @Name: TreeElementType
1378     @ElementType:
1379     dis:ResourceDef
1380     @ShadowContent:
1381     @@rdf:type:
1382     DISLang:TreeElementType
1383 wakaba 1.16 @@For: =ManakaiDOM|all
1384 wakaba 1.1
1385     ElementTypeBinding:
1386     @Name: ClassDef
1387     @ElementType:
1388     dis:ResourceDef
1389     @ShadowContent:
1390     @@rdf:type:
1391     @@@@:
1392 wakaba 1.10 dis:MultipleResource
1393     @@@ForCheck:
1394     !ForFull !ForCompact !ManakaiDOM:ForIF
1395     @@rdf:type:
1396 wakaba 1.25 @@@@: DISLang|Interface
1397     @@@ForCheck: ManakaiDOM|ForIF
1398 wakaba 1.10 @@rdf:type:
1399 wakaba 1.25 @@@@: DISLang|Class
1400 wakaba 1.10 @@@ForCheck: ForFull
1401     @@rdf:type:
1402 wakaba 1.25 @@@@: DISLang|Class
1403 wakaba 1.10 @@@ForCheck: ForCompact
1404 wakaba 1.25 @@ForCheck: ManakaiDOM|Perl
1405 wakaba 1.10
1406     ForDef:
1407     @QName:
1408     mn:ForFull
1409 wakaba 1.25 @ISA: ManakaiDOM|ForClass
1410 wakaba 1.10
1411     ForDef:
1412     @QName:
1413     mn:ForCompact
1414 wakaba 1.25 @ISA: ManakaiDOM|ForClass
1415 wakaba 1.1
1416     ElementTypeBinding:
1417     @Name: IntMethod
1418     @ElementType:
1419     dis:ResourceDef
1420     @ShadowContent:
1421     @@rdf:type:
1422     DISLang:Method
1423     @@ManakaiDOM:isForInternal:1
1424    
1425     ElementTypeBinding:
1426     @Name: Return
1427     @ElementType:
1428     dis:ResourceDef
1429     @ShadowContent:
1430     @@rdf:type:
1431     DISLang:MethodReturn
1432    
1433     ElementTypeBinding:
1434     @Name: Param
1435     @ElementType:
1436     dis:ResourceDef
1437     @ShadowContent:
1438     @@rdf:type:
1439     DISLang:MethodParameter
1440    
1441     ElementTypeBinding:
1442     @Name: PerlDef
1443     @ElementType:
1444     dis:Def
1445     @ShadowContent:
1446     @@ContentType:
1447     lang:Perl
1448    
1449     ElementTypeBinding:
1450     @Name: InCase
1451     @ElementType:
1452     dis:ResourceDef
1453     @ShadowContent:
1454     @@rdf:type:
1455     ManakaiDOM:InCase

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24