nsgenbind: branch master updated. release/0.0.1-3-gaab61eb

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Mon Jun 3 15:15:47 BST 2013


Gitweb links:

...log http://git.netsurf-browser.org/nsgenbind.git/shortlog/aab61ebdb4494309e688ea8afbd97c5a2f89e935
...commit http://git.netsurf-browser.org/nsgenbind.git/commit/aab61ebdb4494309e688ea8afbd97c5a2f89e935
...tree http://git.netsurf-browser.org/nsgenbind.git/tree/aab61ebdb4494309e688ea8afbd97c5a2f89e935

The branch, master has been updated
       via  aab61ebdb4494309e688ea8afbd97c5a2f89e935 (commit)
       via  85287e9287e29fd715470253b1075e726a2ec594 (commit)
      from  51bd18034c510a6d4711823e08b69af2f7aa063e (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/nsgenbind.git/commit/?id=aab61ebdb4494309e688ea8afbd97c5a2f89e935
commit aab61ebdb4494309e688ea8afbd97c5a2f89e935
Author: Vincent Sanders <vincent.sanders at collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders at collabora.co.uk>

    add switch and implementation to enable debug trace logging in generated code

diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index f30bdb3..1d16afe 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -702,14 +702,52 @@ output_operator_placeholder(struct binding *binding,
 	     binding->interface,
 	     webidl_node_gettext(ident_node));
 
-	fprintf(binding->outfile,
-		"\tJSLOG(\"operation %s.%s has no implementation\");\n",
-		binding->interface,
-		webidl_node_gettext(ident_node));
+	if (options->dbglog) {
+		fprintf(binding->outfile,
+			"\tJSLOG(\"operation %s.%s has no implementation\");\n",
+			binding->interface,
+			webidl_node_gettext(ident_node));
+	}
 
 	return 0;
 }
 
+
+/* generate context data fetcher if the binding has private data */
+static inline int
+output_private_get(struct binding *binding, const char *argname)
+{
+	int ret = 0;
+
+	if (binding->has_private) {
+
+		ret = fprintf(binding->outfile,
+			      "\tstruct jsclass_private *%s;\n"
+			      "\n"
+			      "\t%s = JS_GetInstancePrivate(cx,\n"
+			      "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
+			      "\t\t\t&JSClass_%s,\n"
+			      "\t\t\targv);\n"
+			      "\tif (%s == NULL) {\n"
+			      "\t\treturn JS_FALSE;\n"
+			      "\t}\n\n",
+			      argname, argname, binding->interface, argname);
+
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, JSAPI_THIS_OBJECT(cx,vp), %s);\n", argname);
+		}
+	} else {
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, JSAPI_THIS_OBJECT(cx,vp));\n");
+		}
+
+	}
+
+	return ret;
+}
+
 static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
 {
 	struct binding *binding = ctx;
@@ -743,18 +781,7 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
 
 		output_variable_definitions(binding, webidl_node_getnode(node));
 
-		if (binding->has_private) {
-			fprintf(binding->outfile,
-				"\tstruct jsclass_private *private;\n"
-				"\n"
-				"\tprivate = JS_GetInstancePrivate(cx,\n"
-				"\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
-				"\t\t\t&JSClass_%s,\n"
-				"\t\t\targv);\n"
-				"\tif (private == NULL)\n"
-				"\t\treturn JS_FALSE;\n\n",
-				binding->interface);
-		}
+		output_private_get(binding, "private");
 
 		output_operation_input(binding, webidl_node_getnode(node));
 
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 0f82c3f..2bd3068 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -26,11 +26,11 @@ static int generate_property_body(struct binding *binding, const char *interface
 static inline int
 output_private_get(struct binding *binding, const char *argname)
 {
-	if (!binding->has_private) {
-		return 0;
-	}
+	int ret = 0;
 
-	return fprintf(binding->outfile,
+	if (binding->has_private) {
+
+		ret = fprintf(binding->outfile,
 		       "\tstruct jsclass_private *%s;\n"
 		       "\n"
 		       "\t%s = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
@@ -38,6 +38,20 @@ output_private_get(struct binding *binding, const char *argname)
 		       "\t\treturn JS_FALSE;\n"
 		       "\t}\n\n",
 		       argname, argname, binding->interface, argname);
+
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, %s);\n", argname);
+		}
+	} else {
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+		}
+
+	}
+
+	return ret;
 }
 
 /* generate vars for property name getter */
