summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-08-05 22:58:05 +0100
committerVincent Sanders <vince@kyllikki.org>2015-08-05 22:58:05 +0100
commitdca5aa6db8f0dbcae283aee21605d8d1a85d7f94 (patch)
tree9c885d3bcedde0fbe557c63d61a385a0097a64d0
parent619dbd53bc4624e3a4e9bb291e61ed358272d009 (diff)
downloadnsgenbind-dca5aa6db8f0dbcae283aee21605d8d1a85d7f94.tar.gz
nsgenbind-dca5aa6db8f0dbcae283aee21605d8d1a85d7f94.tar.bz2
Add ptototype method type to binding
This allows additional cdata to be added to the generated prototype constructor.
-rw-r--r--src/duk-libdom.c15
-rw-r--r--src/nsgenbind-ast.h11
-rw-r--r--src/nsgenbind-lexer.l2
-rw-r--r--src/nsgenbind-parser.y6
4 files changed, 27 insertions, 7 deletions
diff --git a/src/duk-libdom.c b/src/duk-libdom.c
index 31ec0a1..b01ac4e 100644
--- a/src/duk-libdom.c
+++ b/src/duk-libdom.c
@@ -870,12 +870,23 @@ output_interface_prototype(FILE* outf,
struct interface_map_entry *interfacee,
struct interface_map_entry *inherite)
{
+ struct genbind_node *proto_node;
+
+ /* find the prototype method on the class */
+ proto_node = genbind_node_find_method(interfacee->class,
+ NULL,
+ GENBIND_METHOD_TYPE_PROTOTYPE);
+
/* prototype definition */
- fprintf(outf,
- "duk_ret_t %s_%s___proto(duk_context *ctx)\n",
+ fprintf(outf, "duk_ret_t %s_%s___proto(duk_context *ctx)\n",
DLPFX, interfacee->class_name);
fprintf(outf,"{\n");
+ /* Output any binding data first */
+ if (output_cdata(outf, proto_node, GENBIND_NODE_TYPE_CDATA) != 0) {
+ fprintf(outf,"\n");
+ }
+
/* generate prototype chaining if interface has a parent */
if (inherite != NULL) {
fprintf(outf,
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 0b0fcfd..2a384b2 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -45,11 +45,12 @@ enum genbind_type_modifier {
/* binding method types */
enum genbind_method_type {
- GENBIND_METHOD_TYPE_INIT = 0,
- GENBIND_METHOD_TYPE_FINI = 1, /**< */
- GENBIND_METHOD_TYPE_METHOD = 2, /**< */
- GENBIND_METHOD_TYPE_GETTER = 3, /**< */
- GENBIND_METHOD_TYPE_SETTER = 4, /**< */
+ GENBIND_METHOD_TYPE_INIT = 0, /**< binding method is initialiser */
+ GENBIND_METHOD_TYPE_FINI, /**< binding method is finalizer */
+ GENBIND_METHOD_TYPE_METHOD, /**< binding method is a method */
+ GENBIND_METHOD_TYPE_GETTER, /**< binding method is a getter */
+ GENBIND_METHOD_TYPE_SETTER, /**< binding method is a setter */
+ GENBIND_METHOD_TYPE_PROTOTYPE, /**< binding method is a prototype */
};
struct genbind_node;
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index f7b6528..d092195 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -135,6 +135,8 @@ getter return TOK_GETTER;
setter return TOK_SETTER;
+prototype return TOK_PROTOTYPE;
+
/* other terminals */
{dblcolon} return TOK_DBLCOLON;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 0f30dfc..1462b39 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -131,6 +131,7 @@ add_method(struct genbind_node **genbind_ast,
%token TOK_METHOD
%token TOK_GETTER
%token TOK_SETTER
+%token TOK_PROTOTYPE
%token TOK_DBLCOLON
@@ -339,6 +340,11 @@ MethodType
{
$$ = GENBIND_METHOD_TYPE_SETTER;
}
+ |
+ TOK_PROTOTYPE
+ {
+ $$ = GENBIND_METHOD_TYPE_PROTOTYPE;
+ }
;
ParameterList