1 /*
2  * This file is part of libdom.
3  * Licensed under the MIT License,
4  *                http://www.opensource.org/licenses/mit-license.php
5  * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
6  */
7 
8 #ifndef dom_core_node_h_
9 #define dom_core_node_h_
10 
11 #include <inttypes.h>
12 #include <stdbool.h>
13 
14 #include <dom/core/exceptions.h>
15 #include <dom/core/string.h>
16 #include <dom/events/event_target.h>
17 
18 struct dom_document;
19 struct dom_nodelist;
20 struct dom_namednodemap;
21 struct dom_node;
22 
23 /**
24  * Bits defining position of a node in a document relative to some other node
25  */
26 typedef enum {
27 	DOM_DOCUMENT_POSITION_DISCONNECTED		= 0x01,
28 	DOM_DOCUMENT_POSITION_PRECEDING			= 0x02,
29 	DOM_DOCUMENT_POSITION_FOLLOWING			= 0x04,
30 	DOM_DOCUMENT_POSITION_CONTAINS			= 0x08,
31 	DOM_DOCUMENT_POSITION_CONTAINED_BY		= 0x10,
32 	DOM_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC	= 0x20
33 } dom_document_position;
34 
35 /**
36  * Type of node operation being notified to user_data_handler
37  */
38 typedef enum {
39 	DOM_NODE_CLONED		= 1,
40 	DOM_NODE_IMPORTED	= 2,
41 	DOM_NODE_DELETED	= 3,
42 	DOM_NODE_RENAMED	= 4,
43 	DOM_NODE_ADOPTED	= 5
44 } dom_node_operation;
45 
46 /**
47  * Type of handler function for user data registered on a DOM node
48  */
49 typedef void (*dom_user_data_handler)(dom_node_operation operation,
50 		dom_string *key, void *data, struct dom_node *src,
51 		struct dom_node *dst);
52 
53 /**
54  * Type of a DOM node
55  */
56 typedef enum {
57 	DOM_ELEMENT_NODE		= 1,
58 	DOM_ATTRIBUTE_NODE		= 2,
59 	DOM_TEXT_NODE			= 3,
60 	DOM_CDATA_SECTION_NODE		= 4,
61 	DOM_ENTITY_REFERENCE_NODE	= 5,
62 	DOM_ENTITY_NODE			= 6,
63 	DOM_PROCESSING_INSTRUCTION_NODE	= 7,
64 	DOM_COMMENT_NODE		= 8,
65 	DOM_DOCUMENT_NODE		= 9,
66 	DOM_DOCUMENT_TYPE_NODE		= 10,
67 	DOM_DOCUMENT_FRAGMENT_NODE	= 11,
68 	DOM_NOTATION_NODE		= 12,
69 
70 	/* And a count of the number of node types */
71 	DOM_NODE_TYPE_COUNT
72 } dom_node_type;
73 
74 typedef struct dom_node_internal dom_node_internal;
75 
76 /**
77  * DOM node type
78  */
79 typedef struct dom_node {
80 	void *vtable;
81 	uint32_t refcnt;
82 } dom_node;
83 
84 /* DOM node vtable */
85 typedef struct dom_node_vtable {
86 	dom_event_target_vtable base;
87 	/* pre-destruction hook */
88 	dom_exception (*dom_node_try_destroy)(dom_node_internal *node);
89 	/* The DOM level 3 node's oprations */
90 	dom_exception (*dom_node_get_node_name)(dom_node_internal *node,
91 			dom_string **result);
92 	dom_exception (*dom_node_get_node_value)(dom_node_internal *node,
93 			dom_string **result);
94 	dom_exception (*dom_node_set_node_value)(dom_node_internal *node,
95 			dom_string *value);
96 	dom_exception (*dom_node_get_node_type)(dom_node_internal *node,
97 			dom_node_type *result);
98 	dom_exception (*dom_node_get_parent_node)(dom_node_internal *node,
99 			dom_node_internal **result);
100 	dom_exception (*dom_node_get_child_nodes)(dom_node_internal *node,
101 			struct dom_nodelist **result);
102 	dom_exception (*dom_node_get_first_child)(dom_node_internal *node,
103 			dom_node_internal **result);
104 	dom_exception (*dom_node_get_last_child)(dom_node_internal *node,
105 			dom_node_internal **result);
106 	dom_exception (*dom_node_get_previous_sibling)(dom_node_internal *node,
107 			dom_node_internal **result);
108 	dom_exception (*dom_node_get_next_sibling)(dom_node_internal *node,
109 			dom_node_internal **result);
110 	dom_exception (*dom_node_get_attributes)(dom_node_internal *node,
111 			struct dom_namednodemap **result);
112 	dom_exception (*dom_node_get_owner_document)(dom_node_internal *node,
113 			struct dom_document **result);
114 	dom_exception (*dom_node_insert_before)(dom_node_internal *node,
115 			dom_node_internal *new_child,
116 			dom_node_internal *ref_child,
117 			dom_node_internal **result);
118 	dom_exception (*dom_node_replace_child)(dom_node_internal *node,
119 			dom_node_internal *new_child,
120 			dom_node_internal *old_child,
121 			dom_node_internal **result);
122 	dom_exception (*dom_node_remove_child)(dom_node_internal *node,
123 			dom_node_internal *old_child,
124 			dom_node_internal **result);
125 	dom_exception (*dom_node_append_child)(dom_node_internal *node,
126 			dom_node_internal *new_child,
127 			dom_node_internal **result);
128 	dom_exception (*dom_node_has_child_nodes)(dom_node_internal *node,
129 			bool *result);
130 	dom_exception (*dom_node_clone_node)(dom_node_internal *node, bool deep,
131 			dom_node_internal **result);
132 	dom_exception (*dom_node_normalize)(dom_node_internal *node);
133 	dom_exception (*dom_node_is_supported)(dom_node_internal *node,
134 			dom_string *feature, dom_string *version,
135 			bool *result);
136 	dom_exception (*dom_node_get_namespace)(dom_node_internal *node,
137 			dom_string **result);
138 	dom_exception (*dom_node_get_prefix)(dom_node_internal *node,
139 			dom_string **result);
140 	dom_exception (*dom_node_set_prefix)(dom_node_internal *node,
141 			dom_string *prefix);
142 	dom_exception (*dom_node_get_local_name)(dom_node_internal *node,
143 			dom_string **result);
144 	dom_exception (*dom_node_has_attributes)(dom_node_internal *node,
145 			bool *result);
146 	dom_exception (*dom_node_get_base)(dom_node_internal *node,
147 			dom_string **result);
148 	dom_exception (*dom_node_compare_document_position)(
149 			dom_node_internal *node, dom_node_internal *other,
150 			uint16_t *result);
151 	dom_exception (*dom_node_get_text_content)(dom_node_internal *node,
152 			dom_string **result);
153 	dom_exception (*dom_node_set_text_content)(dom_node_internal *node,
154 			dom_string *content);
155 	dom_exception (*dom_node_is_same)(dom_node_internal *node,
156 			dom_node_internal *other, bool *result);
157 	dom_exception (*dom_node_lookup_prefix)(dom_node_internal *node,
158 			dom_string *namespace,
159 			dom_string **result);
160 	dom_exception (*dom_node_is_default_namespace)(dom_node_internal *node,
161 			dom_string *namespace, bool *result);
162 	dom_exception (*dom_node_lookup_namespace)(dom_node_internal *node,
163 			dom_string *prefix, dom_string **result);
164 	dom_exception (*dom_node_is_equal)(dom_node_internal *node,
165 			dom_node_internal *other, bool *result);
166 	dom_exception (*dom_node_get_feature)(dom_node_internal *node,
167 			dom_string *feature, dom_string *version,
168 			void **result);
169 	dom_exception (*dom_node_set_user_data)(dom_node_internal *node,
170 			dom_string *key, void *data,
171 			dom_user_data_handler handler, void **result);
172 	dom_exception (*dom_node_get_user_data)(dom_node_internal *node,
173 			dom_string *key, void **result);
174 } dom_node_vtable;
175 
176 /* The ref/unref methods define */
177 
dom_node_ref(dom_node * node)178 static inline dom_node *dom_node_ref(dom_node *node)
179 {
180 	if (node != NULL)
181 		node->refcnt++;
182 
183 	return node;
184 }
185 
186 #define dom_node_ref(n) dom_node_ref((dom_node *) (n))
187 
dom_node_try_destroy(dom_node * node)188 static inline dom_exception dom_node_try_destroy(dom_node *node)
189 {
190 	return ((dom_node_vtable *) node->vtable)->dom_node_try_destroy(
191 			(dom_node_internal *) node);
192 }
193 #define dom_node_try_destroy(n) dom_node_try_destroy((dom_node *) (n))
194 
dom_node_unref(dom_node * node)195 static inline void dom_node_unref(dom_node *node)
196 {
197 	if (node != NULL) {
198 		if (--node->refcnt == 0)
199 			dom_node_try_destroy(node);
200 	}
201 
202 }
203 #define dom_node_unref(n) dom_node_unref((dom_node *) (n))
204 
205 /* Contains is non-virtual since it doesn't need to be */
206 
207 dom_exception _dom_node_contains(struct dom_node_internal *node,
208 				struct dom_node_internal *other,
209 				bool *contains);
210 #define dom_node_contains(n, o, c) \
211 	_dom_node_contains((dom_node_internal *)(n), (dom_node_internal *)(o), (c))
212 
213 /* All the rest are virtual */
214 
dom_node_get_node_name(struct dom_node * node,dom_string ** result)215 static inline dom_exception dom_node_get_node_name(struct dom_node *node,
216 		dom_string **result)
217 {
218 	return ((dom_node_vtable *) node->vtable)->dom_node_get_node_name(
219 			(dom_node_internal *) node, result);
220 }
221 #define dom_node_get_node_name(n, r) dom_node_get_node_name((dom_node *) (n), (r))
222 
dom_node_get_node_value(struct dom_node * node,dom_string ** result)223 static inline dom_exception dom_node_get_node_value(struct dom_node *node,
224 		dom_string **result)
225 {
226 	return ((dom_node_vtable *) node->vtable)->dom_node_get_node_value(
227 			(dom_node_internal *) node, result);
228 }
229 #define dom_node_get_node_value(n, r) dom_node_get_node_value( \
230 		(dom_node *) (n), (r))
231 
dom_node_set_node_value(struct dom_node * node,dom_string * value)232 static inline dom_exception dom_node_set_node_value(struct dom_node *node,
233 		dom_string *value)
234 {
235 	return ((dom_node_vtable *) node->vtable)->dom_node_set_node_value(
236 			(dom_node_internal *) node, value);
237 }
238 #define dom_node_set_node_value(n, v) dom_node_set_node_value( \
239 		(dom_node *) (n), (v))
240 
dom_node_get_node_type(struct dom_node * node,dom_node_type * result)241 static inline dom_exception dom_node_get_node_type(struct dom_node *node,
242 		dom_node_type *result)
243 {
244 	return ((dom_node_vtable *) node->vtable)->dom_node_get_node_type(
245 			(dom_node_internal *) node, result);
246 }
247 #define dom_node_get_node_type(n, r) dom_node_get_node_type( \
248 		(dom_node *) (n), (dom_node_type *) (r))
249 
dom_node_get_parent_node(struct dom_node * node,dom_node ** result)250 static inline dom_exception dom_node_get_parent_node(struct dom_node *node,
251 		dom_node **result)
252 {
253 	return ((dom_node_vtable *) node->vtable)->dom_node_get_parent_node(
254 			(dom_node_internal *) node,
255 			(dom_node_internal **) result);
256 }
257 #define dom_node_get_parent_node(n, r) dom_node_get_parent_node( \
258 		(dom_node *) (n), (dom_node **) (r))
259 
dom_node_get_child_nodes(struct dom_node * node,struct dom_nodelist ** result)260 static inline dom_exception dom_node_get_child_nodes(struct dom_node *node,
261 		struct dom_nodelist **result)
262 {
263 	return ((dom_node_vtable *) node->vtable)->dom_node_get_child_nodes(
264 			(dom_node_internal *) node, result);
265 }
266 #define dom_node_get_child_nodes(n, r) dom_node_get_child_nodes( \
267 		(dom_node *) (n), (struct dom_nodelist **) (r))
268 
dom_node_get_first_child(struct dom_node * node,dom_node ** result)269 static inline dom_exception dom_node_get_first_child(struct dom_node *node,
270 		dom_node **result)
271 {
272 	return ((dom_node_vtable *) node->vtable)->dom_node_get_first_child(
273 			(dom_node_internal *) node,
274 			(dom_node_internal **) result);
275 }
276 #define dom_node_get_first_child(n, r) dom_node_get_first_child( \
277 		(dom_node *) (n), (dom_node **) (r))
278 
dom_node_get_last_child(struct dom_node * node,dom_node ** result)279 static inline dom_exception dom_node_get_last_child(struct dom_node *node,
280 		dom_node **result)
281 {
282 	return ((dom_node_vtable *) node->vtable)->dom_node_get_last_child(
283 			(dom_node_internal *) node,
284 			(dom_node_internal **) result);
285 }
286 #define dom_node_get_last_child(n, r) dom_node_get_last_child( \
287 		(dom_node *) (n), (dom_node **) (r))
288 
dom_node_get_previous_sibling(struct dom_node * node,dom_node ** result)289 static inline dom_exception dom_node_get_previous_sibling(
290 		struct dom_node *node, dom_node **result)
291 {
292 	return ((dom_node_vtable *) node->vtable)->
293 			dom_node_get_previous_sibling(
294 			(dom_node_internal *) node,
295 			(dom_node_internal **) result);
296 }
297 #define dom_node_get_previous_sibling(n, r) dom_node_get_previous_sibling( \
298 		(dom_node *) (n), (dom_node **) (r))
299 
dom_node_get_next_sibling(struct dom_node * node,dom_node ** result)300 static inline dom_exception dom_node_get_next_sibling(struct dom_node *node,
301 		dom_node **result)
302 {
303 	return ((dom_node_vtable *) node->vtable)->dom_node_get_next_sibling(
304 			(dom_node_internal *) node,
305 			(dom_node_internal **) result);
306 }
307 #define dom_node_get_next_sibling(n, r) dom_node_get_next_sibling( \
308 		(dom_node *) (n), (dom_node **) (r))
309 
dom_node_get_attributes(struct dom_node * node,struct dom_namednodemap ** result)310 static inline dom_exception dom_node_get_attributes(struct dom_node *node,
311 		struct dom_namednodemap **result)
312 {
313 	return ((dom_node_vtable *) node->vtable)->dom_node_get_attributes(
314 			(dom_node_internal *) node, result);
315 }
316 #define dom_node_get_attributes(n, r) dom_node_get_attributes( \
317 		(dom_node *) (n), (struct dom_namednodemap **) (r))
318 
dom_node_get_owner_document(struct dom_node * node,struct dom_document ** result)319 static inline dom_exception dom_node_get_owner_document(struct dom_node *node,
320 		struct dom_document **result)
321 {
322 	return ((dom_node_vtable *) node->vtable)->dom_node_get_owner_document(
323 			(dom_node_internal *) node, result);
324 }
325 #define dom_node_get_owner_document(n, r) dom_node_get_owner_document( \
326 		(dom_node *) (n), (struct dom_document **) (r))
327 
dom_node_insert_before(struct dom_node * node,struct dom_node * new_child,struct dom_node * ref_child,struct dom_node ** result)328 static inline dom_exception dom_node_insert_before(struct dom_node *node,
329 		struct dom_node *new_child, struct dom_node *ref_child,
330 		struct dom_node **result)
331 {
332 	return ((dom_node_vtable *) node->vtable)->dom_node_insert_before(
333 			(dom_node_internal *) node,
334 			(dom_node_internal *) new_child,
335 			(dom_node_internal *) ref_child,
336 			(dom_node_internal **) result);
337 }
338 #define dom_node_insert_before(n, nn, ref, ret) dom_node_insert_before( \
339 		(dom_node *) (n), (dom_node *) (nn), (dom_node *) (ref),\
340 		(dom_node **) (ret))
341 
dom_node_replace_child(struct dom_node * node,struct dom_node * new_child,struct dom_node * old_child,struct dom_node ** result)342 static inline dom_exception dom_node_replace_child(struct dom_node *node,
343 		struct dom_node *new_child, struct dom_node *old_child,
344 		struct dom_node **result)
345 {
346 	return ((dom_node_vtable *) node->vtable)->dom_node_replace_child(
347 			(dom_node_internal *) node,
348 			(dom_node_internal *) new_child,
349 			(dom_node_internal *) old_child,
350 			(dom_node_internal **) result);
351 }
352 #define dom_node_replace_child(n, nn, old, ret) dom_node_replace_child( \
353 		(dom_node *) (n), (dom_node *) (nn), (dom_node *) (old),\
354 		(dom_node **) (ret))
355 
dom_node_remove_child(struct dom_node * node,struct dom_node * old_child,struct dom_node ** result)356 static inline dom_exception dom_node_remove_child(struct dom_node *node,
357 		struct dom_node *old_child,
358 		struct dom_node **result)
359 {
360 	return ((dom_node_vtable *) node->vtable)->dom_node_remove_child(
361 			(dom_node_internal *) node,
362 			(dom_node_internal *) old_child,
363 			(dom_node_internal **) result);
364 }
365 #define dom_node_remove_child(n, old, ret) dom_node_remove_child( \
366 		(dom_node *) (n), (dom_node *) (old), (dom_node **) (ret))
367 
dom_node_append_child(struct dom_node * node,struct dom_node * new_child,struct dom_node ** result)368 static inline dom_exception dom_node_append_child(struct dom_node *node,
369 		struct dom_node *new_child,
370 		struct dom_node **result)
371 {
372 	return ((dom_node_vtable *) node->vtable)->dom_node_append_child(
373 			(dom_node_internal *) node,
374 			(dom_node_internal *) new_child,
375 			(dom_node_internal **) result);
376 }
377 #define dom_node_append_child(n, nn, ret) dom_node_append_child( \
378 		(dom_node *) (n), (dom_node *) (nn), (dom_node **) (ret))
379 
dom_node_has_child_nodes(struct dom_node * node,bool * result)380 static inline dom_exception dom_node_has_child_nodes(struct dom_node *node,
381 		bool *result)
382 {
383 	return ((dom_node_vtable *) node->vtable)->dom_node_has_child_nodes(
384 			(dom_node_internal *) node, result);
385 }
386 #define dom_node_has_child_nodes(n, r) dom_node_has_child_nodes( \
387 		(dom_node *) (n), (bool *) (r))
388 
dom_node_clone_node(struct dom_node * node,bool deep,struct dom_node ** result)389 static inline dom_exception dom_node_clone_node(struct dom_node *node,
390 		bool deep, struct dom_node **result)
391 {
392 	return ((dom_node_vtable *) node->vtable)->dom_node_clone_node(
393 			(dom_node_internal *) node, deep,
394 			(dom_node_internal **) result);
395 }
396 #define dom_node_clone_node(n, d, r) dom_node_clone_node((dom_node *) (n), \
397 		(bool) (d), (dom_node **) (r))
398 
dom_node_normalize(struct dom_node * node)399 static inline dom_exception dom_node_normalize(struct dom_node *node)
400 {
401 	return ((dom_node_vtable *) node->vtable)->dom_node_normalize(
402 			(dom_node_internal *) node);
403 }
404 #define dom_node_normalize(n) dom_node_normalize((dom_node *) (n))
405 
dom_node_is_supported(struct dom_node * node,dom_string * feature,dom_string * version,bool * result)406 static inline dom_exception dom_node_is_supported(struct dom_node *node,
407 		dom_string *feature, dom_string *version,
408 		bool *result)
409 {
410 	return ((dom_node_vtable *) node->vtable)->dom_node_is_supported(
411 			(dom_node_internal *) node, feature,
412 			version, result);
413 }
414 #define dom_node_is_supported(n, f, v, r) dom_node_is_supported( \
415 		(dom_node *) (n), (f), (v), (bool *) (r))
416 
dom_node_get_namespace(struct dom_node * node,dom_string ** result)417 static inline dom_exception dom_node_get_namespace(struct dom_node *node,
418 		dom_string **result)
419 {
420 	return ((dom_node_vtable *) node->vtable)->dom_node_get_namespace(
421 			(dom_node_internal *) node, result);
422 }
423 #define dom_node_get_namespace(n, r) dom_node_get_namespace((dom_node *) (n), (r))
424 
dom_node_get_prefix(struct dom_node * node,dom_string ** result)425 static inline dom_exception dom_node_get_prefix(struct dom_node *node,
426 		dom_string **result)
427 {
428 	return ((dom_node_vtable *) node->vtable)->dom_node_get_prefix(
429 			(dom_node_internal *) node, result);
430 }
431 #define dom_node_get_prefix(n, r) dom_node_get_prefix((dom_node *) (n), (r))
432 
dom_node_set_prefix(struct dom_node * node,dom_string * prefix)433 static inline dom_exception dom_node_set_prefix(struct dom_node *node,
434 		dom_string *prefix)
435 {
436 	return ((dom_node_vtable *) node->vtable)->dom_node_set_prefix(
437 			(dom_node_internal *) node, prefix);
438 }
439 #define dom_node_set_prefix(n, p) dom_node_set_prefix((dom_node *) (n), (p))
440 
dom_node_get_local_name(struct dom_node * node,dom_string ** result)441 static inline dom_exception dom_node_get_local_name(struct dom_node *node,
442 		dom_string **result)
443 {
444 	return ((dom_node_vtable *) node->vtable)->dom_node_get_local_name(
445 			(dom_node_internal *) node, result);
446 }
447 #define dom_node_get_local_name(n, r) dom_node_get_local_name((dom_node *) (n), (r))
448 
dom_node_has_attributes(struct dom_node * node,bool * result)449 static inline dom_exception dom_node_has_attributes(struct dom_node *node,
450 		bool *result)
451 {
452 	return ((dom_node_vtable *) node->vtable)->dom_node_has_attributes(
453 			(dom_node_internal *) node, result);
454 }
455 #define dom_node_has_attributes(n, r) dom_node_has_attributes( \
456 		(dom_node *) (n), (bool *) (r))
457 
dom_node_get_base(struct dom_node * node,dom_string ** result)458 static inline dom_exception dom_node_get_base(struct dom_node *node,
459 		dom_string **result)
460 {
461 	return ((dom_node_vtable *) node->vtable)->dom_node_get_base(
462 			(dom_node_internal *) node, result);
463 }
464 #define dom_node_get_base(n, r) dom_node_get_base((dom_node *) (n), (r))
465 
dom_node_compare_document_position(struct dom_node * node,struct dom_node * other,uint16_t * result)466 static inline dom_exception dom_node_compare_document_position(
467 		struct dom_node *node, struct dom_node *other,
468 		uint16_t *result)
469 {
470 	return ((dom_node_vtable *) node->vtable)->
471 			dom_node_compare_document_position(
472 			(dom_node_internal *) node,
473 			(dom_node_internal *) other, result);
474 }
475 #define dom_node_compare_document_position(n, o, r) \
476 		dom_node_compare_document_position((dom_node *) (n), \
477 		(dom_node *) (o), (uint16_t *) (r))
478 
dom_node_get_text_content(struct dom_node * node,dom_string ** result)479 static inline dom_exception dom_node_get_text_content(struct dom_node *node,
480 		dom_string **result)
481 {
482 	return ((dom_node_vtable *) node->vtable)->dom_node_get_text_content(
483 			(dom_node_internal *) node, result);
484 }
485 #define dom_node_get_text_content(n, r) dom_node_get_text_content( \
486 		(dom_node *) (n), (r))
487 
dom_node_set_text_content(struct dom_node * node,dom_string * content)488 static inline dom_exception dom_node_set_text_content(struct dom_node *node,
489 		dom_string *content)
490 {
491 	return ((dom_node_vtable *) node->vtable)->dom_node_set_text_content(
492 			(dom_node_internal *) node, content);
493 }
494 #define dom_node_set_text_content(n, c) dom_node_set_text_content( \
495 		(dom_node *) (n), (c))
496 
dom_node_is_same(struct dom_node * node,struct dom_node * other,bool * result)497 static inline dom_exception dom_node_is_same(struct dom_node *node,
498 		struct dom_node *other, bool *result)
499 {
500 	return ((dom_node_vtable *) node->vtable)->dom_node_is_same(
501 			(dom_node_internal *) node,
502 			(dom_node_internal *) other,
503 			result);
504 }
505 #define dom_node_is_same(n, o, r) dom_node_is_same((dom_node *) (n), \
506 		(dom_node *) (o), (bool *) (r))
507 
dom_node_lookup_prefix(struct dom_node * node,dom_string * namespace,dom_string ** result)508 static inline dom_exception dom_node_lookup_prefix(struct dom_node *node,
509 		dom_string *namespace, dom_string **result)
510 {
511 	return ((dom_node_vtable *) node->vtable)->dom_node_lookup_prefix(
512 			(dom_node_internal *) node, namespace, result);
513 }
514 #define dom_node_lookup_prefix(n, ns, r) dom_node_lookup_prefix( \
515 		(dom_node *) (n), (ns), (r))
516 
dom_node_is_default_namespace(struct dom_node * node,dom_string * namespace,bool * result)517 static inline dom_exception dom_node_is_default_namespace(
518 		struct dom_node *node, dom_string *namespace,
519 		bool *result)
520 {
521 	return ((dom_node_vtable *) node->vtable)->
522 			dom_node_is_default_namespace(
523 			(dom_node_internal *) node, namespace, result);
524 }
525 #define dom_node_is_default_namespace(n, ns, r) dom_node_is_default_namespace(\
526 		(dom_node *) (n), (ns), (bool *) (r))
527 
dom_node_lookup_namespace(struct dom_node * node,dom_string * prefix,dom_string ** result)528 static inline dom_exception dom_node_lookup_namespace(struct dom_node *node,
529 		dom_string *prefix, dom_string **result)
530 {
531 	return ((dom_node_vtable *) node->vtable)->dom_node_lookup_namespace(
532 			(dom_node_internal *) node, prefix, result);
533 }
534 #define dom_node_lookup_namespace(n, p, r) dom_node_lookup_namespace( \
535 		(dom_node *) (n), (p), (r))
536 
dom_node_is_equal(struct dom_node * node,struct dom_node * other,bool * result)537 static inline dom_exception dom_node_is_equal(struct dom_node *node,
538 		struct dom_node *other, bool *result)
539 {
540 	return ((dom_node_vtable *) node->vtable)->dom_node_is_equal(
541 			(dom_node_internal *) node,
542 			(dom_node_internal *) other,
543 			result);
544 }
545 #define dom_node_is_equal(n, o, r) dom_node_is_equal((dom_node *) (n), \
546 		(dom_node *) (o), (bool *) (r))
547 
dom_node_get_feature(struct dom_node * node,dom_string * feature,dom_string * version,void ** result)548 static inline dom_exception dom_node_get_feature(struct dom_node *node,
549 		dom_string *feature, dom_string *version,
550 		void **result)
551 {
552 	return ((dom_node_vtable *) node->vtable)->dom_node_get_feature(
553 			(dom_node_internal *) node, feature, version, result);
554 }
555 #define dom_node_get_feature(n, f, v, r) dom_node_get_feature( \
556 		(dom_node *) (n), (f), (v), (void **) (r))
557 
dom_node_set_user_data(struct dom_node * node,dom_string * key,void * data,dom_user_data_handler handler,void ** result)558 static inline dom_exception dom_node_set_user_data(struct dom_node *node,
559 		dom_string *key, void *data,
560 		dom_user_data_handler handler, void **result)
561 {
562 	return ((dom_node_vtable *) node->vtable)->dom_node_set_user_data(
563 			(dom_node_internal *) node, key, data, handler,
564 			result);
565 }
566 #define dom_node_set_user_data(n, k, d, h, r) dom_node_set_user_data( \
567 		(dom_node *) (n), (k), (void *) (d), \
568 		(dom_user_data_handler) h, (void **) (r))
569 
dom_node_get_user_data(struct dom_node * node,dom_string * key,void ** result)570 static inline dom_exception dom_node_get_user_data(struct dom_node *node,
571 		dom_string *key, void **result)
572 {
573 	return ((dom_node_vtable *) node->vtable)->dom_node_get_user_data(
574 			(dom_node_internal *) node, key, result);
575 }
576 #define dom_node_get_user_data(n, k, r) dom_node_get_user_data( \
577 		(dom_node *) (n), (k), (void **) (r))
578 
579 #endif
580