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