diff options
author | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2012-10-25 19:37:09 +0100 |
---|---|---|
committer | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2012-10-25 19:37:09 +0100 |
commit | 971604ee6d295e3b5c5527c15a2e3f5fd34c335c (patch) | |
tree | 4b05c7525d5487411d2ff8c19a0c58c77d9383b0 /src | |
parent | 0b5cd300d739b37090f5e1d29ca08a49fd892713 (diff) | |
download | nsgenbind-971604ee6d295e3b5c5527c15a2e3f5fd34c335c.tar.gz nsgenbind-971604ee6d295e3b5c5527c15a2e3f5fd34c335c.tar.bz2 |
make teh class object non static and named according to interface
Diffstat (limited to 'src')
-rw-r--r-- | src/jsapi-libdom-operator.c | 37 | ||||
-rw-r--r-- | src/jsapi-libdom.c | 22 |
2 files changed, 46 insertions, 13 deletions
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c index e937fa0..e0923dd 100644 --- a/src/jsapi-libdom-operator.c +++ b/src/jsapi-libdom-operator.c @@ -26,12 +26,14 @@ static void output_variable_definitions(struct binding *binding, struct webidl_node *operation_list) { + struct webidl_node *operation_ident; struct webidl_node *arglist_node; struct webidl_node *arglist; /* argument list */ struct webidl_node *arg_node = NULL; struct webidl_node *arg_ident = NULL; struct webidl_node *arg_type = NULL; struct webidl_node *arg_type_base = NULL; + struct webidl_node *arg_type_ident = NULL; enum webidl_type webidl_arg_type; /* return value */ @@ -69,7 +71,27 @@ output_variable_definitions(struct binding *binding, switch (webidl_arg_type) { case WEBIDL_TYPE_USER: - fprintf(stderr, "Unsupported: WEBIDL_TYPE_USER\n"); + if (options->verbose) { + + operation_ident = webidl_node_find_type(operation_list, + NULL, + WEBIDL_NODE_TYPE_IDENT); + + arg_type_ident = webidl_node_find_type(webidl_node_getnode(arg_type), + NULL, + WEBIDL_NODE_TYPE_IDENT); + + fprintf(stderr, + "User type: %s:%s %s\n", + webidl_node_gettext(operation_ident), + webidl_node_gettext(arg_type_ident), + webidl_node_gettext(arg_ident)); + } + /* User type - jsobject then */ + fprintf(binding->outfile, + "\tJSObject *%s = NULL;\n", + webidl_node_gettext(arg_ident)); + break; case WEBIDL_TYPE_BOOL: @@ -199,6 +221,14 @@ output_operation_input(struct binding *binding, switch (webidl_arg_type) { case WEBIDL_TYPE_USER: + fprintf(binding->outfile, + "\tif ((!JSVAL_IS_NULL(argv[%1$d])) ||\n" + "\t\t(JSVAL_IS_PRIMITIVE(argv[%1$d]))) {\n" + "\t\treturn JS_FALSE;\n" + "\t}\n" + "\t%2$s = JSVAL_TO_OBJECT(argv[%1$d]);\n", + arg_cur, + webidl_node_gettext(arg_ident)); break; case WEBIDL_TYPE_BOOL: @@ -331,10 +361,11 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx) "\n" "\tprivate = JS_GetInstancePrivate(cx,\n" "\t\t\tJS_THIS_OBJECT(cx,vp),\n" - "\t\t\t&jsclass_object,\n" + "\t\t\t&JSClass_%s,\n" "\t\t\tNULL);\n" "\tif (private == NULL)\n" - "\t\treturn JS_FALSE;\n\n"); + "\t\treturn JS_FALSE;\n\n", + binding->interface); output_operation_input(binding, webidl_node_getnode(node)); diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c index 82c4ac1..18915fe 100644 --- a/src/jsapi-libdom.c +++ b/src/jsapi-libdom.c @@ -402,11 +402,12 @@ output_con_de_structors(struct binding *binding) "{" "\tstruct jsclass_private *private;\n" "\n" - "\tprivate = JS_GetInstancePrivate(cx, obj, &jsclass_object, NULL);\n" + "\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n" "\tif (private != NULL) {\n" "\t\tfree(private);\n" "\t}\n" - "}\n\n"); + "}\n\n", + binding->interface); /* resolve */ fprintf(binding->outfile, @@ -447,7 +448,7 @@ output_con_de_structors(struct binding *binding) "\tjsobject = JS_InitClass(cx,\n" "\t\tparent,\n" "\t\tNULL,\n" - "\t\t&jsclass_object,\n" + "\t\t&JSClass_%s,\n" "\t\tNULL,\n" "\t\t0,\n" "\t\tjsclass_properties,\n" @@ -466,7 +467,8 @@ output_con_de_structors(struct binding *binding) "\t}\n" "\n" "\treturn jsobject;\n" - "}\n"); + "}\n", + binding->interface); return res; @@ -564,15 +566,14 @@ output_jsclass(struct binding *binding) { /* forward declare the resolver and finalizer */ fprintf(binding->outfile, - "static void jsclass_finalize(JSContext *cx, JSObject *obj);"); + "static void jsclass_finalize(JSContext *cx, JSObject *obj);\n"); fprintf(binding->outfile, - "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);"); + "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n"); /* output the class */ fprintf(binding->outfile, - "static JSClass jsclass_object =\n" - "{\n" - " \"%s\",\n" + "JSClass JSClass_%1$s = {\n" + " \"%1$s\",\n" " JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,\n" " JS_PropertyStub,\n" " JS_PropertyStub,\n" @@ -583,7 +584,8 @@ output_jsclass(struct binding *binding) " JS_ConvertStub,\n" " jsclass_finalize,\n" " JSCLASS_NO_OPTIONAL_MEMBERS\n" - "};\n\n", binding->name); + "};\n\n", + binding->interface); return 0; } |