summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vincent.sanders@collabora.co.uk>2012-09-14 19:57:09 +0100
committerVincent Sanders <vincent.sanders@collabora.co.uk>2012-09-14 19:57:09 +0100
commitcdd39954a238ec07224c3c9cff66a4f8f101d71c (patch)
treedb822cce0b40536d0c5a9fbd0354264cfb6f1f09
parent6ccbb7e3fe88c9a6ddb232c43f71b9c8cb80a884 (diff)
downloadnsgenbind-cdd39954a238ec07224c3c9cff66a4f8f101d71c.tar.gz
nsgenbind-cdd39954a238ec07224c3c9cff66a4f8f101d71c.tar.bz2
add preamble output
add operation nodes to webidl ast
-rw-r--r--src/jsapi-libdom.c23
-rw-r--r--src/webidl-ast.c4
-rw-r--r--src/webidl-ast.h1
-rw-r--r--src/webidl-parser.y11
4 files changed, 36 insertions, 3 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index e7c13d2..3cae66f 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -19,6 +19,25 @@
#define HDR_COMMENT_SEP "\n * "
#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"
+static int webidl_preamble_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ char *txt;
+ txt = genbind_node_gettext(node);
+ fprintf(outfile, "%s", txt);
+ return 0;
+}
+
+static int
+output_preamble(FILE *outfile, struct genbind_node *genbind_ast)
+{
+ genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_PREAMBLE,
+ webidl_preamble_cb,
+ outfile);
+ return 0;
+}
+
static int webidl_hdrcomments_cb(struct genbind_node *node, void *ctx)
{
FILE *outfile = ctx;
@@ -102,9 +121,9 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
output_header_comments(outfile, genbind_ast);
- /* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
+ output_preamble(outfile, genbind_ast);
- fprintf(outfile, "%s", genbind_ast->preamble);
+ /*
fprintf(outfile, " interface %s \n\n", genbind_ast->ifname);
*/
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 5ae52f0..fecf0da 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -88,6 +88,7 @@ struct webidl_node *webidl_node_getnode(struct webidl_node *node)
case WEBIDL_NODE_TYPE_INTERFACE:
case WEBIDL_NODE_TYPE_INTERFACE_MEMBERS:
case WEBIDL_NODE_TYPE_ATTRIBUTE:
+ case WEBIDL_NODE_TYPE_OPERATION:
return node->r.node;
default:
@@ -116,6 +117,9 @@ static const char *webidl_node_type_to_str(enum webidl_node_type type)
case WEBIDL_NODE_TYPE_ATTRIBUTE:
return "Attribute";
+ case WEBIDL_NODE_TYPE_OPERATION:
+ return "Operation";
+
default:
return "Unknown";
}
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 04b49a9..8af3aeb 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -16,6 +16,7 @@ enum webidl_node_type {
WEBIDL_NODE_TYPE_INTERFACE_MEMBERS,
WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE,
WEBIDL_NODE_TYPE_ATTRIBUTE,
+ WEBIDL_NODE_TYPE_OPERATION,
};
struct webidl_node {
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index c4cfa56..f0f1830 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -134,8 +134,10 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%type <node> AttributeOrOperation
%type <node> StringifierAttributeOrOperation
%type <node> Const
+
%type <node> Operation
%type <node> OperationRest
+%type <node> OptionalIdentifier
%%
@@ -501,13 +503,20 @@ Special:
OperationRest:
ReturnType OptionalIdentifier '(' ArgumentList ')' ';'
{
- $$=NULL;
+ struct webidl_node *ident = NULL;
+ if ($2 != NULL) {
+ ident = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $2);
+ }
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_OPERATION, NULL, ident);
}
;
/* [40] */
OptionalIdentifier:
/* empty */
+ {
+ $$=NULL;
+ }
|
TOK_IDENTIFIER
;