From 2de93d957296913fc8e13d7deafaf7c61dfcf265 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Wed, 29 Apr 2009 12:44:35 +0000 Subject: Make dom_namednodemap and dom_nodelist more usable through macroes. Note, it is the partly-completed testcase that find this problem. Our DOMTS is on its way. svn path=/trunk/dom/; revision=7365 --- include/dom/core/namednodemap.h | 53 +++++++++++++++++++++++++++++++++++------ include/dom/core/nodelist.h | 5 +++- src/core/namednodemap.c | 14 +++++------ src/core/nodelist.c | 2 +- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/include/dom/core/namednodemap.h b/include/dom/core/namednodemap.h index 77c4cc3..fd2b754 100644 --- a/include/dom/core/namednodemap.h +++ b/include/dom/core/namednodemap.h @@ -21,24 +21,63 @@ void dom_namednodemap_unref(struct dom_namednodemap *map); dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map, unsigned long *length); -dom_exception dom_namednodemap_get_named_item(struct dom_namednodemap *map, +dom_exception _dom_namednodemap_get_named_item(struct dom_namednodemap *map, struct dom_string *name, struct dom_node **node); -dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map, + +#define dom_namednodemap_get_named_item(m, n, r) \ + _dom_namednodemap_get_named_item((dom_namednodemap *) (m), \ + (dom_string *) (n), (dom_node **) (r)) + + +dom_exception _dom_namednodemap_set_named_item(struct dom_namednodemap *map, struct dom_node *arg, struct dom_node **node); -dom_exception dom_namednodemap_remove_named_item( + +#define dom_namednodemap_set_named_item(m, a, n) \ + _dom_namednodemap_set_named_item((dom_namednodemap *) (m), \ + (dom_node *) (a), (dom_node **) (n)) + + +dom_exception _dom_namednodemap_remove_named_item( struct dom_namednodemap *map, struct dom_string *name, struct dom_node **node); -dom_exception dom_namednodemap_item(struct dom_namednodemap *map, + +#define dom_namednodemap_remove_named_item(m, n, r) \ + _dom_namednodemap_remove_named_item((dom_namednodemap *) (m), \ + (dom_string *) (n), (dom_node **) (n)) + + +dom_exception _dom_namednodemap_item(struct dom_namednodemap *map, unsigned long index, struct dom_node **node); -dom_exception dom_namednodemap_get_named_item_ns( +#define dom_namednodemap_item(m, i, n) _dom_namednodemap_item( \ + (dom_namednodemap *) (m), (unsigned long) (i), \ + (dom_node **) (n)) + + +dom_exception _dom_namednodemap_get_named_item_ns( struct dom_namednodemap *map, struct dom_string *namespace, struct dom_string *localname, struct dom_node **node); -dom_exception dom_namednodemap_set_named_item_ns( + +#define dom_namednodemap_get_named_item_ns(m, n, l, r) \ + _dom_namednodemap_get_named_item_ns((dom_namednodemap *) (m), \ + (dom_string *) (n), (dom_string *) (l), (dom_node **) (n)) + + +dom_exception _dom_namednodemap_set_named_item_ns( struct dom_namednodemap *map, struct dom_node *arg, struct dom_node **node); -dom_exception dom_namednodemap_remove_named_item_ns( + +#define dom_namednodemap_set_named_item_ns(m, a, n) \ + _dom_namednodemap_set_named_item_ns((dom_namednodemap *) (m), \ + (dom_node *) (a), (dom_node **) (n)) + + +dom_exception _dom_namednodemap_remove_named_item_ns( struct dom_namednodemap *map, struct dom_string *namespace, struct dom_string *localname, struct dom_node **node); +#define dom_namednodemap_remove_named_item_ns(m, n, l, r) \ + _dom_namednodemap_remove_named_item_ns((dom_namednodemap *) (m), \ + (dom_string *) (n), (dom_string *) (l), (dom_node **) (r)) + #endif diff --git a/include/dom/core/nodelist.h b/include/dom/core/nodelist.h index d3b0df9..2aad313 100644 --- a/include/dom/core/nodelist.h +++ b/include/dom/core/nodelist.h @@ -19,7 +19,10 @@ void dom_nodelist_unref(struct dom_nodelist *list); dom_exception dom_nodelist_get_length(struct dom_nodelist *list, unsigned long *length); -dom_exception dom_nodelist_item(struct dom_nodelist *list, +dom_exception _dom_nodelist_item(struct dom_nodelist *list, unsigned long index, struct dom_node **node); +#define dom_nodelist_item(l, i, n) _dom_nodelist_item((dom_nodelist *) (l), \ + (unsigned long) (i), (dom_node **) (n)) + #endif diff --git a/src/core/namednodemap.c b/src/core/namednodemap.c index 98fa5f9..dab6bbb 100644 --- a/src/core/namednodemap.c +++ b/src/core/namednodemap.c @@ -159,7 +159,7 @@ dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map, * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_get_named_item(struct dom_namednodemap *map, +dom_exception _dom_namednodemap_get_named_item(struct dom_namednodemap *map, struct dom_string *name, struct dom_node **node) { struct dom_node_internal *cur; @@ -215,7 +215,7 @@ dom_exception dom_namednodemap_get_named_item(struct dom_namednodemap *map, * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map, +dom_exception _dom_namednodemap_set_named_item(struct dom_namednodemap *map, struct dom_node *arg, struct dom_node **node) { dom_exception err; @@ -274,7 +274,7 @@ dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map, * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_remove_named_item( +dom_exception _dom_namednodemap_remove_named_item( struct dom_namednodemap *map, struct dom_string *name, struct dom_node **node) { @@ -332,7 +332,7 @@ dom_exception dom_namednodemap_remove_named_item( * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_item(struct dom_namednodemap *map, +dom_exception _dom_namednodemap_item(struct dom_namednodemap *map, unsigned long index, struct dom_node **node) { struct dom_node_internal *cur; @@ -383,7 +383,7 @@ dom_exception dom_namednodemap_item(struct dom_namednodemap *map, * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_get_named_item_ns( +dom_exception _dom_namednodemap_get_named_item_ns( struct dom_namednodemap *map, struct dom_string *namespace, struct dom_string *localname, struct dom_node **node) { @@ -450,7 +450,7 @@ dom_exception dom_namednodemap_get_named_item_ns( * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_set_named_item_ns( +dom_exception _dom_namednodemap_set_named_item_ns( struct dom_namednodemap *map, struct dom_node *arg, struct dom_node **node) { @@ -517,7 +517,7 @@ dom_exception dom_namednodemap_set_named_item_ns( * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_namednodemap_remove_named_item_ns( +dom_exception _dom_namednodemap_remove_named_item_ns( struct dom_namednodemap *map, struct dom_string *namespace, struct dom_string *localname, struct dom_node **node) { diff --git a/src/core/nodelist.c b/src/core/nodelist.c index c19b2eb..16534b6 100644 --- a/src/core/nodelist.c +++ b/src/core/nodelist.c @@ -238,7 +238,7 @@ dom_exception dom_nodelist_get_length(struct dom_nodelist *list, * The returned node will have had its reference count increased. The client * should unref the node once it has finished with it. */ -dom_exception dom_nodelist_item(struct dom_nodelist *list, +dom_exception _dom_nodelist_item(struct dom_nodelist *list, unsigned long index, struct dom_node **node) { struct dom_node_internal *cur = list->root->first_child; -- cgit v1.2.3