@@ -756,10 +770,13 @@ output_property_placeholder(struct binding *binding,
 	     binding->interface,
 	     ident);
 
-	fprintf(binding->outfile,
-		"\tJSLOG(\"property %s.%s has no implementation\");\n",
-		binding->interface,
-		ident);
+
+	if (options->dbglog) {
+		fprintf(binding->outfile,
+			"\tJSLOG(\"property %s.%s has no implementation\");\n",
+			binding->interface,
+			ident);
+	}
 	return 0;
 }
 
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index fef1656..7104a83 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -238,6 +238,11 @@ output_api_operations(struct binding *binding)
 			"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 			binding->interface);
 
+		if (options->dbglog) {
+			fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+
 		if (binding->finalise != NULL) {
 			output_code_block(binding,
 				genbind_node_getnode(binding->finalise));
@@ -254,6 +259,11 @@ output_api_operations(struct binding *binding)
 			"static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
 			"{\n");
 
+		if (options->dbglog) {
+			fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+		}
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->finalise));
 
@@ -275,8 +285,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->addproperty));
 
@@ -298,8 +320,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->delproperty));
 
@@ -321,8 +355,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->getproperty));
 
@@ -344,8 +390,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->setproperty));
 
@@ -367,6 +425,17 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
 		output_code_block(binding, genbind_node_getnode(binding->enumerate));
@@ -389,8 +458,19 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding, genbind_node_getnode(binding->resolve));
 
 		fprintf(binding->outfile,
@@ -410,6 +490,17 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(JSAPI_MARKCX, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", JSAPI_MARKCX, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", JSAPI_MARKCX, obj);\n");
+			}
+
 		}
 
 		output_code_block(binding, genbind_node_getnode(binding->mark));
diff --git a/src/nsgenbind.c b/src/nsgenbind.c
index 1c5100e..d993646 100644
--- a/src/nsgenbind.c
+++ b/src/nsgenbind.c
@@ -30,7 +30,7 @@ static struct options* process_cmdline(int argc, char **argv)
 		return NULL;
 	}
 
