From 42ee3a48ecea188ee274f1660612ed5637aaf71f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 5 Aug 2012 10:57:34 +0100 Subject: Obtain the docuemnt object at parser creation time. Remove the unecessary document retrival API --- bindings/hubbub/parser.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'bindings/hubbub/parser.c') diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c index 9423c2c..f0e088e 100644 --- a/bindings/hubbub/parser.c +++ b/bindings/hubbub/parser.c @@ -713,6 +713,7 @@ dom_hubbub_parser_default_script(void *ctx, struct dom_node *node) * \param enc Source charset, or NULL * \param fix_enc Whether fix the encoding * \param enable_script Whether scripting should be enabled. + * \param document Dom document return parameter. * \param msg Informational message function * \param script Script callback function * \param mctx Pointer to client-specific private data @@ -722,6 +723,7 @@ dom_hubbub_parser * dom_hubbub_parser_create(const char *enc, bool fix_enc, bool enable_script, + dom_document **document, dom_msg msg, dom_script script, void *mctx) @@ -731,6 +733,12 @@ dom_hubbub_parser_create(const char *enc, hubbub_error error; dom_exception err; + /* check result parameter */ + if (document == NULL) { + msg(DOM_MSG_CRITICAL, mctx, "Bad document return parameter"); + return NULL; + } + parser = malloc(sizeof(dom_hubbub_parser)); if (parser == NULL) { msg(DOM_MSG_CRITICAL, mctx, "No memory for parsing context"); @@ -795,6 +803,9 @@ dom_hubbub_parser_create(const char *enc, HUBBUB_PARSER_ENABLE_SCRIPTING, ¶ms); + /* set return parameter */ + *document = (dom_document *)dom_node_ref(parser->doc); + return parser; } @@ -883,24 +894,6 @@ dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser) return DOM_HUBBUB_OK; } -/** - * Fetch the Document object from the parser - * - * \param parser The parser object - * \return the created document on success, NULL on failure - */ -dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser) -{ - dom_document *doc = NULL; - - if (parser->complete) { - doc = parser->doc; - parser->doc = NULL; - } - - return doc; -} - /** * Retrieve the encoding * -- cgit v1.2.3