diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-08-21 12:53:52 +0200 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-08-21 12:53:52 +0200 |
commit | b0f64cff2c94d1a208528e2ed91c15ab037dbbb1 (patch) | |
tree | 85160c531ec6dd0a51c1aaa276e668cbac64298b /src/duk-libdom-common.c | |
parent | 56eee21ccb63cb7f040c5ce07bc226fbd229330d (diff) | |
download | nsgenbind-b0f64cff2c94d1a208528e2ed91c15ab037dbbb1.tar.gz nsgenbind-b0f64cff2c94d1a208528e2ed91c15ab037dbbb1.tar.bz2 |
split up duk-libdom generation source as it had grown unweildy
Diffstat (limited to 'src/duk-libdom-common.c')
-rw-r--r-- | src/duk-libdom-common.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/duk-libdom-common.c b/src/duk-libdom-common.c new file mode 100644 index 0000000..9a0f660 --- /dev/null +++ b/src/duk-libdom-common.c @@ -0,0 +1,78 @@ +/* duktape binding generation implementation + * + * This file is part of nsgenbind. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org> + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <errno.h> +#include <ctype.h> + +#include "options.h" +#include "utils.h" +#include "nsgenbind-ast.h" +#include "webidl-ast.h" +#include "ir.h" +#include "duk-libdom.h" + +#define NSGENBIND_PREFACE \ + "/* Generated by nsgenbind\n" \ + " *\n" \ + " * nsgenbind is published under the MIT Licence.\n" \ + " * nsgenbind is similar to a compiler is a purely transformative tool which\n" \ + " * explicitly makes no copyright claim on this generated output\n" \ + " */" + +/* exported interface documented in duk-libdom.h */ +int output_tool_preface(FILE* outf) +{ + fprintf(outf, "%s\n", NSGENBIND_PREFACE); + + return 0; +} + +/* exported interface documented in duk-libdom.h */ +int output_cdata(FILE* outf, + struct genbind_node *node, + enum genbind_node_type nodetype) +{ + char *cdata; + int res = 0; + + cdata = genbind_node_gettext( + genbind_node_find_type( + genbind_node_getnode(node), + NULL, nodetype)); + if (cdata != NULL) { + fprintf(outf, "%s", cdata); + res = 1; + } + return res; +} + +/* exported interface documented in duk-libdom.h */ +int output_tool_prologue(FILE* outf) +{ + char *fpath; + + fpath = genb_fpath("binding.h"); + fprintf(outf, "\n#include \"%s\"\n", fpath); + free(fpath); + + fpath = genb_fpath("private.h"); + fprintf(outf, "#include \"%s\"\n", fpath); + free(fpath); + + fpath = genb_fpath("prototype.h"); + fprintf(outf, "#include \"%s\"\n", fpath); + free(fpath); + + return 0; +} |