summaryrefslogtreecommitdiff
path: root/src/core/namednodemap.c
diff options
context:
space:
mode:
authorBo Yang <struggleyb.nku@gmail.com>2009-03-23 03:16:17 +0000
committerBo Yang <struggleyb.nku@gmail.com>2009-03-23 03:16:17 +0000
commitf2747d64aed7059b8520401f7d3b04da91212ac1 (patch)
tree358be35a12bf12ab079e21a4a39af9e255084c24 /src/core/namednodemap.c
parent03aab37a0e8fc73eb7b92a64920136c4db5f42a9 (diff)
downloadlibdom-f2747d64aed7059b8520401f7d3b04da91212ac1.tar.gz
libdom-f2747d64aed7059b8520401f7d3b04da91212ac1.tar.bz2
Modify NamedNodeMap, note that there is no vtable for this type because it is not in the DOM inherit hierarchy. And the internal API used between different DOM parts should use struct dom_node_internal instead of struct dom_node.
svn path=/trunk/dom/; revision=6821
Diffstat (limited to 'src/core/namednodemap.c')
-rw-r--r--src/core/namednodemap.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/core/namednodemap.c b/src/core/namednodemap.c
index 939ef46..98fa5f9 100644
--- a/src/core/namednodemap.c
+++ b/src/core/namednodemap.c
@@ -22,7 +22,7 @@
struct dom_namednodemap {
struct dom_document *owner; /**< Owning document */
- struct dom_node *head; /**< Start of item list */
+ struct dom_node_internal *head; /**< Start of item list */
dom_node_type type; /**< Type of items in map */
@@ -50,7 +50,7 @@ struct dom_namednodemap {
* finished with it.
*/
dom_exception dom_namednodemap_create(struct dom_document *doc,
- struct dom_node *head, dom_node_type type,
+ struct dom_node_internal *head, dom_node_type type,
struct dom_namednodemap **map)
{
struct dom_namednodemap *m;
@@ -95,7 +95,8 @@ void dom_namednodemap_ref(struct dom_namednodemap *map)
void dom_namednodemap_unref(struct dom_namednodemap *map)
{
if (--map->refcnt == 0) {
- struct dom_node *owner = (struct dom_node *) map->owner;
+ struct dom_node_internal *owner =
+ (struct dom_node_internal *) map->owner;
dom_node_unref(map->head);
@@ -122,7 +123,7 @@ void dom_namednodemap_unref(struct dom_namednodemap *map)
dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map,
unsigned long *length)
{
- struct dom_node *cur;
+ struct dom_node_internal *cur;
unsigned long len = 0;
switch (map->type) {
@@ -161,7 +162,7 @@ dom_exception dom_namednodemap_get_length(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 *cur;
+ struct dom_node_internal *cur;
switch (map->type) {
case DOM_ATTRIBUTE_NODE:
@@ -185,7 +186,7 @@ dom_exception dom_namednodemap_get_named_item(struct dom_namednodemap *map,
if (cur != NULL) {
dom_node_ref(cur);
}
- *node = cur;
+ *node = (struct dom_node *) cur;
return DOM_NO_ERR;
}
@@ -218,9 +219,10 @@ dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map,
struct dom_node *arg, struct dom_node **node)
{
dom_exception err;
+ struct dom_node_internal *n = (struct dom_node_internal *) arg;
/* Ensure arg and map belong to the same document */
- if (arg->owner != map->owner)
+ if (n->owner != map->owner)
return DOM_WRONG_DOCUMENT_ERR;
/* Ensure map is writable */
@@ -228,12 +230,12 @@ dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map,
return DOM_NO_MODIFICATION_ALLOWED_ERR;
/* Ensure arg isn't attached to another element */
- if (arg->type == DOM_ATTRIBUTE_NODE && arg->parent != NULL &&
- arg->parent != map->head)
+ if (n->type == DOM_ATTRIBUTE_NODE && n->parent != NULL &&
+ n->parent != map->head)
return DOM_INUSE_ATTRIBUTE_ERR;
/* Ensure arg is permitted in the map */
- if (arg->type != map->type)
+ if (n->type != map->type)
return DOM_HIERARCHY_REQUEST_ERR;
/* Now delegate to the container-specific function.
@@ -333,7 +335,7 @@ dom_exception dom_namednodemap_remove_named_item(
dom_exception dom_namednodemap_item(struct dom_namednodemap *map,
unsigned long index, struct dom_node **node)
{
- struct dom_node *cur;
+ struct dom_node_internal *cur;
unsigned long count = 0;
switch (map->type) {
@@ -360,7 +362,7 @@ dom_exception dom_namednodemap_item(struct dom_namednodemap *map,
if (cur != NULL) {
dom_node_ref(cur);
}
- *node = cur;
+ *node = (struct dom_node *) cur;
return DOM_NO_ERR;
}
@@ -385,7 +387,7 @@ dom_exception dom_namednodemap_get_named_item_ns(
struct dom_namednodemap *map, struct dom_string *namespace,
struct dom_string *localname, struct dom_node **node)
{
- struct dom_node *cur;
+ struct dom_node_internal *cur;
/** \todo ensure XML feature is supported */
@@ -414,7 +416,7 @@ dom_exception dom_namednodemap_get_named_item_ns(
if (cur != NULL) {
dom_node_ref(cur);
}
- *node = cur;
+ *node = (struct dom_node *) cur;
return DOM_NO_ERR;
}
@@ -453,11 +455,12 @@ dom_exception dom_namednodemap_set_named_item_ns(
struct dom_node **node)
{
dom_exception err;
+ struct dom_node_internal *n = (struct dom_node_internal *) arg;
/** \todo ensure XML feature is supported */
/* Ensure arg and map belong to the same document */
- if (arg->owner != map->owner)
+ if (n->owner != map->owner)
return DOM_WRONG_DOCUMENT_ERR;
/* Ensure map is writable */
@@ -465,12 +468,12 @@ dom_exception dom_namednodemap_set_named_item_ns(
return DOM_NO_MODIFICATION_ALLOWED_ERR;
/* Ensure arg isn't attached to another element */
- if (arg->type == DOM_ATTRIBUTE_NODE && arg->parent != NULL &&
- arg->parent != map->head)
+ if (n->type == DOM_ATTRIBUTE_NODE && n->parent != NULL &&
+ n->parent != map->head)
return DOM_INUSE_ATTRIBUTE_ERR;
/* Ensure arg is permitted in the map */
- if (arg->type != map->type)
+ if (n->type != map->type)
return DOM_HIERARCHY_REQUEST_ERR;
/* Now delegate to the container-specific function.
@@ -547,7 +550,7 @@ dom_exception dom_namednodemap_remove_named_item_ns(
}
}
break;
- case DOM_NOTATION_NODE:
+case DOM_NOTATION_NODE:
case DOM_ENTITY_NODE:
/** \todo handle notation and entity nodes */
default:
@@ -569,7 +572,7 @@ dom_exception dom_namednodemap_remove_named_item_ns(
* \return true if list matches, false otherwise
*/
bool dom_namednodemap_match(struct dom_namednodemap *map,
- struct dom_node *head, dom_node_type type)
+ struct dom_node_internal *head, dom_node_type type)
{
if (map->head == head && map->type == type)
return true;