/[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.18 - (hide annotations) (download)
Fri Sep 23 18:25:05 2005 UTC (19 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.17: +2 -21 lines
++ manakai/doc/ChangeLog	23 Sep 2005 17:22:30 -0000
2005-09-23  Wakaba  <wakaba@suika.fam.cx>

	* Makefile: Command-line arguments for new modules added.
	(DAC_PREFIX): Changed to ".dad".

++ manakai/bin/ChangeLog	23 Sep 2005 17:21:35 -0000
2005-09-24  Wakaba  <wakaba@suika.fam.cx>

	* dac.pl, dac2pm.pl, mkdisdump.pl: "--debug" option added.

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

	* mkdisdump.pl: Fixed to support new dad database implementation.

++ manakai/lib/Message/Util/ChangeLog	23 Sep 2005 17:29:45 -0000
2005-09-23  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis (DISParser.new): New method.
	(hasFeature): Removed.  ManakaiDISAnyResource now
	extends DOMFeature:ManakaiHasFeatureByGetFeature.
	(readProperties): Support for property value data
	types DISLang:MemberRef and dx:XCRef added.
	(ManakaiDISExceptionTarget): It is now an alias
	for dx:ManakaiDefaultExceptionHandler.

++ manakai/lib/Message/Util/Error/ChangeLog	23 Sep 2005 17:41:25 -0000
2005-09-23  Wakaba  <wakaba@suika.fam.cx>

	* DOMException.dis (dx:raises): Properties dis:dataType
	and dis:multipleProperties added.

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

	* DISDoc.dis: Modified to support new "dad" implementation.
	(DISElementDISDoc): Removed.
	(DVValueDISDoc): New.
	(documentionGroupId): This attribute values now
	do not include element type names.

	* DNLite.dis (convertDISDocumentToDNLDocument): Fixed
	not to "tie" happens to cause strange segmentation fault.

	* Perl.dis (plCodeFragment): Support for the
	role "dv:ValurRole" added.  Property name "dis:AppName"
	is changed to more specific property names.  Throws
	an exception if an input processor has no Perl code
	definition.  A parameter value to "getPropertyValue"
	was missing.

	* Value.dis (dv:ValueRole): New role.
	(DVValue.getFeature): New method.
	(DVValue): Now extends DOMFeature:ManakaiHasFeatureByGetFeature
	so that it implements DOMFeature:GetFeature.

++ manakai/lib/Message/DOM/ChangeLog	23 Sep 2005 17:24:34 -0000
2005-09-23  Wakaba  <wakaba@suika.fam.cx>

	* GenericLS.dis, SimpleLS.dis: New modules separated
	from DOMLS.dis.

	* DOMFeature.dis, DOMMain.dis: "MDOM:" and "for" definitions
	moved from DOMMain to DOMFeature.  Now DOMFeature
	has no dependency on DOMMain.

	* DOMFeature.dis (DEBUG): New variable.

++ manakai/lib/manakai/ChangeLog	23 Sep 2005 17:44:24 -0000
2005-09-23  Wakaba  <wakaba@suika.fam.cx>

	* DISCore.dis (dis:Label, dis:FullName): Their "dis:multipleProperties"
	property is fixed to "DISCore:UnorderedList" to allow
	language variants.
	(dis:Author): Marked as obsolete.
	(DISCore:author): New property.
	(DISCore:Wakaba): New resource.

	* DISPerl.dis (DISPerl:name, DISPerl:constName,
	DISPerl:exportTagName, DISPerl:variableName, DISPerl:paramName):
	New properties.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24