summaryrefslogtreecommitdiff
path: root/src/core/pi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/pi.c')
-rw-r--r--src/core/pi.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/src/core/pi.c b/src/core/pi.c
index 754b362..634dc05 100644
--- a/src/core/pi.c
+++ b/src/core/pi.c
@@ -9,6 +9,8 @@
#include "core/node.h"
#include "core/pi.h"
+#include "utils/utils.h"
+
/**
* A DOM processing instruction
*/
@@ -16,6 +18,13 @@ struct dom_processing_instruction {
struct dom_node_internal base; /**< Base node */
};
+static struct dom_node_vtable pi_vtable = {
+ DOM_NODE_VTABLE
+};
+
+static struct dom_node_protect_vtable pi_protect_vtable = {
+ DOM_PI_PROTECT_VTABLE
+};
/**
* Create a processing instruction
*
@@ -30,25 +39,28 @@ struct dom_processing_instruction {
*
* The returned node will already be referenced.
*/
-dom_exception dom_processing_instruction_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_processing_instruction_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_processing_instruction **result)
{
struct dom_processing_instruction *p;
dom_exception err;
/* Allocate the comment node */
- p = dom_document_alloc(doc, NULL,
+ p = _dom_document_alloc(doc, NULL,
sizeof(struct dom_processing_instruction));
if (p == NULL)
return DOM_NO_MEM_ERR;
+
+ p->base.base.vtable = &pi_vtable;
+ p->base.vtable = &pi_protect_vtable;
/* And initialise the node */
- err = dom_node_initialise(&p->base, doc,
+ err = _dom_processing_instruction_initialise(&p->base, doc,
DOM_PROCESSING_INSTRUCTION_NODE,
name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, p, 0);
+ _dom_document_alloc(doc, p, 0);
return err;
}
@@ -65,12 +77,49 @@ dom_exception dom_processing_instruction_create(struct dom_document *doc,
*
* The contents of ::pi will be destroyed and ::pi will be freed.
*/
-void dom_processing_instruction_destroy(struct dom_document *doc,
+void _dom_processing_instruction_destroy(struct dom_document *doc,
struct dom_processing_instruction *pi)
{
/* Finalise base class */
- dom_node_finalise(doc, &pi->base);
+ _dom_processing_instruction_finalise(doc, &pi->base);
/* Free processing instruction */
- dom_document_alloc(doc, pi, 0);
+ _dom_document_alloc(doc, pi, 0);
+}
+
+/*-----------------------------------------------------------------------*/
+
+/* Following comes the protected vtable */
+
+/* The virtual destroy function of this class */
+void _dom_pi_destroy(struct dom_node_internal *node)
+{
+ _dom_processing_instruction_destroy(node->owner,
+ (struct dom_processing_instruction *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_pi_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ struct dom_processing_instruction *a;
+
+ a = _dom_document_alloc(doc, NULL,
+ sizeof(struct dom_processing_instruction));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
}
+
+/* The copy constructor of this class */
+dom_exception _dom_pi_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_node_copy(new, old);
+}
+