summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-09-10 00:22:34 +0100
committerVincent Sanders <vince@kyllikki.org>2012-09-10 00:22:34 +0100
commit74e143bf3a9cd1cf6748cf1462f8e0fb161d126e (patch)
tree8526a61b4f6735c7fa0fad17113ae3baee6d6e59 /src/jsapi-libdom.c
parent640ed1da81d909bb3c2f01a481e7e8d3336f336c (diff)
downloadnsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.gz
nsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.bz2
clean up AST building for both parsers
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 02033e1..3d07161 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -11,11 +11,69 @@
#include <string.h>
#include "genjsbind-ast.h"
+#include "webidl-ast.h"
#include "jsapi-libdom.h"
-int jsapi_libdom_output(char *outfilename)
+/*
+#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_SEP_LEN 4
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
+
+int genbind_header_comment(char *comment)
+{
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen(genbind_ast->hdr_comments) +
+ strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", genbind_ast->hdr_comments , comment);
+ free(genbind_ast->hdr_comments);
+ free(comment);
+ genbind_ast->hdr_comments = fullstr;
+
+ return 0;
+}
+
+{
+ if (webidl_parsefile($2) != 0) {
+ YYABORT;
+}
+}
+*/
+ /* initialise root IDL node */
+/* webidl_root =
+
+*/
+
+static int webidl_file_cb(struct genbind_node *node, void *ctx)
+{
+ struct webidl_node **webidl_ast = ctx;
+ char *filename;
+
+ filename = genbind_node_gettext(node);
+
+ return webidl_parsefile(filename, webidl_ast);
+
+}
+
+static int
+read_webidl(struct genbind_node *genbind_ast, struct webidl_node **webidl_ast)
+{
+ return genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_WEBIDLFILE,
+ webidl_file_cb,
+ webidl_ast);
+
+}
+
+int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
{
FILE *outfile = NULL;
+ struct webidl_node *webidl_ast = NULL;
+
+ read_webidl(genbind_ast, &webidl_ast);
+
+
/* open output file */
if (outfilename == NULL) {
outfile = stdout;
@@ -30,12 +88,12 @@ int jsapi_libdom_output(char *outfilename)
return 4;
}
- fprintf(outfile, "/* %s\n */\n\n", genbind_ast->hdr_comments);
+ /* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
fprintf(outfile, "%s", genbind_ast->preamble);
- fprintf(outfile, "/* interface %s */\n\n", genbind_ast->ifname);
-
+ fprintf(outfile, " interface %s \n\n", genbind_ast->ifname);
+*/
fclose(outfile);
return 0;