summaryrefslogtreecommitdiff
path: root/bindings/hubbub/parser.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-08-05 10:57:34 +0100
committerVincent Sanders <vince@kyllikki.org>2012-08-05 10:57:34 +0100
commit2759bec06573d9ac3c32ef2d310492edc8a1b103 (patch)
tree83f2f60fba3b78ddabe1cd25a6ee6bb51faf836b /bindings/hubbub/parser.c
parent6aedb99d8efddb2e3d7db18560ea671424ad8854 (diff)
downloadlibdom-2759bec06573d9ac3c32ef2d310492edc8a1b103.tar.gz
libdom-2759bec06573d9ac3c32ef2d310492edc8a1b103.tar.bz2
Obtain the docuemnt object at parser creation time.
Remove the unecessary document retrival API
Diffstat (limited to 'bindings/hubbub/parser.c')
-rw-r--r--bindings/hubbub/parser.c29
1 files changed, 11 insertions, 18 deletions
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,
&params);
+ /* set return parameter */
+ *document = (dom_document *)dom_node_ref(parser->doc);
+
return parser;
}
@@ -884,24 +895,6 @@ dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
}
/**
- * 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
*
* \param parser The parser object