summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vincent.sanders@collabora.co.uk>2012-11-15 20:10:21 +0000
committerVincent Sanders <vincent.sanders@collabora.co.uk>2012-11-15 20:10:21 +0000
commit52a0b403fca3b37434c7ed5343d25dcae8734e0b (patch)
treeb5629faaadef2d4e9d136a3b4e22eba3c7b8e78a /src/jsapi-libdom.c
parent257f535bd18de9a6fc4e9d90303939706a783732 (diff)
downloadnsgenbind-52a0b403fca3b37434c7ed5343d25dcae8734e0b.tar.gz
nsgenbind-52a0b403fca3b37434c7ed5343d25dcae8734e0b.tar.bz2
correctly construct properties and functions so enumeration is correct. Seems to be an issue setting functions to be enumerable so left disabled for now
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 187d511..0711e75 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -272,8 +272,8 @@ output_class_init(struct binding *binding)
"\t\t&JSClass_%s,\n"
"\t\tNULL,\n"
"\t\t0,\n"
- "\t\tjsclass_properties,\n"
- "\t\tjsclass_functions, \n"
+ "\t\tNULL,\n"
+ "\t\tNULL, \n"
"\t\tNULL, \n"
"\t\tNULL);\n",
binding->interface);
@@ -322,6 +322,7 @@ output_class_new(struct binding *binding)
"{\n"
"\tJSObject *newobject;\n");
+ /* create private data */
if (binding->has_private) {
fprintf(binding->outfile,
"\tstruct jsclass_private *private;\n"
@@ -362,8 +363,38 @@ output_class_new(struct binding *binding)
"\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
"\t\tfree(private);\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"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+ } else {
+ fprintf(binding->outfile,
+ "\tif (newobject == NULL) {\n"
+ "\t\treturn NULL;\n"
"\t}\n");
+
+ /* attach operations and attributes (functions and properties) */
+ fprintf(binding->outfile,
+ "\tif (JS_DefineFunctions(cx, newobject, jsclass_functions) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
+
+ fprintf(binding->outfile,
+ "\tif (JS_DefineProperties(cx, newobject, jsclass_properties) != JS_TRUE) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n\n");
}
+
fprintf(binding->outfile,
"\n"