summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-09-10 00:51:28 +0100
committerVincent Sanders <vince@kyllikki.org>2012-09-10 00:51:28 +0100
commit751839d208b02af3d0a2329e6d75a90d51a247ff (patch)
tree5da314a984879362d0194dc24e9c7598881da829 /src/jsapi-libdom.c
parent141796f3e78e8b134a6a44709a6f349e83bdf04d (diff)
downloadnsgenbind-751839d208b02af3d0a2329e6d75a90d51a247ff.tar.gz
nsgenbind-751839d208b02af3d0a2329e6d75a90d51a247ff.tar.bz2
make comment header output work
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 3d07161..c925ef9 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -14,10 +14,11 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
-/*
#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"
+
+/*
#define HDR_COMMENT_SEP_LEN 4
-#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
int genbind_header_comment(char *comment)
{
@@ -45,6 +46,37 @@ int genbind_header_comment(char *comment)
*/
+static int webidl_hdrcomments_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ char *txt;
+ txt = genbind_node_gettext(node);
+ fprintf(outfile, HDR_COMMENT_SEP"%s",txt);
+ return 0;
+}
+
+static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ genbind_node_for_each_type(genbind_node_getnode(node),
+ GENBIND_NODE_TYPE_STRING,
+ webidl_hdrcomments_cb,
+ ctx);
+ return 0;
+}
+
+static int
+output_header_comments(FILE *outfile, struct genbind_node *genbind_ast)
+{
+ fprintf(outfile, "/* "HDR_COMMENT_PREABLE);
+ genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_HDRCOMMENT,
+ webidl_hdrcomment_cb,
+ outfile);
+ fprintf(outfile,"\n */\n\n");
+ return 0;
+}
+
static int webidl_file_cb(struct genbind_node *node, void *ctx)
{
struct webidl_node **webidl_ast = ctx;
@@ -70,9 +102,13 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
{
FILE *outfile = NULL;
struct webidl_node *webidl_ast = NULL;
+ int res;
- read_webidl(genbind_ast, &webidl_ast);
-
+ res = read_webidl(genbind_ast, &webidl_ast);
+ if (res != 0) {
+ fprintf(stderr, "Error reading Web IDL files\n");
+ return 5;
+ }
/* open output file */
if (outfilename == NULL) {
@@ -88,6 +124,8 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 4;
}
+ output_header_comments(outfile, genbind_ast);
+
/* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
fprintf(outfile, "%s", genbind_ast->preamble);