/[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.17 - (hide annotations) (download)
Thu Sep 22 11:02:33 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.16: +7 -21 lines
++ manakai/bin/ChangeLog	22 Sep 2005 10:33:43 -0000
2005-09-22  Wakaba  <wakaba@suika.fam.cx>

	* dac2pm.pl (status_msg_, status_msg): New functions.
	(--create-perl-module): New option.

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

	* dac.pl: Show how long the process takes.
	(status_msg_, status_msg): New functions.
	(dac_load_module_file): Converts dis document into DNLite document.

	* dac2pm.pl: Unused namespace bindings removed.

++ manakai/lib/Message/Util/ChangeLog	22 Sep 2005 10:40:13 -0000
2005-09-22  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis (Util:): Added for DIS|ForEmpty and DIS|ForLatest.
	(disIsNullable): Reimplemented.

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

	* DIS.dis (addNamespaceBinding): New method.

++ manakai/lib/Message/Util/DIS/ChangeLog	22 Sep 2005 10:56:00 -0000
2005-09-21  Wakaba  <wakaba@suika.fam.cx>

	* Value.dis (DVValue): Extends DIS|NSResolverDIS.

	* DNLite.dis: "databaseArg" parameter added to some methods.
	(free, addNamespaceBinding, getDefaultNamespaceURIRef,
	getNamespaceBindingList): New methods.
	(DNLElement): Inherits DIS/Perl|DISElementPerl.
	(expandedURI, disGetAttribute, plImplementation): New.

	* Perl.dis (plCodeFragment): "databaseArg" parameter added.

++ manakai/lib/Message/DOM/ChangeLog	22 Sep 2005 10:36:20 -0000
2005-09-21  Wakaba  <wakaba@suika.fam.cx>

	* DOMCore.pm (DOMImplementation): Provides "XML" and "XMLVersion"
	features if it is "for" ManakaiDOM:DOMXMLFeature.

	* DOMMain.pm (StringExtended): Code portions of raising
	StringOutOfBoundsException is temporary disabled since
	it is not a DOM-style exception supported by
	current implementation of ManakaiNode - it will be
	recovered in later revision.

++ manakai/lib/manakai/ChangeLog	22 Sep 2005 11:00:19 -0000
2005-09-21  Wakaba  <wakaba@suika.fam.cx>

	* DISPerl.dis (DISPerl:packageName): New.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24