From 26dc8906aeb0783cf36bde31e9051b29a193eb23 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 5 Sep 2012 11:38:56 +0100 Subject: make tests work add basic commandlien handling --- Makefile | 22 ++++- README | 10 +++ src/Makefile | 4 +- src/genbind-lexer.l | 53 ----------- src/genbind-parser.y | 58 ------------ src/genjsbind-lexer.l | 52 +++++++++++ src/genjsbind-parser.y | 60 +++++++++++++ src/genjsbind.c | 173 +++++++++++++++++++++++++++++++----- src/genjsbind.h | 1 + src/webidl-ast.h | 6 +- src/webidl-lexer.l | 1 - src/webidl-parser.y | 10 ++- test/Makefile | 7 ++ test/data/bindings/htmldocument.bnd | 4 + test/data/idl/document.idl | 37 ++++++++ test/data/idl/eventtarget.idl | 5 ++ test/data/idl/htmldocument.idl | 108 ++++++++++++++++++++++ test/data/idl/window.idl | 119 +++++++++++++++++++++++++ test/document.idl | 37 -------- test/eventtarget.idl | 5 -- test/htmldocument.bnd | 3 - test/htmldocument.idl | 108 ---------------------- test/testrunner.sh | 43 +++++++++ test/window.idl | 119 ------------------------- 24 files changed, 630 insertions(+), 415 deletions(-) create mode 100644 README delete mode 100644 src/genbind-lexer.l delete mode 100644 src/genbind-parser.y create mode 100644 src/genjsbind-lexer.l create mode 100644 src/genjsbind-parser.y create mode 100644 src/genjsbind.h create mode 100644 test/Makefile create mode 100644 test/data/bindings/htmldocument.bnd create mode 100644 test/data/idl/document.idl create mode 100644 test/data/idl/eventtarget.idl create mode 100644 test/data/idl/htmldocument.idl create mode 100644 test/data/idl/window.idl delete mode 100644 test/document.idl delete mode 100644 test/eventtarget.idl delete mode 100644 test/htmldocument.bnd delete mode 100644 test/htmldocument.idl create mode 100755 test/testrunner.sh delete mode 100644 test/window.idl diff --git a/Makefile b/Makefile index eab056a..decc5ce 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,29 @@ PREFIX ?= /opt/netsurf NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem include $(NSSHARED)/makefiles/Makefile.tools +TESTRUNNER := test/testrunner.sh + +# Toolchain flags +WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \ + -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ + -Wmissing-declarations -Wnested-externs -pedantic +# BeOS/Haiku/AmigaOS have standard library errors that issue warnings. +ifneq ($(TARGET),beos) + ifneq ($(TARGET),amiga) +# WARNFLAGS := $(WARNFLAGS) -Werror + endif +endif +CFLAGS := -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -I$(CURDIR)/include/ \ + -I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS) +ifneq ($(GCCVER),2) + CFLAGS := $(CFLAGS) -std=c99 +else + # __inline__ is a GCCism + CFLAGS := $(CFLAGS) -Dinline="__inline__" +endif + # Grab the core makefile include $(NSBUILD)/Makefile.top # Add extra install rules for our pkg-config control file and the library itself -#INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in INSTALL_ITEMS := $(INSTALL_ITEMS) /bin:$(BUILDDIR)/$(COMPONENT)$(EXEEXT) diff --git a/README b/README new file mode 100644 index 0000000..70d224f --- /dev/null +++ b/README @@ -0,0 +1,10 @@ +genjsbind +========= + +This is a tool to generate javascript to dom bindings from w3c webidl +files and a binding configuration file. + +building +-------- + +The tool requires bison and flex as pre-requisites \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 232a7dd..6740140 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ # Sources in this directory DIR_SOURCES := genjsbind.c -SOURCES := $(SOURCES) $(BUILDDIR)/genbind-parser.c $(BUILDDIR)/genbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c +SOURCES := $(SOURCES) $(BUILDDIR)/genjsbind-parser.c $(BUILDDIR)/genjsbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c $(BUILDDIR)/%-lexer.c $(BUILDDIR)/%-lexer.h: src/%-lexer.l $(VQ)$(ECHO) " FLEX: $<" @@ -31,7 +31,7 @@ endif $(BUILDDIR)/%-parser.c $(BUILDDIR)/%-parser.h: src/%-parser.y $(VQ)$(ECHO) " BISON: $<" - $(Q)bison -d -t $(BISON_DEFINES) --output=$(BUILDDIR)/$(*F)-parser.c --defines=$(BUILDDIR)/$(*F)-parser.h $< + $(Q)bison -d -t $(BISON_DEFINES) --report=all --output=$(BUILDDIR)/$(*F)-parser.c --defines=$(BUILDDIR)/$(*F)-parser.h $< # Grab the core makefile include $(NSBUILD)/Makefile.subdir diff --git a/src/genbind-lexer.l b/src/genbind-lexer.l deleted file mode 100644 index 6150f09..0000000 --- a/src/genbind-lexer.l +++ /dev/null @@ -1,53 +0,0 @@ -/* - * binding generator lexer - */ - -/* lexer options */ -%option never-interactive -%option bison-bridge -%option nodefault -%option warn -%option debug -%option prefix="genbind_" -%option nounput - -/* header block */ -%{ - -#include -#include -#include - -#include "genbind-parser.h" - -%} - - /* other Unicode “space separator” */ -USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80) - -/* non breaking space \u00A0 */ -NBSP (\xc2\xa0) - -whitespace ([ \t\v\f\n]|{NBSP}|{USP}) - -multicomment \/\*(([^*])|(\*[^/]))*\*\/ - -quotedstring [^\"\\\n\r] - -other [^\t\n\r 0-9A-Z_a-z] - -%% - -{whitespace} /* nothing */ - -webidlfile return TOK_IDLFILE; - -\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL; - -{multicomment} /* nothing */ - -{other} return (int) yytext[0]; - -. /* nothing */ - -%% \ No newline at end of file diff --git a/src/genbind-parser.y b/src/genbind-parser.y deleted file mode 100644 index cad20b4..0000000 --- a/src/genbind-parser.y +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This is a bison parser for genbind - * - */ - -%{ - -#include -#include - -#include "genbind-parser.h" -#include "genbind-lexer.h" - - extern int loadwebidl(char *filename); - -void genbind_error(const char *str) -{ - fprintf(stderr,"error: %s\n",str); -} - - -int genbind_wrap() -{ - return 1; -} - - - -%} - -%define api.pure - -%union -{ - char* text; -} - -%token TOK_IDLFILE - -%token TOK_STRING_LITERAL - -%% - - /* [1] start with instructions */ -Instructions: - /* empty */ - | - IdlFile - ; - -IdlFile: - TOK_IDLFILE TOK_STRING_LITERAL - { - loadwebidl($2); - } - ; - -%% diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l new file mode 100644 index 0000000..e976a8f --- /dev/null +++ b/src/genjsbind-lexer.l @@ -0,0 +1,52 @@ +/* + * binding generator lexer + */ + +/* lexer options */ +%option never-interactive +%option bison-bridge +%option nodefault +%option warn +%option prefix="genjsbind_" +%option nounput + +/* header block */ +%{ + +#include +#include +#include + +#include "genjsbind-parser.h" + +%} + + /* other Unicode “space separator” */ +USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80) + +/* non breaking space \u00A0 */ +NBSP (\xc2\xa0) + +whitespace ([ \t\v\f\n]|{NBSP}|{USP}) + +multicomment \/\*(([^*])|(\*[^/]))*\*\/ + +quotedstring [^\"\\\n\r] + +other [^\t\n\r 0-9A-Z_a-z] + +%% + +{whitespace} /* nothing */ + +webidlfile return TOK_IDLFILE; + +\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL; + +{multicomment} /* nothing */ + +{other} return (int) yytext[0]; + +. /* nothing */ + +%% diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y new file mode 100644 index 0000000..08b8926 --- /dev/null +++ b/src/genjsbind-parser.y @@ -0,0 +1,60 @@ +/* + * This is a bison parser for genbind + * + */ + +%{ + +#include +#include + +#include "genjsbind-parser.h" +#include "genjsbind-lexer.h" +#include "genjsbind.h" + +static void genjsbind_error(const char *str) +{ + fprintf(stderr,"error: %s\n",str); +} + + +int genjsbind_wrap() +{ + return 1; +} + + + +%} + +%define api.pure + +%union +{ + char* text; +} + +%token TOK_IDLFILE + +%token TOK_STRING_LITERAL + +%% + + /* [1] start with Statements */ +Statements: + /* empty */ + | + IdlFile + ; + + /* [2] load a web IDL file */ +IdlFile: + TOK_IDLFILE TOK_STRING_LITERAL ';' + { + if (loadwebidl($2) != 0) { + YYABORT; + } + } + ; + +%% diff --git a/src/genjsbind.c b/src/genjsbind.c index 150c780..145c16e 100644 --- a/src/genjsbind.c +++ b/src/genjsbind.c @@ -1,52 +1,177 @@ #include +#include +#include +#include +#include +#include +#include #include "webidl-ast.h" - #include "webidl-parser.h" -#include "genbind-parser.h" +#include "genjsbind-parser.h" +#include "genjsbind.h" extern int webidl_debug; +extern int webidl__flex_debug; extern FILE* webidl_in; -extern int webidl_parse(); +extern int webidl_parse(void); + +extern int genjsbind_debug; +extern int genjsbind__flex_debug; +extern FILE* genjsbind_in; +extern int genjsbind_parse(void); + +struct options { + char *outfilename; + char *infilename; + char *idlpath; + bool verbose; + bool debug; +}; + +struct options *options; + +static FILE *idlopen(const char *filename) +{ + FILE *idlfile; -extern int genbind_debug; -extern FILE* genbind_in; -extern int genbind_parse(); + if (options->idlpath == NULL) { + if (options->verbose) { + printf("Opening IDL file %s\n", filename); + } + idlfile = fopen(filename, "r"); + } else { + char *fullname; + int fulllen = strlen(options->idlpath) + strlen(filename) + 2; + fullname = malloc(fulllen); + snprintf(fullname, fulllen, "%s/%s", options->idlpath, filename); + if (options->verbose) { + printf("Opening IDL file %s\n", fullname); + } + idlfile = fopen(fullname, "r"); + free(fullname); + } + return idlfile; +} int loadwebidl(char *filename) { - FILE *myfile = fopen(filename, "r"); - if (!myfile) { - perror(filename); + /* set flex to read from file */ + webidl_in = idlopen(filename); + if (!webidl_in) { + fprintf(stderr, "Error opening %s: %s\n", + filename, + strerror(errno)); return 2; } - /* set flex to read from file */ - webidl_in = myfile; - webidl_debug = 1; + if (options->debug) { + webidl_debug = 1; + webidl__flex_debug = 1; + } - /* parse through the input until there is no more: */ - while (!feof(webidl_in)) { - webidl_parse(); + /* parse the file */ + return webidl_parse(); +} + + +static struct options* process_cmdline(int argc, char **argv) +{ + int opt; + + options = calloc(1,sizeof(struct options)); + if (options == NULL) { + fprintf(stderr, "Allocation error\n"); + return NULL; } - return 0; + + while ((opt = getopt(argc, argv, "vdI:o:")) != -1) { + switch (opt) { + case 'I': + options->idlpath = strdup(optarg); + break; + + case 'o': + options->outfilename = strdup(optarg); + break; + + case 'v': + options->verbose = true; + break; + + case 'd': + options->debug = true; + break; + + default: /* '?' */ + fprintf(stderr, + "Usage: %s [-I idlpath] [-o filename] inputfile\n", + argv[0]); + free(options); + return NULL; + + } + } + + if (optind >= argc) { + fprintf(stderr, "Error: expected input filename\n"); + free(options); + return NULL; + } + + options->infilename = strdup(argv[optind]); + + return options; + } int main(int argc, char **argv) { - FILE *myfile = fopen("htmldocument.bnd", "r"); - if (!myfile) { - perror(NULL); + FILE *infile; + int parse_res; + + options = process_cmdline(argc, argv); + if (options == NULL) { + return 1; /* bad commandline */ + } + + if (options->verbose && (options->outfilename == NULL)) { + fprintf(stderr, "Error: outputting to stdout with verbose logging would fail\n"); return 2; } + + if ((options->infilename[0] == '-') && + (options->infilename[1] == 0)) { + if (options->verbose) { + printf("Using stdin for input\n"); + } + infile = stdin; + } else { + if (options->verbose) { + printf("Opening binding file %s\n", options->infilename); + } + infile = fopen(options->infilename, "r"); + } + + if (!infile) { + fprintf(stderr, "Error opening %s: %s\n", + options->infilename, + strerror(errno)); + return 3; + } + /* set flex to read from file */ - genbind_in = myfile; + genjsbind_in = infile; - genbind_debug = 1; + if (options->debug) { + genjsbind_debug = 1; + genjsbind__flex_debug = 1; + } - /* parse through the input until there is no more: */ - while (!feof(genbind_in)) { - genbind_parse(); + parse_res = genjsbind_parse(); + if (parse_res) { + fprintf(stderr, "parse result was %d\n", parse_res); + return parse_res; } return 0; } diff --git a/src/genjsbind.h b/src/genjsbind.h new file mode 100644 index 0000000..69d2f59 --- /dev/null +++ b/src/genjsbind.h @@ -0,0 +1 @@ +extern int loadwebidl(char *filename); diff --git a/src/webidl-ast.h b/src/webidl-ast.h index 96d7c2a..f56c5d9 100644 --- a/src/webidl-ast.h +++ b/src/webidl-ast.h @@ -1,2 +1,4 @@ - struct ifmembers_s { - }; + +struct ifmembers_s { + char *name; +}; diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l index 1d2db67..20ee4c5 100644 --- a/src/webidl-lexer.l +++ b/src/webidl-lexer.l @@ -16,7 +16,6 @@ %option bison-locations %option nodefault %option warn -%option debug %option prefix="webidl_" %option nounput diff --git a/src/webidl-parser.y b/src/webidl-parser.y index 73ed2c6..c4e25f1 100644 --- a/src/webidl-parser.y +++ b/src/webidl-parser.y @@ -16,9 +16,9 @@ -void webidl_error(const char *str) +static void webidl_error(const char *str) { - fprintf(stderr,"error: %s\n",str); + fprintf(stderr,"error: %s\n",str); } int webidl_wrap() @@ -33,6 +33,12 @@ int webidl_wrap() %locations %define api.pure + /* the w3c grammar results in 10 shift/reduce, 2 reduce/reduce conflicts + * The reduce/reduce error are both the result of empty sequences + */ + /* %expect 10 */ + /* %expect-rr 2 */ + %union { int attr; diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..0e5236e --- /dev/null +++ b/test/Makefile @@ -0,0 +1,7 @@ + +TEST_TARGETS := $(TEST_TARGETS) test_bindings + +test_bindings: + $(Q)$(SHAREDLDPATH) $(TESTRUNNER) $(BUILDDIR) $(CURDIR)/test + +include $(NSBUILD)/Makefile.subdir diff --git a/test/data/bindings/htmldocument.bnd b/test/data/bindings/htmldocument.bnd new file mode 100644 index 0000000..4f3095f --- /dev/null +++ b/test/data/bindings/htmldocument.bnd @@ -0,0 +1,4 @@ +/* test binding docuemnt */ + +webidlfile "htmldocument.idl"; + diff --git a/test/data/idl/document.idl b/test/data/idl/document.idl new file mode 100644 index 0000000..afab566 --- /dev/null +++ b/test/data/idl/document.idl @@ -0,0 +1,37 @@ +interface Document : Node { + readonly attribute DOMImplementation implementation; + readonly attribute DOMString URL; + readonly attribute DOMString documentURI; + readonly attribute DOMString compatMode; + readonly attribute DOMString characterSet; + readonly attribute DOMString contentType; + + readonly attribute DocumentType? doctype; + readonly attribute Element? documentElement; + HTMLCollection getElementsByTagName(DOMString localName); + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + HTMLCollection getElementsByClassName(DOMString classNames); + Element? getElementById(DOMString elementId); + + Element createElement(DOMString localName); + Element createElementNS(DOMString? namespace, DOMString qualifiedName); + DocumentFragment createDocumentFragment(); + Text createTextNode(DOMString data); + Comment createComment(DOMString data); + ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); + + Node importNode(Node node, optional boolean deep = true); + Node adoptNode(Node node); + + Event createEvent(DOMString interface); + + Range createRange(); + + // NodeFilter.SHOW_ALL = 0xFFFFFFFF + NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); + TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); + + // NEW + void prepend((Node or DOMString)... nodes); + void append((Node or DOMString)... nodes); +}; diff --git a/test/data/idl/eventtarget.idl b/test/data/idl/eventtarget.idl new file mode 100644 index 0000000..2cfd15e --- /dev/null +++ b/test/data/idl/eventtarget.idl @@ -0,0 +1,5 @@ +interface EventTarget { + void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false); + void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false); + boolean dispatchEvent(Event event); +}; diff --git a/test/data/idl/htmldocument.idl b/test/data/idl/htmldocument.idl new file mode 100644 index 0000000..923aa08 --- /dev/null +++ b/test/data/idl/htmldocument.idl @@ -0,0 +1,108 @@ +[OverrideBuiltins] +partial interface Document { + // resource metadata management + [PutForwards=href] readonly attribute Location? location; + attribute DOMString domain; + readonly attribute DOMString referrer; + attribute DOMString cookie; + readonly attribute DOMString lastModified; + readonly attribute DOMString readyState; + + // DOM tree accessors + getter object (DOMString name); + attribute DOMString title; + attribute DOMString dir; + attribute HTMLElement? body; + readonly attribute HTMLHeadElement? head; + readonly attribute HTMLCollection images; + readonly attribute HTMLCollection embeds; + readonly attribute HTMLCollection plugins; + readonly attribute HTMLCollection links; + readonly attribute HTMLCollection forms; + readonly attribute HTMLCollection scripts; + NodeList getElementsByName(DOMString elementName); + NodeList getItems(optional DOMString typeNames); // microdata + readonly attribute DOMElementMap cssElementMap; + + // dynamic markup insertion + Document open(optional DOMString type, optional DOMString replace); + WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace); + void close(); + void write(DOMString... text); + void writeln(DOMString... text); + + // user interaction + readonly attribute WindowProxy? defaultView; + readonly attribute Element? activeElement; + boolean hasFocus(); + attribute DOMString designMode; + boolean execCommand(DOMString commandId); + boolean execCommand(DOMString commandId, boolean showUI); + boolean execCommand(DOMString commandId, boolean showUI, DOMString value); + boolean queryCommandEnabled(DOMString commandId); + boolean queryCommandIndeterm(DOMString commandId); + boolean queryCommandState(DOMString commandId); + boolean queryCommandSupported(DOMString commandId); + DOMString queryCommandValue(DOMString commandId); + readonly attribute HTMLCollection commands; + + // event handler IDL attributes + attribute EventHandler onabort; + attribute EventHandler onblur; + attribute EventHandler oncancel; + attribute EventHandler oncanplay; + attribute EventHandler oncanplaythrough; + attribute EventHandler onchange; + attribute EventHandler onclick; + attribute EventHandler onclose; + attribute EventHandler oncontextmenu; + attribute EventHandler oncuechange; + attribute EventHandler ondblclick; + attribute EventHandler ondrag; + attribute EventHandler ondragend; + attribute EventHandler ondragenter; + attribute EventHandler ondragleave; + attribute EventHandler ondragover; + attribute EventHandler ondragstart; + attribute EventHandler ondrop; + attribute EventHandler ondurationchange; + attribute EventHandler onemptied; + attribute EventHandler onended; + attribute OnErrorEventHandler onerror; + attribute EventHandler onfocus; + attribute EventHandler oninput; + attribute EventHandler oninvalid; + attribute EventHandler onkeydown; + attribute EventHandler onkeypress; + attribute EventHandler onkeyup; + attribute EventHandler onload; + attribute EventHandler onloadeddata; + attribute EventHandler onloadedmetadata; + attribute EventHandler onloadstart; + attribute EventHandler onmousedown; + attribute EventHandler onmousemove; + attribute EventHandler onmouseout; + attribute EventHandler onmouseover; + attribute EventHandler onmouseup; + attribute EventHandler onmousewheel; + attribute EventHandler onpause; + attribute EventHandler onplay; + attribute EventHandler onplaying; + attribute EventHandler onprogress; + attribute EventHandler onratechange; + attribute EventHandler onreset; + attribute EventHandler onscroll; + attribute EventHandler onseeked; + attribute EventHandler onseeking; + attribute EventHandler onselect; + attribute EventHandler onshow; + attribute EventHandler onstalled; + attribute EventHandler onsubmit; + attribute EventHandler onsuspend; + attribute EventHandler ontimeupdate; + attribute EventHandler onvolumechange; + attribute EventHandler onwaiting; + + // special event handler IDL attributes that only apply to Document objects + [LenientThis] attribute EventHandler onreadystatechange; +}; diff --git a/test/data/idl/window.idl b/test/data/idl/window.idl new file mode 100644 index 0000000..7114709 --- /dev/null +++ b/test/data/idl/window.idl @@ -0,0 +1,119 @@ +#include "eventtarget.idl" + +[NamedPropertiesObject] +interface Window : EventTarget { + // the current browsing context + [Unforgeable] readonly attribute WindowProxy window; + [Replaceable] readonly attribute WindowProxy self; + [Unforgeable] readonly attribute Document document; + attribute DOMString name; + [PutForwards=href, Unforgeable] readonly attribute Location location; + readonly attribute History history; + [Replaceable] readonly attribute BarProp locationbar; + [Replaceable] readonly attribute BarProp menubar; + [Replaceable] readonly attribute BarProp personalbar; + [Replaceable] readonly attribute BarProp scrollbars; + [Replaceable] readonly attribute BarProp statusbar; + [Replaceable] readonly attribute BarProp toolbar; + attribute DOMString status; + void close(); + void stop(); + void focus(); + void blur(); + + // other browsing contexts + [Replaceable] readonly attribute WindowProxy frames; + [Replaceable] readonly attribute unsigned long length; + [Unforgeable] readonly attribute WindowProxy top; + attribute WindowProxy? opener; + readonly attribute WindowProxy parent; + readonly attribute Element? frameElement; + WindowProxy open(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace); + getter WindowProxy (unsigned long index); + getter object (DOMString name); + + // the user agent + readonly attribute Navigator navigator; + readonly attribute External external; + readonly attribute ApplicationCache applicationCache; + + // user prompts + void alert(DOMString message); + boolean confirm(DOMString message); + DOMString? prompt(DOMString message, optional DOMString default); + void print(); + any showModalDialog(DOMString url, optional any argument); + + // cross-document messaging + void postMessage(any message, DOMString targetOrigin, optional sequence transfer); + + // event handler IDL attributes + attribute EventHandler onabort; + attribute EventHandler onafterprint; + attribute EventHandler onbeforeprint; + attribute EventHandler onbeforeunload; + attribute EventHandler onblur; + attribute EventHandler oncancel; + attribute EventHandler oncanplay; + attribute EventHandler oncanplaythrough; + attribute EventHandler onchange; + attribute EventHandler onclick; + attribute EventHandler onclose; + attribute EventHandler oncontextmenu; + attribute EventHandler oncuechange; + attribute EventHandler ondblclick; + attribute EventHandler ondrag; + attribute EventHandler ondragend; + attribute EventHandler ondragenter; + attribute EventHandler ondragleave; + attribute EventHandler ondragover; + attribute EventHandler ondragstart; + attribute EventHandler ondrop; + attribute EventHandler ondurationchange; + attribute EventHandler onemptied; + attribute EventHandler onended; + attribute OnErrorEventHandler onerror; + attribute EventHandler onfocus; + attribute EventHandler onhashchange; + attribute EventHandler oninput; + attribute EventHandler oninvalid; + attribute EventHandler onkeydown; + attribute EventHandler onkeypress; + attribute EventHandler onkeyup; + attribute EventHandler onload; + attribute EventHandler onloadeddata; + attribute EventHandler onloadedmetadata; + attribute EventHandler onloadstart; + attribute EventHandler onmessage; + attribute EventHandler onmousedown; + attribute EventHandler onmousemove; + attribute EventHandler onmouseout; + attribute EventHandler onmouseover; + attribute EventHandler onmouseup; + attribute EventHandler onmousewheel; + attribute EventHandler onoffline; + attribute EventHandler ononline; + attribute EventHandler onpause; + attribute EventHandler onplay; + attribute EventHandler onplaying; + attribute EventHandler onpagehide; + attribute EventHandler onpageshow; + attribute EventHandler onpopstate; + attribute EventHandler onprogress; + attribute EventHandler onratechange; + attribute EventHandler onreset; + attribute EventHandler onresize; + attribute EventHandler onscroll; + attribute EventHandler onseeked; + attribute EventHandler onseeking; + attribute EventHandler onselect; + attribute EventHandler onshow; + attribute EventHandler onstalled; + attribute EventHandler onstorage; + attribute EventHandler onsubmit; + attribute EventHandler onsuspend; + attribute EventHandler ontimeupdate; + attribute EventHandler onunload; + attribute EventHandler onvolumechange; + attribute EventHandler onwaiting; +}; diff --git a/test/document.idl b/test/document.idl deleted file mode 100644 index afab566..0000000 --- a/test/document.idl +++ /dev/null @@ -1,37 +0,0 @@ -interface Document : Node { - readonly attribute DOMImplementation implementation; - readonly attribute DOMString URL; - readonly attribute DOMString documentURI; - readonly attribute DOMString compatMode; - readonly attribute DOMString characterSet; - readonly attribute DOMString contentType; - - readonly attribute DocumentType? doctype; - readonly attribute Element? documentElement; - HTMLCollection getElementsByTagName(DOMString localName); - HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); - HTMLCollection getElementsByClassName(DOMString classNames); - Element? getElementById(DOMString elementId); - - Element createElement(DOMString localName); - Element createElementNS(DOMString? namespace, DOMString qualifiedName); - DocumentFragment createDocumentFragment(); - Text createTextNode(DOMString data); - Comment createComment(DOMString data); - ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); - - Node importNode(Node node, optional boolean deep = true); - Node adoptNode(Node node); - - Event createEvent(DOMString interface); - - Range createRange(); - - // NodeFilter.SHOW_ALL = 0xFFFFFFFF - NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); - TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); - - // NEW - void prepend((Node or DOMString)... nodes); - void append((Node or DOMString)... nodes); -}; diff --git a/test/eventtarget.idl b/test/eventtarget.idl deleted file mode 100644 index 2cfd15e..0000000 --- a/test/eventtarget.idl +++ /dev/null @@ -1,5 +0,0 @@ -interface EventTarget { - void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false); - void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false); - boolean dispatchEvent(Event event); -}; diff --git a/test/htmldocument.bnd b/test/htmldocument.bnd deleted file mode 100644 index 6f02c75..0000000 --- a/test/htmldocument.bnd +++ /dev/null @@ -1,3 +0,0 @@ -/* test binding docuemnt */ - -webidlfile "htmldocument.idl" diff --git a/test/htmldocument.idl b/test/htmldocument.idl deleted file mode 100644 index 923aa08..0000000 --- a/test/htmldocument.idl +++ /dev/null @@ -1,108 +0,0 @@ -[OverrideBuiltins] -partial interface Document { - // resource metadata management - [PutForwards=href] readonly attribute Location? location; - attribute DOMString domain; - readonly attribute DOMString referrer; - attribute DOMString cookie; - readonly attribute DOMString lastModified; - readonly attribute DOMString readyState; - - // DOM tree accessors - getter object (DOMString name); - attribute DOMString title; - attribute DOMString dir; - attribute HTMLElement? body; - readonly attribute HTMLHeadElement? head; - readonly attribute HTMLCollection images; - readonly attribute HTMLCollection embeds; - readonly attribute HTMLCollection plugins; - readonly attribute HTMLCollection links; - readonly attribute HTMLCollection forms; - readonly attribute HTMLCollection scripts; - NodeList getElementsByName(DOMString elementName); - NodeList getItems(optional DOMString typeNames); // microdata - readonly attribute DOMElementMap cssElementMap; - - // dynamic markup insertion - Document open(optional DOMString type, optional DOMString replace); - WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace); - void close(); - void write(DOMString... text); - void writeln(DOMString... text); - - // user interaction - readonly attribute WindowProxy? defaultView; - readonly attribute Element? activeElement; - boolean hasFocus(); - attribute DOMString designMode; - boolean execCommand(DOMString commandId); - boolean execCommand(DOMString commandId, boolean showUI); - boolean execCommand(DOMString commandId, boolean showUI, DOMString value); - boolean queryCommandEnabled(DOMString commandId); - boolean queryCommandIndeterm(DOMString commandId); - boolean queryCommandState(DOMString commandId); - boolean queryCommandSupported(DOMString commandId); - DOMString queryCommandValue(DOMString commandId); - readonly attribute HTMLCollection commands; - - // event handler IDL attributes - attribute EventHandler onabort; - attribute EventHandler onblur; - attribute EventHandler oncancel; - attribute EventHandler oncanplay; - attribute EventHandler oncanplaythrough; - attribute EventHandler onchange; - attribute EventHandler onclick; - attribute EventHandler onclose; - attribute EventHandler oncontextmenu; - attribute EventHandler oncuechange; - attribute EventHandler ondblclick; - attribute EventHandler ondrag; - attribute EventHandler ondragend; - attribute EventHandler ondragenter; - attribute EventHandler ondragleave; - attribute EventHandler ondragover; - attribute EventHandler ondragstart; - attribute EventHandler ondrop; - attribute EventHandler ondurationchange; - attribute EventHandler onemptied; - attribute EventHandler onended; - attribute OnErrorEventHandler onerror; - attribute EventHandler onfocus; - attribute EventHandler oninput; - attribute EventHandler oninvalid; - attribute EventHandler onkeydown; - attribute EventHandler onkeypress; - attribute EventHandler onkeyup; - attribute EventHandler onload; - attribute EventHandler onloadeddata; - attribute EventHandler onloadedmetadata; - attribute EventHandler onloadstart; - attribute EventHandler onmousedown; - attribute EventHandler onmousemove; - attribute EventHandler onmouseout; - attribute EventHandler onmouseover; - attribute EventHandler onmouseup; - attribute EventHandler onmousewheel; - attribute EventHandler onpause; - attribute EventHandler onplay; - attribute EventHandler onplaying; - attribute EventHandler onprogress; - attribute EventHandler onratechange; - attribute EventHandler onreset; - attribute EventHandler onscroll; - attribute EventHandler onseeked; - attribute EventHandler onseeking; - attribute EventHandler onselect; - attribute EventHandler onshow; - attribute EventHandler onstalled; - attribute EventHandler onsubmit; - attribute EventHandler onsuspend; - attribute EventHandler ontimeupdate; - attribute EventHandler onvolumechange; - attribute EventHandler onwaiting; - - // special event handler IDL attributes that only apply to Document objects - [LenientThis] attribute EventHandler onreadystatechange; -}; diff --git a/test/testrunner.sh b/test/testrunner.sh new file mode 100755 index 0000000..b717e34 --- /dev/null +++ b/test/testrunner.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +outline() { +echo >>${LOGFILE} +echo "-----------------------------------------------------------" >>${LOGFILE} +echo >>${LOGFILE} +} + +BUILDDIR=$1 +TESTDIR=$2 + +# locations +LOGFILE=${BUILDDIR}/testlog + +GENJSBIND=${BUILDDIR}/genjsbind + +BINDINGDIR=${TESTDIR}/data/bindings +BINDINGTESTS=$(ls ${BINDINGDIR}/*.bnd) + +IDLDIR=${TESTDIR}/data/idl + +echo "$*" >${LOGFILE} + +for TEST in ${BINDINGTESTS};do + + TESTNAME=$(basename ${TEST} .bnd) + + echo -n " TEST: ${TESTNAME}......" + outline + + echo ${GENJSBIND} -d -v -I ${IDLDIR} -o ${BUILDDIR}/test_${TESTNAME}.c ${TEST} >>${LOGFILE} 2>&1 + + ${GENJSBIND} -d -v -I ${IDLDIR} -o ${BUILDDIR}/test_${TESTNAME}.c ${TEST} >>${LOGFILE} 2>&1 + + if [ $? -eq 0 ]; then + echo "PASS" + else + echo "FAIL" + fi + + +done + diff --git a/test/window.idl b/test/window.idl deleted file mode 100644 index 7114709..0000000 --- a/test/window.idl +++ /dev/null @@ -1,119 +0,0 @@ -#include "eventtarget.idl" - -[NamedPropertiesObject] -interface Window : EventTarget { - // the current browsing context - [Unforgeable] readonly attribute WindowProxy window; - [Replaceable] readonly attribute WindowProxy self; - [Unforgeable] readonly attribute Document document; - attribute DOMString name; - [PutForwards=href, Unforgeable] readonly attribute Location location; - readonly attribute History history; - [Replaceable] readonly attribute BarProp locationbar; - [Replaceable] readonly attribute BarProp menubar; - [Replaceable] readonly attribute BarProp personalbar; - [Replaceable] readonly attribute BarProp scrollbars; - [Replaceable] readonly attribute BarProp statusbar; - [Replaceable] readonly attribute BarProp toolbar; - attribute DOMString status; - void close(); - void stop(); - void focus(); - void blur(); - - // other browsing contexts - [Replaceable] readonly attribute WindowProxy frames; - [Replaceable] readonly attribute unsigned long length; - [Unforgeable] readonly attribute WindowProxy top; - attribute WindowProxy? opener; - readonly attribute WindowProxy parent; - readonly attribute Element? frameElement; - WindowProxy open(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace); - getter WindowProxy (unsigned long index); - getter object (DOMString name); - - // the user agent - readonly attribute Navigator navigator; - readonly attribute External external; - readonly attribute ApplicationCache applicationCache; - - // user prompts - void alert(DOMString message); - boolean confirm(DOMString message); - DOMString? prompt(DOMString message, optional DOMString default); - void print(); - any showModalDialog(DOMString url, optional any argument); - - // cross-document messaging - void postMessage(any message, DOMString targetOrigin, optional sequence transfer); - - // event handler IDL attributes - attribute EventHandler onabort; - attribute EventHandler onafterprint; - attribute EventHandler onbeforeprint; - attribute EventHandler onbeforeunload; - attribute EventHandler onblur; - attribute EventHandler oncancel; - attribute EventHandler oncanplay; - attribute EventHandler oncanplaythrough; - attribute EventHandler onchange; - attribute EventHandler onclick; - attribute EventHandler onclose; - attribute EventHandler oncontextmenu; - attribute EventHandler oncuechange; - attribute EventHandler ondblclick; - attribute EventHandler ondrag; - attribute EventHandler ondragend; - attribute EventHandler ondragenter; - attribute EventHandler ondragleave; - attribute EventHandler ondragover; - attribute EventHandler ondragstart; - attribute EventHandler ondrop; - attribute EventHandler ondurationchange; - attribute EventHandler onemptied; - attribute EventHandler onended; - attribute OnErrorEventHandler onerror; - attribute EventHandler onfocus; - attribute EventHandler onhashchange; - attribute EventHandler oninput; - attribute EventHandler oninvalid; - attribute EventHandler onkeydown; - attribute EventHandler onkeypress; - attribute EventHandler onkeyup; - attribute EventHandler onload; - attribute EventHandler onloadeddata; - attribute EventHandler onloadedmetadata; - attribute EventHandler onloadstart; - attribute EventHandler onmessage; - attribute EventHandler onmousedown; - attribute EventHandler onmousemove; - attribute EventHandler onmouseout; - attribute EventHandler onmouseover; - attribute EventHandler onmouseup; - attribute EventHandler onmousewheel; - attribute EventHandler onoffline; - attribute EventHandler ononline; - attribute EventHandler onpause; - attribute EventHandler onplay; - attribute EventHandler onplaying; - attribute EventHandler onpagehide; - attribute EventHandler onpageshow; - attribute EventHandler onpopstate; - attribute EventHandler onprogress; - attribute EventHandler onratechange; - attribute EventHandler onreset; - attribute EventHandler onresize; - attribute EventHandler onscroll; - attribute EventHandler onseeked; - attribute EventHandler onseeking; - attribute EventHandler onselect; - attribute EventHandler onshow; - attribute EventHandler onstalled; - attribute EventHandler onstorage; - attribute EventHandler onsubmit; - attribute EventHandler onsuspend; - attribute EventHandler ontimeupdate; - attribute EventHandler onunload; - attribute EventHandler onvolumechange; - attribute EventHandler onwaiting; -}; -- cgit v1.2.3