-	while ((opt = getopt(argc, argv, "vDW::d:I:o:h:")) != -1) {
+	while ((opt = getopt(argc, argv, "vgDW::d:I:o:h:")) != -1) {
 		switch (opt) {
 		case 'I':
 			options->idlpath = strdup(optarg);
@@ -56,13 +56,17 @@ static struct options* process_cmdline(int argc, char **argv)
 			options->debug = true;
 			break;
 
+		case 'g':
+			options->dbglog = true;
+			break;
+
 		case 'W':
 			options->warnings = 1; /* warning flags */
 			break;
 
 		default: /* '?' */
 			fprintf(stderr, 
-			     "Usage: %s [-v] [-D] [-W] [-d depfilename] [-I idlpath] [-o filename] [-h headerfile] inputfile\n",
+			     "Usage: %s [-v] [-g] [-D] [-W] [-d depfilename] [-I idlpath] [-o filename] [-h headerfile] inputfile\n",
 				argv[0]);
 			free(options);
 			return NULL;
diff --git a/src/options.h b/src/options.h
index ca71078..13c02be 100644
--- a/src/options.h
+++ b/src/options.h
@@ -22,6 +22,7 @@ struct options {
 
 	bool verbose; /**< verbose processing */
 	bool debug; /**< debug enabled */
+	bool dbglog; /**< embed debug logging in output */
 	unsigned int warnings; /**< warning flags */
 };
 


commitdiff http://git.netsurf-browser.org/nsgenbind.git/commit/?id=85287e9287e29fd715470253b1075e726a2ec594
commit 85287e9287e29fd715470253b1075e726a2ec594
Author: Vincent Sanders <vincent.sanders at collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders at collabora.co.uk>

    use macro to cope with differing return types in garbage collection callback

diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 2a29e22..fef1656 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -415,7 +415,7 @@ output_api_operations(struct binding *binding)
 		output_code_block(binding, genbind_node_getnode(binding->mark));
 
 		fprintf(binding->outfile,
-			"\treturn JS_TRUE;\n"
+			"\tJSAPI_MARKOP_RETURN(JS_TRUE);\n"
 			"}\n\n");
 	}
 	return res;


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

Summary of changes:
 src/jsapi-libdom-operator.c |   59 ++++++++++++++++++++-------
 src/jsapi-libdom-property.c |   33 +++++++++++----
 src/jsapi-libdom.c          |   93 ++++++++++++++++++++++++++++++++++++++++++-
 src/nsgenbind.c             |    8 +++-
 src/options.h               |    1 +
 5 files changed, 167 insertions(+), 27 deletions(-)

diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index f30bdb3..1d16afe 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -702,14 +702,52 @@ output_operator_placeholder(struct binding *binding,
 	     binding->interface,
 	     webidl_node_gettext(ident_node));
 
-	fprintf(binding->outfile,
-		"\tJSLOG(\"operation %s.%s has no implementation\");\n",
-		binding->interface,
-		webidl_node_gettext(ident_node));
+	if (options->dbglog) {
+		fprintf(binding->outfile,
+			"\tJSLOG(\"operation %s.%s has no implementation\");\n",
+			binding->interface,
+			webidl_node_gettext(ident_node));
+	}
 
 	return 0;
 }
 
+
+/* generate context data fetcher if the binding has private data */
+static inline int
+output_private_get(struct binding *binding, const char *argname)
+{
+	int ret = 0;
+
+	if (binding->has_private) {
+
+		ret = fprintf(binding->outfile,
+			      "\tstruct jsclass_private *%s;\n"
+			      "\n"
+			      "\t%s = JS_GetInstancePrivate(cx,\n"
+			      "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
+			      "\t\t\t&JSClass_%s,\n"
+			      "\t\t\targv);\n"
+			      "\tif (%s == NULL) {\n"
+			      "\t\treturn JS_FALSE;\n"
+			      "\t}\n\n",
+			      argname, argname, binding->interface, argname);
+
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, JSAPI_THIS_OBJECT(cx,vp), %s);\n", argname);
+		}
+	} else {
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, JSAPI_THIS_OBJECT(cx,vp));\n");
+		}
+
+	}
+
+	return ret;
+}
+
 static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
 {
 	struct binding *binding = ctx;
@@ -743,18 +781,7 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
 
 		output_variable_definitions(binding, webidl_node_getnode(node));
 
-		if (binding->has_private) {
-			fprintf(binding->outfile,
-				"\tstruct jsclass_private *private;\n"
-				"\n"
-				"\tprivate = JS_GetInstancePrivate(cx,\n"
-				"\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
-				"\t\t\t&JSClass_%s,\n"
-				"\t\t\targv);\n"
-				"\tif (private == NULL)\n"
-				"\t\treturn JS_FALSE;\n\n",
-				binding->interface);
-		}
+		output_private_get(binding, "private");
 
 		output_operation_input(binding, webidl_node_getnode(node));
 
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 0f82c3f..2bd3068 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -26,11 +26,11 @@ static int generate_property_body(struct binding *binding, const char *interface
 static inline int
 output_private_get(struct binding *binding, const char *argname)
 {
-	if (!binding->has_private) {
-		return 0;
-	}
+	int ret = 0;
 
-	return fprintf(binding->outfile,
+	if (binding->has_private) {
+
+		ret = fprintf(binding->outfile,
 		       "\tstruct jsclass_private *%s;\n"
 		       "\n"
 		       "\t%s = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
@@ -38,6 +38,20 @@ output_private_get(struct binding *binding, const char *argname)
 		       "\t\treturn JS_FALSE;\n"
 		       "\t}\n\n",
 		       argname, argname, binding->interface, argname);
+
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				       "\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, %s);\n", argname);
+		}
+	} else {
+		if (options->dbglog) {
+			ret += fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+		}
+
+	}
+
+	return ret;
 }
 
 /* generate vars for property name getter */
@@ -756,10 +770,13 @@ output_property_placeholder(struct binding *binding,
 	     binding->interface,
 	     ident);
 
-	fprintf(binding->outfile,
-		"\tJSLOG(\"property %s.%s has no implementation\");\n",
-		binding->interface,
-		ident);
+
+	if (options->dbglog) {
+		fprintf(binding->outfile,
+			"\tJSLOG(\"property %s.%s has no implementation\");\n",
+			binding->interface,
+			ident);
+	}
 	return 0;
 }
 
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 2a29e22..7104a83 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -238,6 +238,11 @@ output_api_operations(struct binding *binding)
 			"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 			binding->interface);
 
