diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-09-25 11:44:59 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-09-25 11:44:59 +0100 |
commit | 4a7185fd4a25b1456737b8fa2ac6a770a3e1721e (patch) | |
tree | 65280034968b4b04e000b43bcb3b8b4e1856c21e /src/duk-libdom-common.c | |
parent | 5b0ac4502fd4407d51c165e0ea4ef814b3253fa9 (diff) | |
download | nsgenbind-4a7185fd4a25b1456737b8fa2ac6a770a3e1721e.tar.gz nsgenbind-4a7185fd4a25b1456737b8fa2ac6a770a3e1721e.tar.bz2 |
Make the binding parser understand c types
Instead of c types being opaque strings this makes the bindig parser
understand them. This is necessary for extended attribute parsing in
future but also makes the binding more easily understandable.
Diffstat (limited to 'src/duk-libdom-common.c')
-rw-r--r-- | src/duk-libdom-common.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/duk-libdom-common.c b/src/duk-libdom-common.c index 9a0f660..a1298e9 100644 --- a/src/duk-libdom-common.c +++ b/src/duk-libdom-common.c @@ -76,3 +76,42 @@ int output_tool_prologue(FILE* outf) return 0; } + + +/* exported interface documented in duk-libdom.h */ +int output_ctype(FILE *outf, struct genbind_node *node, bool identifier) +{ + const char *type_cdata = NULL; + struct genbind_node *typename_node; + + typename_node = genbind_node_find_type(genbind_node_getnode(node), + NULL, + GENBIND_NODE_TYPE_NAME); + while (typename_node != NULL) { + type_cdata = genbind_node_gettext(typename_node); + + fprintf(outf, "%s", type_cdata); + + typename_node = genbind_node_find_type( + genbind_node_getnode(node), + typename_node, + GENBIND_NODE_TYPE_NAME); + + /* separate all but the last entry with spaces */ + if (typename_node != NULL) { + fputc(' ', outf); + } + } + + if (identifier) { + if ((type_cdata != NULL) && + (type_cdata[0] != '*') && + (type_cdata[0] != ' ')) { + fputc(' ', outf); + } + + output_cdata(outf, node, GENBIND_NODE_TYPE_IDENT); + } + + return 0; +} |