diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2011-12-21 22:18:10 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2011-12-21 22:18:10 +0000 |
commit | 83f3338663c4969eebefd8c2c43bd3fc43587fdd (patch) | |
tree | e48ba69628c5ba793533094e308c1fce9acb21aa /src/core/document.h | |
parent | 4ade8ad1c7b23e6eeeee6681acbdb43fb10cab43 (diff) | |
download | libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.gz libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.bz2 |
Merge branches/jmb/dom-alloc-purge back to trunk
svn path=/trunk/libdom/; revision=13316
Diffstat (limited to 'src/core/document.h')
-rw-r--r-- | src/core/document.h | 202 |
1 files changed, 77 insertions, 125 deletions
diff --git a/src/core/document.h b/src/core/document.h index 911b89f..9ff7368 100644 --- a/src/core/document.h +++ b/src/core/document.h @@ -12,7 +12,16 @@ #include <stddef.h> #include <dom/core/node.h> +#include <dom/core/attr.h> +#include <dom/core/cdatasection.h> +#include <dom/core/comment.h> #include <dom/core/document.h> +#include <dom/core/document_type.h> +#include <dom/core/doc_fragment.h> +#include <dom/core/element.h> +#include <dom/core/entity_ref.h> +#include <dom/core/pi.h> +#include <dom/core/text.h> #include <dom/core/implementation.h> #include "core/string.h" @@ -20,26 +29,10 @@ #include "core/nodelist.h" #include "utils/hashtable.h" -#include "utils/resource_mgr.h" #include "utils/list.h" #include "events/document_event.h" -struct dom_document; -struct dom_namednodemap; -struct dom_node; -struct dom_nodelist; -struct dom_document_type; -struct dom_element; -struct dom_document_fragment; -struct dom_text; -struct dom_comment; -struct dom_cdata_section; -struct dom_processing_instruction; -struct dom_attr; -struct dom_entity_reference; -struct dom_configuration; - struct dom_doc_nl; /** @@ -48,122 +41,102 @@ struct dom_doc_nl; * this. */ struct dom_document { - struct dom_node_internal base; /**< Base node */ + dom_node_internal base; /**< Base node */ struct dom_doc_nl *nodelists; /**< List of active nodelists */ dom_string *uri; /**< The uri of this document */ - dom_alloc alloc; /**< Memory (de)allocation function */ - void *pw; /**< Pointer to client data */ - struct list_entry pending_nodes; /**< The deletion pending list */ - struct lwc_string_s *id_name; /**< The ID attribute's name */ + dom_string *id_name; /**< The ID attribute's name */ dom_document_event_internal dei; /**< The DocumentEVent interface */ }; /* Create a DOM document */ -dom_exception _dom_document_create(dom_alloc alloc, void *pw, - dom_events_default_action_fetcher daf, - struct dom_document **doc); +dom_exception _dom_document_create(dom_events_default_action_fetcher daf, + dom_document **doc); /* Initialise the document */ -dom_exception _dom_document_initialise(struct dom_document *doc, - dom_alloc alloc, void *pw, +dom_exception _dom_document_initialise(dom_document *doc, dom_events_default_action_fetcher daf); /* Finalise the document */ -bool _dom_document_finalise(struct dom_document *doc); - -/* Create a dom_string from C string */ -dom_exception _dom_document_create_string(struct dom_document *doc, - const uint8_t *data, size_t len, dom_string **result); -/* Create a lwc_string from C string */ -dom_exception _dom_document_create_lwcstring(struct dom_document *doc, - const uint8_t *data, size_t len, struct lwc_string_s **result); -/* Unref a lwc_string of this document */ -void _dom_document_unref_lwcstring(struct dom_document *doc, - struct lwc_string_s *str); -/* Create a dom_string from a lwc_string */ -dom_exception _dom_document_create_string_from_lwcstring( - struct dom_document *doc, struct lwc_string_s *str, - dom_string **result); - +bool _dom_document_finalise(dom_document *doc); /* Begin the virtual functions */ -dom_exception _dom_document_get_doctype(struct dom_document *doc, - struct dom_document_type **result); -dom_exception _dom_document_get_implementation(struct dom_document *doc, +dom_exception _dom_document_get_doctype(dom_document *doc, + dom_document_type **result); +dom_exception _dom_document_get_implementation(dom_document *doc, dom_implementation **result); -dom_exception _dom_document_get_document_element(struct dom_document *doc, - struct dom_element **result); -dom_exception _dom_document_create_element(struct dom_document *doc, - dom_string *tag_name, struct dom_element **result); -dom_exception _dom_document_create_document_fragment(struct dom_document *doc, - struct dom_document_fragment **result); -dom_exception _dom_document_create_text_node(struct dom_document *doc, - dom_string *data, struct dom_text **result); -dom_exception _dom_document_create_comment(struct dom_document *doc, - dom_string *data, struct dom_comment **result); -dom_exception _dom_document_create_cdata_section(struct dom_document *doc, - dom_string *data, struct dom_cdata_section **result); +dom_exception _dom_document_get_document_element(dom_document *doc, + dom_element **result); +dom_exception _dom_document_create_element(dom_document *doc, + dom_string *tag_name, dom_element **result); +dom_exception _dom_document_create_document_fragment(dom_document *doc, + dom_document_fragment **result); +dom_exception _dom_document_create_text_node(dom_document *doc, + dom_string *data, dom_text **result); +dom_exception _dom_document_create_comment(dom_document *doc, + dom_string *data, dom_comment **result); +dom_exception _dom_document_create_cdata_section(dom_document *doc, + dom_string *data, dom_cdata_section **result); dom_exception _dom_document_create_processing_instruction( - struct dom_document *doc, dom_string *target, + dom_document *doc, dom_string *target, dom_string *data, - struct dom_processing_instruction **result); -dom_exception _dom_document_create_attribute(struct dom_document *doc, - dom_string *name, struct dom_attr **result); -dom_exception _dom_document_create_entity_reference(struct dom_document *doc, + dom_processing_instruction **result); +dom_exception _dom_document_create_attribute(dom_document *doc, + dom_string *name, dom_attr **result); +dom_exception _dom_document_create_entity_reference(dom_document *doc, dom_string *name, - struct dom_entity_reference **result); -dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc, - dom_string *tagname, struct dom_nodelist **result); -dom_exception _dom_document_import_node(struct dom_document *doc, - struct dom_node *node, bool deep, struct dom_node **result); -dom_exception _dom_document_create_element_ns(struct dom_document *doc, + dom_entity_reference **result); +dom_exception _dom_document_get_elements_by_tag_name(dom_document *doc, + dom_string *tagname, dom_nodelist **result); +dom_exception _dom_document_import_node(dom_document *doc, + dom_node *node, bool deep, dom_node **result); +dom_exception _dom_document_create_element_ns(dom_document *doc, dom_string *namespace, dom_string *qname, - struct dom_element **result); -dom_exception _dom_document_create_attribute_ns(struct dom_document *doc, + dom_element **result); +dom_exception _dom_document_create_attribute_ns(dom_document *doc, dom_string *namespace, dom_string *qname, - struct dom_attr **result); + dom_attr **result); dom_exception _dom_document_get_elements_by_tag_name_ns( - struct dom_document *doc, dom_string *namespace, - dom_string *localname, struct dom_nodelist **result); -dom_exception _dom_document_get_element_by_id(struct dom_document *doc, - dom_string *id, struct dom_element **result); -dom_exception _dom_document_get_input_encoding(struct dom_document *doc, + dom_document *doc, dom_string *namespace, + dom_string *localname, dom_nodelist **result); +dom_exception _dom_document_get_element_by_id(dom_document *doc, + dom_string *id, dom_element **result); +dom_exception _dom_document_get_input_encoding(dom_document *doc, dom_string **result); -dom_exception _dom_document_get_xml_encoding(struct dom_document *doc, +dom_exception _dom_document_get_xml_encoding(dom_document *doc, dom_string **result); -dom_exception _dom_document_get_xml_standalone(struct dom_document *doc, +dom_exception _dom_document_get_xml_standalone(dom_document *doc, bool *result); -dom_exception _dom_document_set_xml_standalone(struct dom_document *doc, +dom_exception _dom_document_set_xml_standalone(dom_document *doc, bool standalone); -dom_exception _dom_document_get_xml_version(struct dom_document *doc, +dom_exception _dom_document_get_xml_version(dom_document *doc, dom_string **result); -dom_exception _dom_document_set_xml_version(struct dom_document *doc, +dom_exception _dom_document_set_xml_version(dom_document *doc, dom_string *version); dom_exception _dom_document_get_strict_error_checking( - struct dom_document *doc, bool *result); + dom_document *doc, bool *result); dom_exception _dom_document_set_strict_error_checking( - struct dom_document *doc, bool strict); -dom_exception _dom_document_get_uri(struct dom_document *doc, + dom_document *doc, bool strict); +dom_exception _dom_document_get_uri(dom_document *doc, dom_string **result); -dom_exception _dom_document_set_uri(struct dom_document *doc, +dom_exception _dom_document_set_uri(dom_document *doc, dom_string *uri); -dom_exception _dom_document_adopt_node(struct dom_document *doc, - struct dom_node *node, struct dom_node **result); -dom_exception _dom_document_get_dom_config(struct dom_document *doc, +dom_exception _dom_document_adopt_node(dom_document *doc, + dom_node *node, dom_node **result); +dom_exception _dom_document_get_dom_config(dom_document *doc, struct dom_configuration **result); -dom_exception _dom_document_normalize(struct dom_document *doc); -dom_exception _dom_document_rename_node(struct dom_document *doc, - struct dom_node *node, +dom_exception _dom_document_normalize(dom_document *doc); +dom_exception _dom_document_rename_node(dom_document *doc, + dom_node *node, dom_string *namespace, dom_string *qname, - struct dom_node **result); + dom_node **result); #define DOM_DOCUMENT_VTABLE \ _dom_document_get_doctype, \ @@ -215,7 +188,7 @@ typedef struct dom_document_protected_vtable dom_document_protected_vtable; static inline dom_exception dom_document_get_base(dom_document *doc, dom_string **base_uri) { - struct dom_node_internal *node = (struct dom_node_internal *) doc; + dom_node_internal *node = (dom_node_internal *) doc; return ((dom_document_protected_vtable *) node->vtable)-> dom_document_get_base(doc, base_uri); } @@ -223,15 +196,12 @@ static inline dom_exception dom_document_get_base(dom_document *doc, (dom_document *) (d), (dom_string **) (b)) /* Following comes the protected vtable */ -void _dom_document_destroy(struct dom_node_internal *node); -dom_exception __dom_document_alloc(struct dom_document *doc, - struct dom_node_internal *n, struct dom_node_internal **ret); -dom_exception _dom_document_copy(struct dom_node_internal *new, - struct dom_node_internal *old); +void _dom_document_destroy(dom_node_internal *node); +dom_exception _dom_document_copy(dom_node_internal *old, + dom_node_internal **copy); #define DOM_DOCUMENT_PROTECT_VTABLE \ _dom_document_destroy, \ - __dom_document_alloc, \ _dom_document_copy @@ -240,40 +210,22 @@ dom_exception _dom_document_copy(struct dom_node_internal *new, /* Try to destroy the document: * When the refcnt is zero and the pending list is empty, we can destroy this * document. */ -void _dom_document_try_destroy(struct dom_document *doc); -/* (De)allocate memory */ -void *_dom_document_alloc(struct dom_document *doc, void *ptr, size_t size); - -/* Get the resource manager inside this document, a resource manager - * is an object which contain the memory allocator/intern string context, - * with which we can allocate strings or intern strings */ -void _dom_document_get_resource_mgr( - struct dom_document *doc, struct dom_resource_mgr *rm); - -/* Get the internal allocator and its pointer */ -void _dom_document_get_allocator(struct dom_document *doc, - dom_alloc *al, void **pw); - -/* Create a hash_table */ -dom_exception _dom_document_create_hashtable(struct dom_document *doc, - size_t chains, dom_hash_func f, struct dom_hash_table **ht); +void _dom_document_try_destroy(dom_document *doc); /* Get a nodelist, creating one if necessary */ -dom_exception _dom_document_get_nodelist(struct dom_document *doc, - nodelist_type type, struct dom_node_internal *root, - struct lwc_string_s *tagname, struct lwc_string_s *namespace, - struct lwc_string_s *localname, struct dom_nodelist **list); +dom_exception _dom_document_get_nodelist(dom_document *doc, + nodelist_type type, dom_node_internal *root, + dom_string *tagname, dom_string *namespace, + dom_string *localname, dom_nodelist **list); /* Remove a nodelist */ -void _dom_document_remove_nodelist(struct dom_document *doc, - struct dom_nodelist *list); +void _dom_document_remove_nodelist(dom_document *doc, dom_nodelist *list); /* Find element with certain ID in the subtree rooted at root */ dom_exception _dom_find_element_by_id(dom_node_internal *root, - struct lwc_string_s *id, struct dom_element **result); + dom_string *id, dom_element **result); /* Set the ID attribute name of this document */ -void _dom_document_set_id_name(struct dom_document *doc, - struct lwc_string_s *name); +void _dom_document_set_id_name(dom_document *doc, dom_string *name); #define _dom_document_get_id_name(d) (d->id_name) |