From ac42344d05ec326f0063133498ec1c040e924db2 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 5 Dec 2010 23:52:56 +0000 Subject: Remove bootstrap infrastructure, and just make dom_implementation a stub. We only support a single implementation, so all the registry and implementation list stuff is totally unnecesary and overcomplex svn path=/trunk/dom/; revision=11017 --- include/dom/bootstrap/implpriv.h | 246 ----------------------------------- include/dom/bootstrap/implregistry.h | 32 ----- include/dom/bootstrap/init_fini.h | 21 --- include/dom/core/document.h | 8 +- include/dom/core/implementation.h | 10 +- include/dom/core/impllist.h | 27 ---- include/dom/dom.h | 7 +- 7 files changed, 9 insertions(+), 342 deletions(-) delete mode 100644 include/dom/bootstrap/implpriv.h delete mode 100644 include/dom/bootstrap/implregistry.h delete mode 100644 include/dom/bootstrap/init_fini.h delete mode 100644 include/dom/core/impllist.h (limited to 'include') diff --git a/include/dom/bootstrap/implpriv.h b/include/dom/bootstrap/implpriv.h deleted file mode 100644 index 89d3f96..0000000 --- a/include/dom/bootstrap/implpriv.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 John-Mark Bell - */ - -/** \file - * This file defines all the grubby details that implementation backends - * need to know in order to permit themselves to be bootstrapped. - * - * The DOMImplementation and DOMImplementationList implementations also - * include this, as those types are defined here. - * - * The Document implementation includes this as it needs the declaration of - * dom_document_create and dom_document_set_doctype. - * - * The DocumentType implementation includes this as it needs the declaration - * of dom_document_type_create. - * - * No other client should be including this. - */ - -#ifndef dom_bootstrap_implpriv_h_ -#define dom_bootstrap_implpriv_h_ - -#include -#include - -#include -#include -#include -#include - -struct dom_document; -struct dom_document_type; - -/** - * DOM Implementation - */ -struct dom_implementation { - /** - * Test whether a DOM implementation implements a specific feature - * and version - * - * \param impl The DOM implementation to query - * \param feature The feature to test for - * \param version The version number of the feature to test for - * \param result Pointer to location to receive result - * \return DOM_NO_ERR. - */ - dom_exception (*has_feature)(struct dom_implementation *impl, - struct dom_string *feature, - struct dom_string *version, - bool *result); - - /** - * Create a document type node - * - * \param impl The implementation to create the node - * \param qname The qualified name of the document type - * \param public_id The external subset public identifier - * \param system_id The external subset system identifier - * \param doctype Pointer to location to receive result - * \return DOM_NO_ERR on success, - * DOM_INVALID_CHARACTER_ERR if ::qname is invalid, - * DOM_NAMESPACE_ERR if ::qname is malformed, - * DOM_NOT_SUPPORTED_ERR if ::impl does not support the - * feature "XML" and the language - * exposed through Document does - * not support XML namespaces. - * - * Any memory allocated by this call should be allocated using - * the provided memory (de)allocation function. - * - * The doctype will be referenced, so the client need not do this - * explicitly. The client must unref the doctype once it has - * finished with it. - */ - dom_exception (*create_document_type)( - struct dom_implementation *impl, - struct dom_string *qname, - struct dom_string *public_id, - struct dom_string *system_id, - dom_alloc alloc, void *pw, - struct dom_document_type **doctype); - - /** - * Create a document node - * - * \param impl The implementation to create the node - * \param namespace The namespace URI of the document element - * \param qname The qualified name of the document element - * \param doctype The type of document to create - * \param doc Pointer to location to receive result - * \return DOM_NO_ERR on success, - * DOM_INVALID_CHARACTER_ERR if ::qname is invalid, - * DOM_NAMESPACE_ERR if ::qname is malformed, or if - * ::qname has a prefix and - * ::namespace is NULL, or if - * ::qname is NULL and ::namespace - * is non-NULL, or if ::qname has - * a prefix "xml" and ::namespace - * is not - * "http://www.w3.org/XML/1998/namespace", - * or if ::impl does not support - * the "XML" feature and - * ::namespace is non-NULL, - * DOM_WRONG_DOCUMENT_ERR if ::doctype is already being - * used by a document, or if it - * was not created by ::impl, - * DOM_NOT_SUPPORTED_ERR if ::impl does not support the - * feature "XML" and the language - * exposed through Document does - * not support XML namespaces. - * - * Any memory allocated by this call should be allocated using - * the provided memory (de)allocation function. - * - * The document will be referenced, so the client need not do this - * explicitly. The client must unref the document once it has - * finished with it. - */ - dom_exception (*create_document)(struct dom_implementation *impl, - struct dom_string *namespace, - struct dom_string *qname, - struct dom_document_type *doctype, - dom_alloc alloc, void *pw, - dom_events_default_action_fetcher daf, - struct dom_document **doc); - - /** - * Retrieve a specialized object which implements the specified - * feature and version - * - * \param impl The implementation to create the object - * \param feature The requested feature - * \param version The version number of the feature - * \param object Pointer to location to receive object - * \return DOM_NO_ERR. - * - * Any memory allocated by this call should be allocated using - * the provided memory (de)allocation function. - */ - dom_exception (*get_feature)(struct dom_implementation *impl, - struct dom_string *feature, - struct dom_string *version, - void **object); - - /** - * Destroy a DOM implementation instance - * - * \param impl The instance to destroy - */ - void (*destroy)(struct dom_implementation *impl); - - uint32_t refcnt; /**< Reference count */ -}; - - -/** - * An item in a DOM Implementation List - */ -struct dom_implementation_list_item { - struct dom_implementation *impl; /**< Implementation */ - - struct dom_implementation_list_item *next; /**< Next in list */ - struct dom_implementation_list_item *prev; /**< Prev in list */ -}; - -/** - * DOM Implementation List - */ -struct dom_implementation_list { - struct dom_implementation_list_item *head; /**< Head of list */ - - uint32_t refcnt; /**< Reference count */ - - /** - * Destroy a DOM implementation instance - * - * \param impl The instance to destroy - */ - void (*destroy)(struct dom_implementation_list *impllist); -}; - - -/** - * DOM Implementation Source - * - * This is simply a pair of function pointers in a struct. - * - * This is assumed to be statically allocated within the backend. - */ -struct dom_implementation_source { - /** - * Get a DOM implementation that supports the requested features - * - * \param features String containing required features - * \param impl Pointer to location to receive implementation - * \param alloc Function to (de)allocate memory - * \param pw Pointer to client-specific private data - * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion - * - * Any memory allocated by this call should be allocated using - * the provided memory (de)allocation function. The implementation's - * destroy() method will be called once it is no longer used. - * - * The implementation will be referenced, so the client need not - * do this explicitly. The client must unref the implementation - * once it has finished with it. - */ - dom_exception (*get_dom_implementation)( - struct dom_string *features, - struct dom_implementation **impl); - - /** - * Get a list of DOM implementations that support the requested - * features - * - * \param features String containing required features - * \param list Pointer to location to receive list - * \param alloc Function to (de)allocate memory - * \param pw Pointer to client-specific private data - * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion - * - * Any memory allocated by this call should be allocated using - * the provided memory (de)allocation function. The ::alloc/::pw - * pair must be stored on the list object, such that the list - * and its contents may be freed once they are no longer needed. - * - * List nodes reference the implementation objects they point to. - * - * The list will be referenced, so the client need not do this - * explicitly. The client must unref the list once it has finished - * with it. - */ - dom_exception (*get_dom_implementation_list)( - struct dom_string *features, - struct dom_implementation_list **list); -}; - -/* Register a source with the DOM library */ -dom_exception dom_register_source(struct dom_implementation_source *source); - -#endif diff --git a/include/dom/bootstrap/implregistry.h b/include/dom/bootstrap/implregistry.h deleted file mode 100644 index e14738c..0000000 --- a/include/dom/bootstrap/implregistry.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 John-Mark Bell - */ - -#ifndef dom_bootstrap_implregistry_h_ -#define dom_bootstrap_implregistry_h_ - -#include -#include - -struct dom_implementation; -struct dom_implementation_list; -struct dom_string; - -/* Initialise the implementation registry */ -dom_exception dom_implregistry_initialise( - dom_alloc allocator, void *ptr); - -/* Retrieve a DOM implementation from the registry */ -dom_exception dom_implregistry_get_dom_implementation( - struct dom_string *features, - struct dom_implementation **impl); - -/* Get a list of DOM implementations that support the requested features */ -dom_exception dom_implregistry_get_dom_implementation_list( - struct dom_string *features, - struct dom_implementation_list **list); - -#endif diff --git a/include/dom/bootstrap/init_fini.h b/include/dom/bootstrap/init_fini.h deleted file mode 100644 index 5773af6..0000000 --- a/include/dom/bootstrap/init_fini.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 John-Mark Bell - */ - -#ifndef dom_bootstrap_init_fini_h_ -#define dom_bootstrap_init_fini_h_ - -#include -#include - -/* Initialise the DOM library */ -dom_exception dom_initialise(dom_alloc alloc, void *pw); - -/* Finalise the DOM library */ -dom_exception dom_finalise(void); - -#endif - diff --git a/include/dom/core/document.h b/include/dom/core/document.h index 1fe9752..ebe82b8 100644 --- a/include/dom/core/document.h +++ b/include/dom/core/document.h @@ -14,6 +14,7 @@ #include #include +#include #include struct dom_attr; @@ -25,7 +26,6 @@ struct dom_document_fragment; struct dom_document_type; struct dom_element; struct dom_entity_reference; -struct dom_implementation; struct dom_node; struct dom_nodelist; struct dom_processing_instruction; @@ -43,7 +43,7 @@ typedef struct dom_document_vtable { struct dom_document_type **result); dom_exception (*dom_document_get_implementation)( struct dom_document *doc, - struct dom_implementation **result); + 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, @@ -127,13 +127,13 @@ static inline dom_exception dom_document_get_doctype(struct dom_document *doc, (dom_document *) (d), (struct dom_document_type **) (r)) static inline dom_exception dom_document_get_implementation( - struct dom_document *doc, struct dom_implementation **result) + struct dom_document *doc, dom_implementation **result) { return ((dom_document_vtable *) ((dom_node *) doc)->vtable)-> dom_document_get_implementation(doc, result); } #define dom_document_get_implementation(d, r) dom_document_get_implementation(\ - (dom_document *) (d), (struct dom_implementation **) (r)) + (dom_document *) (d), (dom_implementation **) (r)) static inline dom_exception dom_document_get_document_element( struct dom_document *doc, struct dom_element **result) diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h index 7865b10..6fb381c 100644 --- a/include/dom/core/implementation.h +++ b/include/dom/core/implementation.h @@ -18,24 +18,19 @@ struct dom_document; struct dom_document_type; -typedef struct dom_implementation dom_implementation; - -void dom_implementation_ref(struct dom_implementation *impl); -void dom_implementation_unref(struct dom_implementation *impl); +typedef const char *dom_implementation; dom_exception dom_implementation_has_feature( - struct dom_implementation *impl, struct dom_string *feature, struct dom_string *version, bool *result); dom_exception dom_implementation_create_document_type( - struct dom_implementation *impl, struct dom_string *qname, + struct dom_string *qname, struct dom_string *public_id, struct dom_string *system_id, dom_alloc alloc, void *pw, struct dom_document_type **doctype); dom_exception dom_implementation_create_document( - struct dom_implementation *impl, struct dom_string *namespace, struct dom_string *qname, struct dom_document_type *doctype, dom_alloc alloc, void *pw, @@ -43,7 +38,6 @@ dom_exception dom_implementation_create_document( struct dom_document **doc); dom_exception dom_implementation_get_feature( - struct dom_implementation *impl, struct dom_string *feature, struct dom_string *version, void **object); diff --git a/include/dom/core/impllist.h b/include/dom/core/impllist.h deleted file mode 100644 index 8773066..0000000 --- a/include/dom/core/impllist.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 John-Mark Bell - */ - -#ifndef dom_core_impllist_h_ -#define dom_core_impllist_h_ - -#include - -struct dom_implementation; - -typedef struct dom_implementation_list dom_implementation_list; - -void dom_implementation_list_ref(struct dom_implementation_list *list); -void dom_implementation_list_unref(struct dom_implementation_list *list); - -dom_exception dom_implementation_list_get_length( - struct dom_implementation_list *list, unsigned long *length); - -dom_exception dom_implementation_list_item( - struct dom_implementation_list *list, unsigned long index, - struct dom_implementation **impl); - -#endif diff --git a/include/dom/dom.h b/include/dom/dom.h index 3a0a138..d39b85f 100644 --- a/include/dom/dom.h +++ b/include/dom/dom.h @@ -17,9 +17,6 @@ /* Base library headers */ #include -/* DOM bootstrap headers */ -#include - /* DOM core headers */ #include #include @@ -28,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -58,4 +54,7 @@ typedef enum dom_namespace { extern struct dom_string *dom_namespaces[DOM_NAMESPACE_COUNT]; +dom_exception dom_initialise(dom_alloc alloc, void *pw); +dom_exception dom_finalise(void); + #endif -- cgit v1.2.3