summaryrefslogtreecommitdiff
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
commit80fefa4a957812b4357b2e65fa0776ee8c93b4ae (patch)
tree358be35a12bf12ab079e21a4a39af9e255084c24
parent322bd58c4e0d68abe817cc4036e3ff7acb51e152 (diff)
downloadlibdom-80fefa4a957812b4357b2e65fa0776ee8c93b4ae.tar.gz
libdom-80fefa4a957812b4357b2e65fa0776ee8c93b4ae.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
-rw-r--r--src/core/document.c8
-rw-r--r--src/core/document.h4
-rw-r--r--src/core/element.c14
-rw-r--r--src/core/element.h3
-rw-r--r--src/core/namednodemap.c43
-rw-r--r--src/core/namednodemap.h4
-rw-r--r--src/core/nodelist.c8
-rw-r--r--src/core/nodelist.h8
8 files changed, 49 insertions, 43 deletions
diff --git a/src/core/document.c b/src/core/document.c
index 8cfcfd0..355d7f8 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -510,7 +510,7 @@ dom_exception _dom_document_create_entity_reference(struct dom_document *doc,
dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc,
struct dom_string *tagname, struct dom_nodelist **result)
{
- return dom_document_get_nodelist(doc, (struct dom_node *) doc,
+ return dom_document_get_nodelist(doc, (struct dom_node_internal *) doc,
tagname, NULL, NULL, result);
}
@@ -679,7 +679,7 @@ dom_exception _dom_document_get_elements_by_tag_name_ns(
struct dom_document *doc, struct dom_string *namespace,
struct dom_string *localname, struct dom_nodelist **result)
{
- return dom_document_get_nodelist(doc, (struct dom_node *) doc,
+ return dom_document_get_nodelist(doc, (struct dom_node_internal *) doc,
NULL, namespace, localname, result);
}
@@ -1049,7 +1049,7 @@ void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
* finished with it.
*/
dom_exception dom_document_get_nodelist(struct dom_document *doc,
- struct dom_node *root, struct dom_string *tagname,
+ struct dom_node_internal *root, struct dom_string *tagname,
struct dom_string *namespace, struct dom_string *localname,
struct dom_nodelist **list)
{
@@ -1148,7 +1148,7 @@ void dom_document_remove_nodelist(struct dom_document *doc,
* finished with it.
*/
dom_exception dom_document_get_namednodemap(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_doc_nnm *m;
diff --git a/src/core/document.h b/src/core/document.h
index 874bc22..f05b9e0 100644
--- a/src/core/document.h
+++ b/src/core/document.h
@@ -171,7 +171,7 @@ void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size);
/* Get a nodelist, creating one if necessary */
dom_exception dom_document_get_nodelist(struct dom_document *doc,
- struct dom_node *root, struct dom_string *tagname,
+ struct dom_node_internal *root, struct dom_string *tagname,
struct dom_string *namespace, struct dom_string *localname,
struct dom_nodelist **list);
/* Remove a nodelist */
@@ -180,7 +180,7 @@ void dom_document_remove_nodelist(struct dom_document *doc,
/* Get a namednodemap, creating one if necessary */
dom_exception dom_document_get_namednodemap(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);
/* Remove a namednodemap */
void dom_document_remove_namednodemap(struct dom_document *doc,
diff --git a/src/core/element.c b/src/core/element.c
index 98feb18..80d547e 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -548,7 +548,8 @@ dom_exception _dom_element_get_elements_by_tag_name(
struct dom_nodelist **result)
{
return dom_document_get_nodelist(element->base.owner,
- (struct dom_node *) element, name, NULL, NULL, result);
+ (struct dom_node_internal *) element, name, NULL,
+ NULL, result);
}
/**
@@ -955,7 +956,7 @@ dom_exception _dom_element_get_elements_by_tag_name_ns(
/** \todo ensure XML feature is supported */
return dom_document_get_nodelist(element->base.owner,
- (struct dom_node *) element, NULL,
+ (struct dom_node_internal *) element, NULL,
namespace, localname, result);
}
@@ -1125,8 +1126,8 @@ dom_exception dom_element_get_attributes(struct dom_element *element,
struct dom_namednodemap **result)
{
return dom_document_get_namednodemap(element->base.owner,
- (struct dom_node *) element, DOM_ATTRIBUTE_NODE,
- result);
+ (struct dom_node_internal *) element,
+ DOM_ATTRIBUTE_NODE, result);
}
/**
@@ -1150,8 +1151,9 @@ dom_exception dom_element_has_attributes(struct dom_element *element,
* \param element The element to retrieve the first attribute from
* \return Pointer to first attribute, or NULL if none.
*/
-struct dom_node *dom_element_get_first_attribute(struct dom_element *element)
+struct dom_node_internal *dom_element_get_first_attribute(
+ struct dom_element *element)
{
- return (struct dom_node *) element->attributes;
+ return (struct dom_node_internal *) element->attributes;
}
diff --git a/src/core/element.h b/src/core/element.h
index 5b3d26c..a05b8c0 100644
--- a/src/core/element.h
+++ b/src/core/element.h
@@ -50,7 +50,8 @@ dom_exception dom_element_get_attributes(struct dom_element *element,
dom_exception dom_element_has_attributes(struct dom_element *element,
bool *result);
-struct dom_node *dom_element_get_first_attribute(struct dom_element *element);
+struct dom_node_internal *dom_element_get_first_attribute(
+ struct dom_element *element);
/* The virtual functions of dom_element */
dom_exception _dom_element_get_tag_name(struct dom_element *element,
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;
diff --git a/src/core/namednodemap.h b/src/core/namednodemap.h
index 99b1a35..830ab6d 100644
--- a/src/core/namednodemap.h
+++ b/src/core/namednodemap.h
@@ -20,12 +20,12 @@ struct dom_string;
/* Create a namednodemap */
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);
/* Match a namednodemap instance against a set of creation parameters */
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);
#endif
diff --git a/src/core/nodelist.c b/src/core/nodelist.c
index 4377426..bcb634a 100644
--- a/src/core/nodelist.c
+++ b/src/core/nodelist.c
@@ -66,7 +66,7 @@ struct dom_nodelist {
* do so explicitly. The client must unref the list once finished with it.
*/
dom_exception dom_nodelist_create(struct dom_document *doc,
- struct dom_node *root, struct dom_string *tagname,
+ struct dom_node_internal *root, struct dom_string *tagname,
struct dom_string *namespace, struct dom_string *localname,
struct dom_nodelist **list)
{
@@ -316,9 +316,9 @@ dom_exception dom_nodelist_item(struct dom_nodelist *list,
* \param localname Local part of nodes in list (or NULL)
* \return true if list matches, false otherwise
*/
-bool dom_nodelist_match(struct dom_nodelist *list, struct dom_node *root,
- struct dom_string *tagname, struct dom_string *namespace,
- struct dom_string *localname)
+bool dom_nodelist_match(struct dom_nodelist *list,
+ struct dom_node_internal *root, struct dom_string *tagname,
+ struct dom_string *namespace, struct dom_string *localname)
{
if (list->root != root)
return false;
diff --git a/src/core/nodelist.h b/src/core/nodelist.h
index e80c0ba..9629d03 100644
--- a/src/core/nodelist.h
+++ b/src/core/nodelist.h
@@ -19,13 +19,13 @@ struct dom_string;
/* Create a nodelist */
dom_exception dom_nodelist_create(struct dom_document *doc,
- struct dom_node *root, struct dom_string *tagname,
+ struct dom_node_internal *root, struct dom_string *tagname,
struct dom_string *namespace, struct dom_string *localname,
struct dom_nodelist **list);
/* Match a nodelist instance against a set of nodelist creation parameters */
-bool dom_nodelist_match(struct dom_nodelist *list, struct dom_node *root,
- struct dom_string *tagname, struct dom_string *namespace,
- struct dom_string *localname);
+bool dom_nodelist_match(struct dom_nodelist *list,
+ struct dom_node_internal *root, struct dom_string *tagname,
+ struct dom_string *namespace, struct dom_string *localname);
#endif