+		if (options->dbglog) {
+			fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+
 		if (binding->finalise != NULL) {
 			output_code_block(binding,
 				genbind_node_getnode(binding->finalise));
@@ -254,6 +259,11 @@ output_api_operations(struct binding *binding)
 			"static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
 			"{\n");
 
+		if (options->dbglog) {
+			fprintf(binding->outfile,
+				"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+		}
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->finalise));
 
@@ -275,8 +285,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->addproperty));
 
@@ -298,8 +320,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->delproperty));
 
@@ -321,8 +355,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->getproperty));
 
@@ -344,8 +390,20 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+		
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding,
 				  genbind_node_getnode(binding->setproperty));
 
@@ -367,6 +425,17 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
 		output_code_block(binding, genbind_node_getnode(binding->enumerate));
@@ -389,8 +458,19 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", cx, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", cx, obj);\n");
+			}
+
 		}
 
+
 		output_code_block(binding, genbind_node_getnode(binding->resolve));
 
 		fprintf(binding->outfile,
@@ -410,12 +490,23 @@ output_api_operations(struct binding *binding)
 				"\n"
 				"\tprivate = JS_GetInstancePrivate(JSAPI_MARKCX, obj, &JSClass_%s, NULL);\n",
 				binding->interface);
+
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p private:%%p\", JSAPI_MARKCX, obj, private);\n");
+			}
+		} else {
+			if (options->dbglog) {
+				fprintf(binding->outfile,
+					"\tJSLOG(\"jscontext:%%p jsobject:%%p\", JSAPI_MARKCX, obj);\n");
+			}
+
 		}
 
 		output_code_block(binding, genbind_node_getnode(binding->mark));
 
 		fprintf(binding->outfile,
-			"\treturn JS_TRUE;\n"
+			"\tJSAPI_MARKOP_RETURN(JS_TRUE);\n"
 			"}\n\n");
 	}
 	return res;
diff --git a/src/nsgenbind.c b/src/nsgenbind.c
index 1c5100e..d993646 100644
--- a/src/nsgenbind.c
+++ b/src/nsgenbind.c
@@ -30,7 +30,7 @@ static struct options* process_cmdline(int argc, char **argv)
 		return NULL;
 	}
 
-	while ((opt = getopt(argc, argv, "vDW::d:I:o:h:")) != -1) {
+	while ((opt = getopt(argc, argv, "vgDW::d:I:o:h:")) != -1) {
 		switch (opt) {
 		case 'I':
 			options->idlpath = strdup(optarg);
@@ -56,13 +56,17 @@ static struct options* process_cmdline(int argc, char **argv)
 			options->debug = true;
 			break;
 
+		case 'g':
+			options->dbglog = true;
+			break;
+
 		case 'W':
 			options->warnings = 1; /* warning flags */
 			break;
 
 		default: /* '?' */
 			fprintf(stderr, 
-			     "Usage: %s [-v] [-D] [-W] [-d depfilename] [-I idlpath] [-o filename] [-h headerfile] inputfile\n",
+			     "Usage: %s [-v] [-g] [-D] [-W] [-d depfilename] [-I idlpath] [-o filename] [-h headerfile] inputfile\n",
 				argv[0]);
 			free(options);
 			return NULL;
diff --git a/src/options.h b/src/options.h
index ca71078..13c02be 100644
--- a/src/options.h
+++ b/src/options.h
@@ -22,6 +22,7 @@ struct options {
 
 	bool verbose; /**< verbose processing */
 	bool debug; /**< debug enabled */
+	bool dbglog; /**< embed debug logging in output */
 	unsigned int warnings; /**< warning flags */
 };
 


-- 
NetSurf Generator for JavaScript bindings



More information about the netsurf-commits mailing list