Gitweb links:

...log 
http://git.netsurf-browser.org/libdom.git/shortlog/2759bec06573d9ac3c32ef2d310492edc8a1b103
...commit 
http://git.netsurf-browser.org/libdom.git/commit/2759bec06573d9ac3c32ef2d310492edc8a1b103
...tree 
http://git.netsurf-browser.org/libdom.git/tree/2759bec06573d9ac3c32ef2d310492edc8a1b103

The branch, master has been updated
       via  2759bec06573d9ac3c32ef2d310492edc8a1b103 (commit)
      from  6aedb99d8efddb2e3d7db18560ea671424ad8854 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libdom.git/commitdiff/2759bec06573d9ac3c32ef2d310492edc8a1b103
commit 2759bec06573d9ac3c32ef2d310492edc8a1b103
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    Obtain the docuemnt object at parser creation time.
    Remove the unecessary document retrival API

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
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index 16b02a8..e4bd52a 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -53,9 +53,7 @@ typedef enum dom_hubbub_encoding_source {
  */
 
 /* Create a Hubbub parser instance */
-dom_hubbub_parser *dom_hubbub_parser_create(const char *enc, bool fix_enc,
-                       bool enable_script, dom_msg msg,
-                       dom_script script, void *mctx);
+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);
 
 /* Destroy a Hubbub parser instance */
 void dom_hubbub_parser_destroy(dom_hubbub_parser *parser);
@@ -70,9 +68,6 @@ dom_hubbub_error 
dom_hubbub_parser_insert_chunk(dom_hubbub_parser *parser, const
 /* Notify parser that datastream is empty */
 dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser);
 
-/* Retrieve the created DOM Document */
-dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser);
-
 /* Retrieve the document's encoding */
 const char *dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser,
                dom_hubbub_encoding_source *source);


-----------------------------------------------------------------------

Summary of changes:
 bindings/hubbub/parser.c |   29 +++++++++++------------------
 bindings/hubbub/parser.h |    7 +------
 2 files changed, 12 insertions(+), 24 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
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index 16b02a8..e4bd52a 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -53,9 +53,7 @@ typedef enum dom_hubbub_encoding_source {
  */
 
 /* Create a Hubbub parser instance */
-dom_hubbub_parser *dom_hubbub_parser_create(const char *enc, bool fix_enc,
-                       bool enable_script, dom_msg msg,
-                       dom_script script, void *mctx);
+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);
 
 /* Destroy a Hubbub parser instance */
 void dom_hubbub_parser_destroy(dom_hubbub_parser *parser);
@@ -70,9 +68,6 @@ dom_hubbub_error 
dom_hubbub_parser_insert_chunk(dom_hubbub_parser *parser, const
 /* Notify parser that datastream is empty */
 dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser);
 
-/* Retrieve the created DOM Document */
-dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser);
-
 /* Retrieve the document's encoding */
 const char *dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser,
                dom_hubbub_encoding_source *source);


-- 
Document Object Model library

_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to