summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-09-28 14:57:14 +0100
committerVincent Sanders <vince@kyllikki.org>2015-09-28 14:57:14 +0100
commit476bc961ae4c490dfa0f09293c5611451bb42599 (patch)
treeddf5deaae2d8a34e628555130914a933602d3eec
parentc80955dcc6b663c250a1f2552b626770fbd46a94 (diff)
downloadnsgenbind-476bc961ae4c490dfa0f09293c5611451bb42599.tar.gz
nsgenbind-476bc961ae4c490dfa0f09293c5611451bb42599.tar.bz2
Allow empty classes
-rw-r--r--README54
-rw-r--r--src/nsgenbind-parser.y14
-rw-r--r--test/data/bindings/browser-duk.bnd4
3 files changed, 66 insertions, 6 deletions
diff --git a/README b/README
index f2a8bf3..4d08ff2 100644
--- a/README
+++ b/README
@@ -118,7 +118,7 @@ The binding file consists of three types of element:
but without at least one the binding is not very useful as
it will generate no output.
- preface
+ preface
This takes a cdata block. There may only be one of these per
binding, subsequent directives will be ignored.
@@ -160,6 +160,10 @@ The binding file consists of three types of element:
private member variables are declared here and header and
footer elements specific to this class.
+ Although not generally useful, because methods that reference a
+ class cause it to be implicitly created, empty definitions are
+ permitted.
+
private
variables added to the private structure for the class.
@@ -219,6 +223,54 @@ The binding file consists of three types of element:
binding but they will almost certainly have to be translated
into more suitable class names for generated output.
+
+ preface
+
+ The declarator for this method type need only identify the
+ class (an identifier may be provided but will be ignored).
+
+ This takes a cdata block. There may only be one of these per
+ class, subsequent directives will be ignored.
+
+ The preface is emitted in every generated source file after
+ the binding preface and tool preamble.
+
+
+ prologue
+
+ The declarator for this method type need only identify the
+ class (an identifier may be provided but will be ignored).
+
+ This takes a cdata block. There may only be one of these per
+ class, subsequent directives will be ignored.
+
+ The prologue is emitted in every generated source file after
+ the binding prologue has been generated.
+
+
+ epilogue
+
+ The declarator for this method type need only identify the
+ class (an identifier may be provided but will be ignored).
+
+ This takes a cdata block. There may only be one of these per
+ class, subsequent directives will be ignored.
+
+ The epilogue is emitted after the generated code and before
+ the binding epilogue
+
+
+ postface
+
+ The declarator for this method type need only identify the
+ class (an identifier may be provided but will be ignored).
+
+ This takes a cdata block. There may only be one of these per
+ class, subsequent directives will be ignored.
+
+ The postface is emitted after the binding epilogue.
+
+
init
The declarator for this method type need only identify the
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index a3e5609..88c69b1 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -55,9 +55,9 @@ typedef struct YYLTYPE {
}
%initial-action {
- yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = 1;
- yylloc.filename = filename;
+ yylloc.first_line = yylloc.last_line = 1;
+ yylloc.first_column = yylloc.last_column = 1;
+ yylloc.filename = filename;
}
%code {
@@ -105,7 +105,7 @@ add_method(struct genbind_node **genbind_ast,
long methodtype,
struct genbind_node *declarator,
char *cdata,
- int lineno,
+ long lineno,
char *filename)
{
struct genbind_node *res_node;
@@ -134,7 +134,6 @@ add_method(struct genbind_node **genbind_ast,
cdata);
}
-
location_node = genbind_new_node(GENBIND_NODE_TYPE_FILE,
genbind_new_node(GENBIND_NODE_TYPE_LINE,
cdata_node,
@@ -522,6 +521,11 @@ Class:
;
ClassArgs:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
ClassArg
|
ClassArgs ClassArg
diff --git a/test/data/bindings/browser-duk.bnd b/test/data/bindings/browser-duk.bnd
index cef3563..3113891 100644
--- a/test/data/bindings/browser-duk.bnd
+++ b/test/data/bindings/browser-duk.bnd
@@ -39,6 +39,10 @@ binding duk_libdom {
%};
};
+class empty_class {
+};
+
+
#include "HTMLUnknownElement.bnd"
/* specialisations of html_element */