summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-10-08 00:27:36 +0100
committerVincent Sanders <vince@kyllikki.org>2012-10-08 00:27:36 +0100
commitd3b66100f5fc6459d9d466e20bf0b2054d617b85 (patch)
treecbbcc65363d46b789f884f1fe72559fa4bd68daa /src/jsapi-libdom.c
parentf072d31de069e378af37a15d1e1433e5a9e15275 (diff)
downloadnsgenbind-d3b66100f5fc6459d9d466e20bf0b2054d617b85.tar.gz
nsgenbind-d3b66100f5fc6459d9d466e20bf0b2054d617b85.tar.bz2
split out operator body generation
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c125
1 files changed, 1 insertions, 124 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index f5b9ed5..adb0b5e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -20,13 +20,6 @@
#define HDR_COMMENT_SEP "\n * "
#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"
-struct binding {
- struct genbind_node *gb_ast;
- struct webidl_node *wi_ast;
- const char *name; /* name of the binding */
- const char *interface; /* webidl interface binding is for */
- FILE *outfile ; /* output file */
-};
static int webidl_file_cb(struct genbind_node *node, void *ctx)
{
@@ -259,70 +252,6 @@ generate_function_spec(struct binding *binding, const char *interface)
-static int webidl_function_body_cb(struct webidl_node *node, void *ctx)
-{
- struct binding *binding = ctx;
- struct webidl_node *ident_node;
- struct genbind_node *operation_node;
-
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node == NULL) {
- /* operation without identifier - must have special keyword
- * http://www.w3.org/TR/WebIDL/#idl-operations
- */
- } else {
- /* normal operation with identifier */
-
- fprintf(binding->outfile,
- "static JSBool JSAPI_NATIVE(%s, JSContext *cx, uintN argc, jsval *vp)\n",
- webidl_node_gettext(ident_node));
- fprintf(binding->outfile,
- "{\n");
-
- fprintf(binding->outfile,
- " struct jsclass_private *private;\n");
-
- fprintf(binding->outfile,
- " private = JS_GetInstancePrivate(cx,\n"
- " JS_THIS_OBJECT(cx,vp),\n"
- " &jsclass_object,\n"
- " NULL);\n"
- " if (priv == NULL)\n"
- " return JS_FALSE;\n");
-
-/*
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-*/
-
- operation_node = genbind_node_find_type_ident(binding->gb_ast,
- NULL,
- GENBIND_NODE_TYPE_OPERATION,
- webidl_node_gettext(ident_node));
-
- if (operation_node != NULL) {
- struct genbind_node *code_node;
-
- code_node = genbind_node_find_type(genbind_node_getnode(operation_node),
- NULL,
- GENBIND_NODE_TYPE_CBLOCK);
- if (code_node != NULL) {
- fprintf(binding->outfile,
- "%s\n",
- genbind_node_gettext(code_node));
- }
- }
-
-
- fprintf(binding->outfile, "}\n\n");
-
- }
- return 0;
-}
@@ -486,58 +415,6 @@ output_property_body(struct binding *binding, const char *interface)
return 0;
}
-static int
-output_function_body(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- while (members_node != NULL) {
-
- fprintf(binding->outfile,"/**** %s ****/\n", interface);
-
- /* for each function emit a JSAPI_FS()*/
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_OPERATION,
- webidl_function_body_cb,
- binding);
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- }
-
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return output_function_body(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
static int
output_jsclass(struct binding *binding)
@@ -722,7 +599,7 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 8;
}
- res = output_function_body(binding, binding->interface);
+ res = output_operator_body(binding, binding->interface);
if (res) {
return 9;
}