diff options
author | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2012-09-19 19:22:07 +0100 |
---|---|---|
committer | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2012-09-19 19:22:07 +0100 |
commit | 46cfe5f47ce0034bb8804d0bd04d573bc6213ab8 (patch) | |
tree | c8d48ee534040cf4f36e238970a99dbee63b2d9b /src/jsapi-libdom.c | |
parent | d5c2e8d0843abd94e4fed57f25186147f56a3976 (diff) | |
download | nsgenbind-46cfe5f47ce0034bb8804d0bd04d573bc6213ab8.tar.gz nsgenbind-46cfe5f47ce0034bb8804d0bd04d573bc6213ab8.tar.bz2 |
extract and output binding parameters
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r-- | src/jsapi-libdom.c | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c index 505f115..4dc2db8 100644 --- a/src/jsapi-libdom.c +++ b/src/jsapi-libdom.c @@ -6,10 +6,11 @@ * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> */ +#include <stdbool.h> #include <stdio.h> #include <errno.h> #include <string.h> -#include <stdbool.h> +#include <stdlib.h> #include "options.h" #include "genjsbind-ast.h" @@ -19,6 +20,11 @@ #define HDR_COMMENT_SEP "\n * " #define HDR_COMMENT_PREABLE "Generated by nsgenjsapi" +struct binding { + const char *name; /* name of the binding */ + const char *interface; /* webidl interface binding is for */ +}; + static int webidl_preamble_cb(struct genbind_node *node, void *ctx) { FILE *outfile = ctx; @@ -91,29 +97,62 @@ read_webidl(struct genbind_node *genbind_ast, struct webidl_node **webidl_ast) /* debug dump of web idl AST */ if (options->verbose) { - webidl_ast_dump(webidl_ast, 0); + webidl_ast_dump(*webidl_ast, 0); } return res; } -struct binding { - const char *name; /* name of the binding */ - const char *interface; /* webidl interface binding is for */ -}; +static int +output_function_spec(FILE *outfile, + struct genbind_node *genbind_ast, + struct binding *binding) +{ + fprintf(outfile, "%s\n%s\n", binding->name, binding->interface); + + return 0; +} static struct binding *binding_new(struct genbind_node *genbind_ast) { struct binding *nb; - nb = calloc(1, sizeof(struct binding)); - struct genbind_node *binding_node; + struct genbind_node *ident_node; + struct genbind_node *interface_node; binding_node = genbind_node_find(genbind_ast, - NULL, - genbind_cmp_node_type, - GENBIND_NODE_TYPE_BINDING); + NULL, + genbind_cmp_node_type, + (void *)GENBIND_NODE_TYPE_BINDING); + + if (binding_node == NULL) { + return NULL; + } + + ident_node = genbind_node_find(genbind_node_getnode(binding_node), + NULL, + genbind_cmp_node_type, + (void *)GENBIND_NODE_TYPE_IDENT); + + if (ident_node == NULL) { + return NULL; + } + + interface_node = genbind_node_find(genbind_node_getnode(binding_node), + NULL, + genbind_cmp_node_type, + (void *)GENBIND_NODE_TYPE_TYPE_INTERFACE); + + if (interface_node == NULL) { + return NULL; + } + + nb = calloc(1, sizeof(struct binding)); + + nb->name = genbind_node_gettext(ident_node); + nb->interface = genbind_node_gettext(interface_node); + return nb; } int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast) @@ -151,7 +190,7 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast) output_preamble(outfile, genbind_ast); - //output_function_spec(outfile, genbind_ast); + output_function_spec(outfile, genbind_ast, binding); //output_property_spec(outfile, genbind_ast); |