diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-26 22:19:48 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-26 22:19:48 +0000 |
commit | 4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b (patch) | |
tree | 07ad40b1cb4623ecd3d1d7df5be0cc5211156fec /src/core/element.c | |
parent | d208ad37e9dea0e3854e70eef40e33716c54aff0 (diff) | |
download | libdom-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/element.c')
-rw-r--r-- | src/core/element.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/core/element.c b/src/core/element.c index 57260cf..11b41a1 100644 --- a/src/core/element.c +++ b/src/core/element.c @@ -7,6 +7,8 @@ #include <dom/core/element.h> +#include "core/document.h" +#include "core/element.h" #include "core/node.h" #include "utils/utils.h" @@ -20,6 +22,49 @@ struct dom_element { }; /** + * Create an element node + * + * \param doc The owning document + * \param name The name of the node to create + * \param result Pointer to location to receive created element + * \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 element will already be referenced. + */ +dom_exception dom_element_create(struct dom_document *doc, + struct dom_string *name, struct dom_element **result) +{ + struct dom_element *el; + dom_exception err; + + /** \todo Sanity check the tag name */ + + /* Allocate the element */ + el = dom_document_alloc(doc, NULL, sizeof(struct dom_element)); + if (el == NULL) + return DOM_NO_MEM_ERR; + + /* Initialise the base class */ + err = dom_node_initialise(&el->base, doc, DOM_ELEMENT_NODE, + name, NULL); + if (err != DOM_NO_ERR) { + dom_document_alloc(doc, el, 0); + return err; + } + + /* Perform our type-specific initialisation */ + el->schema_type_info = NULL; + + *result = el; + + return DOM_NO_ERR; +} + +/** * Retrieve an element's tag name * * \param element The element to retrieve the name from |