From c0f9ae95b9f5ac169f225d2b52d57d05599b6772 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 20 Dec 2012 17:00:06 +0000 Subject: change the javascript bindings to use generated headers --- Makefile.sources.javascript | 13 +-- javascript/jsapi.c | 6 +- javascript/jsapi/binding.h | 159 ------------------------------------ javascript/jsapi/console.bnd | 4 +- javascript/jsapi/event.bnd | 4 +- javascript/jsapi/htmlcollection.bnd | 6 +- javascript/jsapi/htmldocument.bnd | 10 ++- javascript/jsapi/htmlelement.bnd | 7 +- javascript/jsapi/location.bnd | 5 +- javascript/jsapi/navigator.bnd | 5 +- javascript/jsapi/node.bnd | 3 +- javascript/jsapi/nodelist.bnd | 6 +- javascript/jsapi/text.bnd | 6 +- javascript/jsapi/window.bnd | 14 +++- 14 files changed, 59 insertions(+), 189 deletions(-) delete mode 100644 javascript/jsapi/binding.h diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript index 3092d1b2f..4633e9d0d 100644 --- a/Makefile.sources.javascript +++ b/Makefile.sources.javascript @@ -23,9 +23,10 @@ JSAPI_BINDING_text := javascript/jsapi/text.bnd JSAPI_BINDING_node := javascript/jsapi/node.bnd JSAPI_BINDING_event := javascript/jsapi/event.bnd -# 1: input file -# 2: output file -# 3: binding name +# 1: input binding file +# 2: source output file +# 3: header output file +# 4: binding name define convert_jsapi_binding S_JSAPI_BINDING += $(2) @@ -33,7 +34,9 @@ D_JSAPI_BINDING += $(patsubst %.c,%.d,$(2)) $(2): $(1) $(OBJROOT)/created $$(VQ)echo " GENBIND: $(1)" - $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(patsubst %.c,%.h,$(2)) -o $(2) $(1) + $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(3) -o $(2) $(1) + +$(3): $(2) endef @@ -52,7 +55,7 @@ S_JSAPI := S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI)) -$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi))) +$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).h,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi))) else S_JAVASCRIPT += none.c diff --git a/javascript/jsapi.c b/javascript/jsapi.c index ef34371d1..7b68fe975 100644 --- a/javascript/jsapi.c +++ b/javascript/jsapi.c @@ -17,14 +17,16 @@ */ #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" - +#include "render/html_internal.h" #include "content/content.h" #include "javascript/content.h" #include "javascript/js.h" #include "utils/log.h" +#include "window.h" +#include "event.h" + static JSRuntime *rt; /* global runtime */ void js_initialise(void) diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h deleted file mode 100644 index 7b0f61428..000000000 --- a/javascript/jsapi/binding.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2012 Vincent Sanders - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * spidermonkey jsapi class bindings - */ - -#ifndef _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ -#define _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ - - -#include "render/html_internal.h" - -JSObject *jsapi_InitClass_Window(JSContext *cx, JSObject *parent); - -/** Create a new javascript window object - * - * @param cx The javascript context. - * @param parent The parent object or NULL for new global - * @param win_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Window(JSContext *cx, - JSObject *window, - JSObject *parent, - struct browser_window *bw, - html_content *htmlc); - -JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Location(JSContext *cx, - JSObject *window, - JSObject *parent, - nsurl *url, - html_content *htmlc); - - -JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent); - -/** Create a new javascript document object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Document(JSContext *cx, - JSObject *proto, - JSObject *parent, - dom_document *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_Console(JSContext *cx, JSObject *parent); -/** Create a new javascript console object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Console(JSContext *cx, JSObject *prototype, JSObject *parent); - - -JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent); -/** Create a new javascript navigator object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *proto, JSObject *parent); - -extern JSClass JSClass_HTMLElement; - -JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_HTMLElement(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_element *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_HTMLCollection(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_HTMLCollection(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_html_collection *collection, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_NodeList(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_NodeList(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_nodelist *nodelist, - struct html_content *htmlc); - - -extern JSClass JSClass_Text; - -JSObject *jsapi_InitClass_Text(JSContext *cx, JSObject *parent); -/** Create a new javascript text object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param node The dom node to use in the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Text(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_text *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_Node(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Node(JSContext *cx, - JSObject *prototype, - JSObject *parent); - -extern JSClass JSClass_Event; -JSObject *jsapi_InitClass_Event(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Event(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_event *event); - -#endif diff --git a/javascript/jsapi/console.bnd b/javascript/jsapi/console.bnd index 7c3484529..9b3d21f95 100644 --- a/javascript/jsapi/console.bnd +++ b/javascript/jsapi/console.bnd @@ -19,9 +19,9 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "console.h" %} diff --git a/javascript/jsapi/event.bnd b/javascript/jsapi/event.bnd index cc03c920a..b0880d91e 100644 --- a/javascript/jsapi/event.bnd +++ b/javascript/jsapi/event.bnd @@ -21,9 +21,9 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "event.h" %} diff --git a/javascript/jsapi/htmlcollection.bnd b/javascript/jsapi/htmlcollection.bnd index 5e99e48b8..38e14ed1d 100644 --- a/javascript/jsapi/htmlcollection.bnd +++ b/javascript/jsapi/htmlcollection.bnd @@ -23,9 +23,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmlelement.h" +#include "htmlcollection.h" %} diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index c29e470c2..ddf408a9f 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -25,12 +25,16 @@ preamble %{ #include "utils/log.h" #include "utils/corestrings.h" #include "utils/libdom.h" - #include "content/urldb.h" - #include "javascript/js.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmldocument.h" +#include "htmlelement.h" +#include "text.h" +#include "nodelist.h" +#include "location.h" %} diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index 3ede93bbf..48ebbdb64 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -24,10 +24,13 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" #include "utils/corestrings.h" - #include "javascript/js.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmlelement.h" +#include "text.h" +#include "location.h" %} diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd index 32677d1b5..85117a2ce 100644 --- a/javascript/jsapi/location.bnd +++ b/javascript/jsapi/location.bnd @@ -21,9 +21,10 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "location.h" %} diff --git a/javascript/jsapi/navigator.bnd b/javascript/jsapi/navigator.bnd index e63e9a9fd..d040edec2 100644 --- a/javascript/jsapi/navigator.bnd +++ b/javascript/jsapi/navigator.bnd @@ -24,14 +24,13 @@ preamble %{ #include "desktop/netsurf.h" #include "desktop/options.h" - #include "utils/config.h" #include "utils/useragent.h" #include "utils/log.h" #include "utils/utsname.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "navigator.h" /* * navigator properties for netsurf diff --git a/javascript/jsapi/node.bnd b/javascript/jsapi/node.bnd index bcf0ef7b3..49fd06bc5 100644 --- a/javascript/jsapi/node.bnd +++ b/javascript/jsapi/node.bnd @@ -23,7 +23,8 @@ preamble %{ #include "utils/log.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "node.h" %} diff --git a/javascript/jsapi/nodelist.bnd b/javascript/jsapi/nodelist.bnd index b57dc6e05..4aa8c47f5 100644 --- a/javascript/jsapi/nodelist.bnd +++ b/javascript/jsapi/nodelist.bnd @@ -20,9 +20,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "nodelist.h" +#include "htmlelement.h" %} diff --git a/javascript/jsapi/text.bnd b/javascript/jsapi/text.bnd index 42791d081..6b4352116 100644 --- a/javascript/jsapi/text.bnd +++ b/javascript/jsapi/text.bnd @@ -23,9 +23,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - +#include "render/html_internal.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "text.h" +#include "htmlelement.h" %} diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd index 6153e90aa..288b5b3d8 100644 --- a/javascript/jsapi/window.bnd +++ b/javascript/jsapi/window.bnd @@ -24,10 +24,20 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" #include "utils/corestrings.h" - +#include "render/html_internal.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "console.h" +#include "navigator.h" +#include "event.h" +#include "node.h" +#include "htmlcollection.h" +#include "nodelist.h" +#include "htmldocument.h" +#include "text.h" +#include "htmlelement.h" +#include "window.h" +#include "location.h" %} -- cgit v1.2.3