summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorBo Yang <struggleyb.nku@gmail.com>2009-03-19 12:24:41 +0000
committerBo Yang <struggleyb.nku@gmail.com>2009-03-19 12:24:41 +0000
commit2d2b525d83419bffbd7dc32c5a046f6eb4d2943a (patch)
tree7bdb22df848030e364ef345550c06c980ae6bfed /src/core
parentf05c3c710a443641aab66cb46a4333cdc2683d03 (diff)
downloadlibdom-2d2b525d83419bffbd7dc32c5a046f6eb4d2943a.tar.gz
libdom-2d2b525d83419bffbd7dc32c5a046f6eb4d2943a.tar.bz2
Convert DocumentType to use vtable structure.
svn path=/trunk/dom/; revision=6804
Diffstat (limited to 'src/core')
-rw-r--r--src/core/document_type.c30
-rw-r--r--src/core/document_type.h29
2 files changed, 50 insertions, 9 deletions
diff --git a/src/core/document_type.c b/src/core/document_type.c
index 73a8383..c5660bc 100644
--- a/src/core/document_type.c
+++ b/src/core/document_type.c
@@ -18,7 +18,7 @@
* DOM DocumentType node
*/
struct dom_document_type {
- struct dom_node base; /**< Base node */
+ struct dom_node_internal base; /**< Base node */
/** \todo other members */
struct dom_string *public_id; /**< Doctype public ID */
@@ -28,6 +28,13 @@ struct dom_document_type {
void *pw; /**< Pointer to private data */
};
+static struct dom_document_type_vtable document_type_vtable = {
+ {
+ DOM_NODE_VTABLE
+ },
+ DOM_DOCUMENT_TYPE_VTABLE
+};
+
/**
* Create a document type node
*
@@ -63,6 +70,10 @@ dom_exception dom_document_type_create(struct dom_string *qname,
return err;
}
+ /* Initialize the vtable */
+ result->base.base.vtable = &document_type_vtable;
+ result->base.destroy = &dom_document_type_destroy;
+
/* Get public and system IDs */
dom_string_ref(public_id);
result->public_id = public_id;
@@ -86,8 +97,11 @@ dom_exception dom_document_type_create(struct dom_string *qname,
*
* The contents of ::doctype will be destroyed and ::doctype will be freed.
*/
-void dom_document_type_destroy(struct dom_document_type *doctype)
+void dom_document_type_destroy(struct dom_node_internal *doctypenode)
{
+ struct dom_document_type *doctype =
+ (struct dom_document_type *)doctypenode;
+
/* Finish with public and system IDs */
dom_string_unref(doctype->system_id);
dom_string_unref(doctype->public_id);
@@ -110,7 +124,7 @@ void dom_document_type_destroy(struct dom_document_type *doctype)
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_document_type_get_name(struct dom_document_type *doc_type,
+dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
struct dom_string **result)
{
UNUSED(doc_type);
@@ -130,7 +144,7 @@ dom_exception dom_document_type_get_name(struct dom_document_type *doc_type,
* the responsibility of the caller to unref the map once it has
* finished with it.
*/
-dom_exception dom_document_type_get_entities(
+dom_exception _dom_document_type_get_entities(
struct dom_document_type *doc_type,
struct dom_namednodemap **result)
{
@@ -151,7 +165,7 @@ dom_exception dom_document_type_get_entities(
* the responsibility of the caller to unref the map once it has
* finished with it.
*/
-dom_exception dom_document_type_get_notations(
+dom_exception _dom_document_type_get_notations(
struct dom_document_type *doc_type,
struct dom_namednodemap **result)
{
@@ -172,7 +186,7 @@ dom_exception dom_document_type_get_notations(
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_document_type_get_public_id(
+dom_exception _dom_document_type_get_public_id(
struct dom_document_type *doc_type,
struct dom_string **result)
{
@@ -193,7 +207,7 @@ dom_exception dom_document_type_get_public_id(
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_document_type_get_system_id(
+dom_exception _dom_document_type_get_system_id(
struct dom_document_type *doc_type,
struct dom_string **result)
{
@@ -214,7 +228,7 @@ dom_exception dom_document_type_get_system_id(
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_document_type_get_internal_subset(
+dom_exception _dom_document_type_get_internal_subset(
struct dom_document_type *doc_type,
struct dom_string **result)
{
diff --git a/src/core/document_type.h b/src/core/document_type.h
index 266a1b6..e38cf52 100644
--- a/src/core/document_type.h
+++ b/src/core/document_type.h
@@ -11,7 +11,34 @@
struct dom_document_type;
/* Destroy a document type */
-void dom_document_type_destroy(struct dom_document_type *doctype);
+void dom_document_type_destroy(struct dom_node_internal *doctypenode);
+
+/* The virtual functions of DocumentType */
+dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception _dom_document_type_get_entities(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result);
+dom_exception _dom_document_type_get_notations(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result);
+dom_exception _dom_document_type_get_public_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception _dom_document_type_get_system_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception _dom_document_type_get_internal_subset(
+ struct dom_document_type *doc_type,
+ struct dom_string **result);
+
+#define DOM_DOCUMENT_TYPE_VTABLE \
+ _dom_document_type_get_name, \
+ _dom_document_type_get_entities, \
+ _dom_document_type_get_notations, \
+ _dom_document_type_get_public_id, \
+ _dom_document_type_get_system_id, \
+ _dom_document_type_get_internal_subset
#endif