diff options
author | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2013-06-03 15:15:05 +0100 |
---|---|---|
committer | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2013-06-03 15:15:05 +0100 |
commit | aab61ebdb4494309e688ea8afbd97c5a2f89e935 (patch) | |
tree | 716a29b96f3408ba2c7cf71534b97430c10b8ef4 /src/jsapi-libdom-operator.c | |
parent | 85287e9287e29fd715470253b1075e726a2ec594 (diff) | |
download | nsgenbind-aab61ebdb4494309e688ea8afbd97c5a2f89e935.tar.gz nsgenbind-aab61ebdb4494309e688ea8afbd97c5a2f89e935.tar.bz2 |
add switch and implementation to enable debug trace logging in generated code
Diffstat (limited to 'src/jsapi-libdom-operator.c')
-rw-r--r-- | src/jsapi-libdom-operator.c | 59 |
1 files changed, 43 insertions, 16 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)); |