summaryrefslogtreecommitdiff
path: root/src/core/attr.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 22:19:48 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 22:19:48 +0000
commit4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b (patch)
tree07ad40b1cb4623ecd3d1d7df5be0cc5211156fec /src/core/attr.c
parentd208ad37e9dea0e3854e70eef40e33716c54aff0 (diff)
downloadlibdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.gz
libdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.bz2
Implement type-specific node constructors and veneer the appropriate Document APIs onto them.
svn path=/trunk/dom/; revision=3463
Diffstat (limited to 'src/core/attr.c')
-rw-r--r--src/core/attr.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/core/attr.c b/src/core/attr.c
index bcdc0ce..ed20c93 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -9,6 +9,8 @@
#include <dom/core/attr.h>
+#include "core/attr.h"
+#include "core/document.h"
#include "core/node.h"
#include "utils/utils.h"
@@ -32,6 +34,52 @@ struct dom_attr {
};
/**
+ * Create an attribute node
+ *
+ * \param doc The owning document
+ * \param name The name of the node to create
+ * \param result Pointer to location to receive created attribute
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::name is invalid,
+ * DOM_NO_MEM_ERR on memory exhaustion.
+ *
+ * ::doc and ::name will have their reference counts increased.
+ *
+ * The returned attribute will already be referenced.
+ */
+dom_exception dom_attr_create(struct dom_document *doc,
+ struct dom_string *name, struct dom_attr **result)
+{
+ struct dom_attr *a;
+ dom_exception err;
+
+ /** \todo Sanity check the attribute name */
+
+ /* Allocate the element */
+ a = dom_document_alloc(doc, NULL, sizeof(struct dom_attr));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Initialise the base class */
+ err = dom_node_initialise(&a->base, doc, DOM_ATTRIBUTE_NODE,
+ name, NULL);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(doc, a, 0);
+ return err;
+ }
+
+ /* Perform our type-specific initialisation */
+ a->specified = false;
+ a->owner = NULL;
+ a->schema_type_info = NULL;
+ a->is_id = false;
+
+ *result = a;
+
+ return DOM_NO_ERR;
+}
+
+/**
* Retrieve an attribute's name
*
* \param attr Attribute to retrieve name from