/[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.16 - (hide annotations) (download)
Tue Sep 20 12:21:50 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.15: +8 -19 lines
++ manakai/lib/Message/Markup/ChangeLog	20 Sep 2005 12:08:51 -0000
2005-09-20  Wakaba  <wakaba@suika.fam.cx>

	* SuikaWikiConfig21.dis (valueRef, nodeIDRef): New attributes.

++ manakai/lib/Message/Util/ChangeLog	20 Sep 2005 12:10:46 -0000
2005-09-20  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis: Use valueRef and nodeIDRef where possible so
	that dad file can share text data if possible.
	For resources, {subOf} and {supOf} is now optional.
	(sourceNodeIDRef): New attribute.

++ manakai/lib/Message/Util/Error/ChangeLog	20 Sep 2005 12:16:35 -0000
2005-09-20  Wakaba  <wakaba@suika.fam.cx>

	* DOMException.dis (Class, Interface): New types.
	ManakaiDOM:ExceptionClass and ManakaiDOM:ExceptionIF
	are now deprecated.
	(disPerl:EXCEPTION, disPerl:WARNING): Moved
	from /lib/manakai/DISPerl.dis.

++ manakai/lib/Message/Util/DIS/ChangeLog	20 Sep 2005 12:14:37 -0000
2005-09-20  Wakaba  <wakaba@suika.fam.cx>

	* Value.dis (createDVValueRef): New method.  Now
	values are hold as scalar reference in ManakaiDVValue.
	(valueRef): New attribute.

	* DNLite.dis (ManakaiDISImplementationDNLite): Now extends
	class ManakaiDISImplementation.
	(convertDISDocumentToDNLDocument): Typo in class names fixed.
	For nodes, {child} property is now optional.
	(nodeIDRef, valueRef): New attributes.

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

	* DOMFeature.pm: Debug output code copied
	from Attic/DOMMetaImpl.pm (Should these code incorporated
	to source dis file?).

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

	* DISIDL.dis: Full names are given to data types.

	* DISCore.dis, DISLang.dis, DISPerl.dis: Refactored so
	that some resources has made its canonical URI changed.
	Lexical types (DISCore:LexicalType) and programming
	language data types (DISLang:AnyDataType) is now
	clearly separated.  New name given for,
	e.g., dis:TypeQName (now DISCore:QName), Perl:ARRAY (now
	DISPerl:ARRAY), and so on.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24