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