summaryrefslogtreecommitdiff
path: root/src/jsapi-libdom.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-09-09 12:23:28 +0100
committerVincent Sanders <vince@kyllikki.org>2012-09-09 12:23:28 +0100
commit640ed1da81d909bb3c2f01a481e7e8d3336f336c (patch)
tree62213942cc809b290f5738fac6379a4d1ddc2acc /src/jsapi-libdom.c
parent03d0a9abbd49e099e4ef522bf60d621b9092ecc5 (diff)
downloadnsgenbind-640ed1da81d909bb3c2f01a481e7e8d3336f336c.tar.gz
nsgenbind-640ed1da81d909bb3c2f01a481e7e8d3336f336c.tar.bz2
split out output geenration
Diffstat (limited to 'src/jsapi-libdom.c')
-rw-r--r--src/jsapi-libdom.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
new file mode 100644
index 0000000..02033e1
--- /dev/null
+++ b/src/jsapi-libdom.c
@@ -0,0 +1,42 @@
+/* binding output generator for jsapi(spidermonkey) to libdom
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "genjsbind-ast.h"
+#include "jsapi-libdom.h"
+
+int jsapi_libdom_output(char *outfilename)
+{
+ FILE *outfile = NULL;
+ /* open output file */
+ if (outfilename == NULL) {
+ outfile = stdout;
+ } else {
+ outfile = fopen(outfilename, "w");
+ }
+
+ if (!outfile) {
+ fprintf(stderr, "Error opening output %s: %s\n",
+ outfilename,
+ strerror(errno));
+ return 4;
+ }
+
+ 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);
+
+ fclose(outfile);
+
+ return 0;
+}