From 8d9fcaaa445b95ba4c934dbdb40b98ae81bf8785 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 21 Oct 2012 14:44:06 +0100 Subject: split type and identifier in private entries --- src/genjsbind-parser.y | 6 +++-- src/jsapi-libdom.c | 47 +++++++++++++++++++++---------------- test/data/bindings/htmldocument.bnd | 6 ++--- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y index 0950dc9..cf9ab61 100644 --- a/src/genjsbind-parser.y +++ b/src/genjsbind-parser.y @@ -209,9 +209,11 @@ Type Private : - TOK_PRIVATE Strings ';' + TOK_PRIVATE TOK_STRING_LITERAL TOK_IDENTIFIER ';' { - $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_PRIVATE, NULL, $2); + $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_PRIVATE, NULL, + genbind_new_node(GENBIND_NODE_TYPE_IDENT, + genbind_new_node(GENBIND_NODE_TYPE_STRING, NULL, $2), $3)); } ; diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c index adb0b5e..aa6d2bb 100644 --- a/src/jsapi-libdom.c +++ b/src/jsapi-libdom.c @@ -306,21 +306,31 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx) } -static int webidl_privatestr_cb(struct genbind_node *node, void *ctx) + +static int webidl_private_cb(struct genbind_node *node, void *ctx) { struct binding *binding = ctx; + struct genbind_node *ident_node; + struct genbind_node *type_node; - fprintf(binding->outfile, " %s;\n", genbind_node_gettext(node)); - return 0; -} + ident_node = genbind_node_find_type(genbind_node_getnode(node), + NULL, + GENBIND_NODE_TYPE_IDENT); + if (ident_node == NULL) + return -1; /* bad AST */ + + type_node = genbind_node_find_type(genbind_node_getnode(node), + NULL, + GENBIND_NODE_TYPE_STRING); + if (type_node == NULL) + return -1; /* bad AST */ + + fprintf(binding->outfile, + " %s%s;\n", + genbind_node_gettext(type_node), + genbind_node_gettext(ident_node)); -static int webidl_private_cb(struct genbind_node *node, void *ctx) -{ - genbind_node_for_each_type(genbind_node_getnode(node), - GENBIND_NODE_TYPE_STRING, - webidl_privatestr_cb, - ctx); return 0; } @@ -512,26 +522,23 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast) struct webidl_node *webidl_ast = NULL; int res; - binding_node = genbind_node_find(genbind_ast, + binding_node = genbind_node_find_type(genbind_ast, NULL, - genbind_cmp_node_type, - (void *)GENBIND_NODE_TYPE_BINDING); + 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); + ident_node = genbind_node_find_type(genbind_node_getnode(binding_node), + NULL, + GENBIND_NODE_TYPE_IDENT); if (ident_node == NULL) { return NULL; } - interface_node = genbind_node_find(genbind_node_getnode(binding_node), + interface_node = genbind_node_find_type(genbind_node_getnode(binding_node), NULL, - genbind_cmp_node_type, - (void *)GENBIND_NODE_TYPE_BINDING_INTERFACE); + GENBIND_NODE_TYPE_BINDING_INTERFACE); if (interface_node == NULL) { return NULL; } diff --git a/test/data/bindings/htmldocument.bnd b/test/data/bindings/htmldocument.bnd index 310fc29..8f85ca3 100644 --- a/test/data/bindings/htmldocument.bnd +++ b/test/data/bindings/htmldocument.bnd @@ -20,7 +20,7 @@ preamble %{ #include "javascript/jsapi.h" - %} +%} operation write %{ LOG(("content %p parser %p writing %s", @@ -37,8 +37,8 @@ binding document { /* parameters to constructor value stored in private * context structure. */ - private "dom_document *node"; - private "struct html_content *htmlc"; + private "dom_document *" node; + private "struct html_content *" htmlc; interface Document; /* Web IDL interface to generate */ } -- cgit v1.2.3