nsgenjsbind: branch master updated. 24d68eb4e19e48c80a44af324499e1e16863e768

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Fri Nov 16 22:05:51 GMT 2012


Gitweb links:

...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/24d68eb4e19e48c80a44af324499e1e16863e768
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/24d68eb4e19e48c80a44af324499e1e16863e768
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/24d68eb4e19e48c80a44af324499e1e16863e768

The branch, master has been updated
       via  24d68eb4e19e48c80a44af324499e1e16863e768 (commit)
      from  bb6e9d7f5f71677aa4fc79fed01919ea0bbb20c4 (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/nsgenjsbind.git/commitdiff/24d68eb4e19e48c80a44af324499e1e16863e768
commit 24d68eb4e19e48c80a44af324499e1e16863e768
Author: Vincent Sanders <vince at kyllikki.org>
Commit: Vincent Sanders <vince at kyllikki.org>

    ensure newly created objects survive teh garbage collector long enough to be constructed.

diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0711e75..476c99e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -357,7 +357,16 @@ output_class_new(struct binding *binding)
 			"\tif (newobject == NULL) {\n"
 			"\t\tfree(private);\n"
 			"\t\treturn NULL;\n"
-			"\t}\n"
+			"\t}\n\n");
+
+		/* root object to stop it being garbage collected */
+		fprintf(binding->outfile,
+			"\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+			"\t\tfree(private);\n"
+			"\t\treturn NULL;\n"
+			"\t}\n\n");
+
+		fprintf(binding->outfile,
 			"\n"
 			"\t/* attach private pointer */\n"
 			"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
@@ -365,6 +374,7 @@ output_class_new(struct binding *binding)
 			"\t\treturn NULL;\n"
 			"\t}\n\n");
 
+
 		/* attach operations and attributes (functions and properties) */
 		fprintf(binding->outfile,
 			"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -383,6 +393,12 @@ output_class_new(struct binding *binding)
 			"\t\treturn NULL;\n"
 			"\t}\n");
 
+		/* root object to stop it being garbage collected */
+		fprintf(binding->outfile,
+			"\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+			"\t\treturn NULL;\n"
+			"\t}\n\n");
+
 		/* attach operations and attributes (functions and properties) */
 		fprintf(binding->outfile,
 			"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -395,8 +411,9 @@ output_class_new(struct binding *binding)
 			"\t}\n\n");
 	}
 	
-
+	/* unroot object and return it */
 	fprintf(binding->outfile,
+		"\tJS_RemoveRoot(cx, &newobject);\n"
 		"\n"
 		"\treturn newobject;\n"
 		"}\n");


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

Summary of changes:
 src/jsapi-libdom.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0711e75..476c99e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -357,7 +357,16 @@ output_class_new(struct binding *binding)
 			"\tif (newobject == NULL) {\n"
 			"\t\tfree(private);\n"
 			"\t\treturn NULL;\n"
-			"\t}\n"
+			"\t}\n\n");
+
+		/* root object to stop it being garbage collected */
+		fprintf(binding->outfile,
+			"\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+			"\t\tfree(private);\n"
+			"\t\treturn NULL;\n"
+			"\t}\n\n");
+
+		fprintf(binding->outfile,
 			"\n"
 			"\t/* attach private pointer */\n"
 			"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
@@ -365,6 +374,7 @@ output_class_new(struct binding *binding)
 			"\t\treturn NULL;\n"
 			"\t}\n\n");
 
+
 		/* attach operations and attributes (functions and properties) */
 		fprintf(binding->outfile,
 			"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -383,6 +393,12 @@ output_class_new(struct binding *binding)
 			"\t\treturn NULL;\n"
 			"\t}\n");
 
+		/* root object to stop it being garbage collected */
+		fprintf(binding->outfile,
+			"\tif (JS_AddRoot(cx, &newobject) != JS_TRUE) {\n"
+			"\t\treturn NULL;\n"
+			"\t}\n\n");
+
 		/* attach operations and attributes (functions and properties) */
 		fprintf(binding->outfile,
 			"\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
@@ -395,8 +411,9 @@ output_class_new(struct binding *binding)
 			"\t}\n\n");
 	}
 	
-
+	/* unroot object and return it */
 	fprintf(binding->outfile,
+		"\tJS_RemoveRoot(cx, &newobject);\n"
 		"\n"
 		"\treturn newobject;\n"
 		"}\n");


-- 
NetSurf Generator for JavaScript bindings



More information about the netsurf-commits mailing list