summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dom/core/document_type.h97
-rw-r--r--src/core/document_type.c30
-rw-r--r--src/core/document_type.h29
3 files changed, 134 insertions, 22 deletions
diff --git a/include/dom/core/document_type.h b/include/dom/core/document_type.h
index 66b6407..3a0eb5e 100644
--- a/include/dom/core/document_type.h
+++ b/include/dom/core/document_type.h
@@ -10,27 +10,98 @@
#define dom_core_document_type_h_
#include <dom/core/exceptions.h>
+#include <dom/core/node.h>
-struct dom_document_type;
struct dom_namednodemap;
struct dom_string;
-dom_exception dom_document_type_get_name(struct dom_document_type *doc_type,
- struct dom_string **result);
-dom_exception dom_document_type_get_entities(
+typedef struct dom_document_type dom_document_type;
+/* The Dom DocumentType vtable */
+typedef struct dom_document_type_vtable {
+ struct dom_node_vtable base;
+
+ 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);
+} dom_document_type_vtable;
+
+static inline dom_exception dom_document_type_get_name(
+ struct dom_document_type *doc_type, struct dom_string **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_name(doc_type, result);
+}
+#define dom_document_type_get_name(dt, r) dom_document_type_get_name( \
+ (dom_document_type *) (dt), (struct dom_string **) (r))
+
+static inline 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_namednodemap **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_entities(doc_type, result);
+}
+#define dom_document_type_get_entities(dt, r) dom_document_type_get_entities( \
+ (dom_document_type *) (dt), (struct dom_string **) (r))
+
+static inline 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_namednodemap **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_notations(doc_type, result);
+}
+#define dom_document_type_get_notations(dt, r) dom_document_type_get_notations(\
+ (dom_document_type *) (dt), (struct dom_string **) (r))
+
+static inline 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_string **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_public_id(doc_type, result);
+}
+#define dom_document_type_get_public_id(dt, r) \
+ dom_document_type_get_public_id((dom_document_type *) (dt), \
+ (struct dom_string **) (r))
+
+static inline 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_string **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_system_id(doc_type, result);
+}
+#define dom_document_type_get_system_id(dt, r) \
+ dom_document_type_get_system_id((dom_document_type *) (dt), \
+ (struct dom_string **) (r))
+
+static inline dom_exception dom_document_type_get_internal_subset(
struct dom_document_type *doc_type,
- struct dom_string **result);
+ struct dom_string **result)
+{
+ return ((dom_document_type_vtable *) ((dom_node *) (doc_type))->vtable)
+ ->dom_document_type_get_internal_subset(doc_type,
+ result);
+}
+#define dom_document_type_get_internal_subset(dt, r) \
+ dom_document_type_get_internal_subset( \
+ (dom_document_type *) (dt), (struct dom_string **) (r))
+
#endif
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