/[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.28 - (hide annotations) (download)
Wed Oct 12 00:31:05 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.27: +12 -6 lines
++ manakai/bin/ChangeLog	12 Oct 2005 00:13:08 -0000
2005-10-11  Wakaba  <wakaba@suika.fam.cx>

	* dac2pm.pl: Reports how long it takes at END.

++ manakai/lib/Message/Util/ChangeLog	12 Oct 2005 00:25:36 -0000
2005-10-11  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (IfClsDef, IFClsETDef): New version of classes based
	on DOMCore and element type definitions added.
	(localName): Renamed to "pcLocalName" to avoid
	conflict with "Node.localName" attribute.

2005-10-10  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis (Require): Unused reference to "PerlCode.dis" removed.

	* Makefile: Rules to make "PerlCode.pm" separated
	from ones for "DIS.pm".

	* ManakaiNode.dis (mn:unsetXRefNode): "$referent"
	parameter is replaced with "$referrer->{$propName}".

	* PerlCode.dis (Require): References "DOMCore.dis".
	(DefaultFor): Changed to "ManakaiDOM:ManakaiDOMLatest".
	(Util: for ManakaiDOM:ManakaiDOM): New.

++ manakai/lib/Message/Util/DIS/ChangeLog	12 Oct 2005 00:30:10 -0000
2005-10-11  Wakaba  <wakaba@suika.fam.cx>

	* Perl.dis (plImplementation): Changed to direct
	instantiation of "ManakaiPCImplementation" class.
	(getPerlNameList, getPerlOperatorList): New methods.
	(plCodeFragment): Now allows subroutines having more than
	two method names and operators.
	(plMethodOperator): Removed.

2005-10-10  Wakaba  <wakaba@suika.fam.cx>

	* DNLite.dis (Require): Reference to "DIS/Perl.dis" added.

	* Perl.dis (Require): Reference to "PerlCode.dis" added.

++ manakai/lib/Message/DOM/ChangeLog	12 Oct 2005 00:15:44 -0000
2005-10-11  Wakaba  <wakaba@suika.fam.cx>

	* DOMCore.dis (appendChild, createElementNS, createAttributeNS,
	setAttribute, setAttributeNS): "strictErrorChecking" attribute supported.
	(doStrictErrorChecking): New code.

	* DOMMain.dis (XML10Name, XML11Name): "strictErrorChecking" attribute
	supported.

	* Makefile: Rule to make "DOMFeature.pm" restored.

2005-10-10  Wakaba  <wakaba@suika.fam.cx>

	* DOMCore.dis (ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR): New error subcode.
	(adoptNode): Implemented.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24