From ce321410577f384e19042ea20b30ed6cbb00eda2 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 12 Oct 2015 17:40:35 +0100 Subject: [PATCH] Split up javascript engine makefiles by splitting javascript engine specific makefiles and source up we avoid having to consider old JSAPI or none code while working on duktape. --- javascript/Makefile | 101 +++++-------------------------- javascript/duktape/Makefile | 37 +++++++++++ javascript/{ => duktape}/dukky.c | 36 +++++------ javascript/{ => duktape}/dukky.h | 0 javascript/duktape/netsurf.bnd | 2 +- javascript/jsapi/Makefile | 53 ++++++++++++++++ javascript/{ => jsapi}/jsapi.c | 0 javascript/{ => jsapi}/jsapi.h | 0 javascript/none/Makefile | 9 +++ javascript/{ => none}/none.c | 0 10 files changed, 134 insertions(+), 104 deletions(-) create mode 100644 javascript/duktape/Makefile rename javascript/{ => duktape}/dukky.c (96%) rename javascript/{ => duktape}/dukky.h (100%) create mode 100644 javascript/jsapi/Makefile rename javascript/{ => jsapi}/jsapi.c (100%) rename javascript/{ => jsapi}/jsapi.h (100%) create mode 100644 javascript/none/Makefile rename javascript/{ => none}/none.c (100%) diff --git a/javascript/Makefile b/javascript/Makefile index 3b8bf48a4..36f123b64 100644 --- a/javascript/Makefile +++ b/javascript/Makefile @@ -1,103 +1,34 @@ # # NetSurf javascript source file inclusion # -# Included by Makefile.sources +# Included by Makefile # -# ---------------------------------------------------------------------------- -# JSAPI binding -# ---------------------------------------------------------------------------- - -S_JSAPI_BINDING:= -D_JSAPI_BINDING:= - -JSAPI_BINDING_htmldocument := javascript/jsapi/htmldocument.bnd -JSAPI_BINDING_htmlelement := javascript/jsapi/htmlelement.bnd -JSAPI_BINDING_window := javascript/jsapi/window.bnd -JSAPI_BINDING_navigator := javascript/jsapi/navigator.bnd -JSAPI_BINDING_console := javascript/jsapi/console.bnd -JSAPI_BINDING_location := javascript/jsapi/location.bnd -JSAPI_BINDING_htmlcollection := javascript/jsapi/htmlcollection.bnd -JSAPI_BINDING_nodelist := javascript/jsapi/nodelist.bnd -JSAPI_BINDING_text := javascript/jsapi/text.bnd -JSAPI_BINDING_comment := javascript/jsapi/comment.bnd -JSAPI_BINDING_node := javascript/jsapi/node.bnd -JSAPI_BINDING_event := javascript/jsapi/event.bnd - -# 1: input binding file -# 2: source output file -# 3: header output file -# 4: binding name -define convert_jsapi_binding - -S_JSAPI_BINDING += $(2) -D_JSAPI_BINDING += $(patsubst %.c,%.d,$(2)) - -$(2): $(1) $(OBJROOT)/created - $$(VQ)echo " GENBIND: $(1)" - $(Q)nsgenbind -g -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(3) -o $(2) $(1) - -$(3): $(2) - -endef - -# Javascript sources +# Check if jsapi is required ifeq ($(NETSURF_USE_JS),YES) WANT_JS_SOURCE := YES -endif - +else ifeq ($(NETSURF_USE_MOZJS),YES) WANT_JS_SOURCE := YES endif +endif + +S_JAVASCRIPT_BINDING:= ifeq ($(WANT_JS_SOURCE),YES) - -S_JSAPI := - -S_JAVASCRIPT += content.c jsapi.c fetcher.c $(addprefix jsapi/,$(S_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))) - -ifeq ($(filter $(MAKECMDGOALS),clean test coverage),) --include $(D_JSAPI_BINDING) -endif - +# JSAPI (spidemonkey) +include javascript/jsapi/Makefile else ifeq ($(NETSURF_USE_DUKTAPE),YES) - -javascript/dukky.c: $(OBJROOT)/duktape/binding.h - -BINDINGS := $(wildcard javascript/duktape/*.bnd) - -$(OBJROOT)/duktape/binding.h $(OBJROOT)/duktape/Makefile: javascript/duktape/netsurf.bnd $(BINDINGS) - $(Q)mkdir -p $(OBJROOT)/duktape - $(VQ)echo " GENBIND: $<" - $(Q)nsgenbind -D -I javascript/WebIDL $< $(OBJROOT)/duktape - -# create unimplemented report for doxygen -Docs/UnimplementedJavascript.txt: javascript/duktape/netsurf.bnd $(BINDINGS) - $(Q)mkdir -p $(OBJROOT)/duktape - $(VQ)echo "/** \page unimplemented Unimplemented javascript bindings" > $@ - $(VQ)echo "This is a list of all the binding methods, getters and setters without an implementation in a binding." >> $@ - $(VQ)echo "" >> $@ - $(VQ)echo " GENBIND: $<" - $(Q)nsgenbind -Wunimplemented -I javascript/WebIDL $< $(OBJROOT)/duktape 2>&1 >/dev/null | grep "Unimplemented" | cut -d' ' -f4- | sort -k 2 | awk '{print $$0"\\n" }' >> $@ - $(VQ)echo "*/" >> $@ - -ifeq ($(filter $(MAKECMDGOALS),clean test coverage),) --include $(OBJROOT)/duktape/Makefile -endif - -S_JSAPI_BINDING:=$(addprefix $(OBJROOT)/duktape/,$(NSGENBIND_SOURCES)) - -$(S_JSAPI_BINDING): $(BINDINGS) - -S_JAVASCRIPT += dukky.c content.c fetcher.c duktape/duktape.c - -CFLAGS += -DDUK_OPT_HAVE_CUSTOM_H +# Duktape +include javascript/duktape/Makefile else -S_JAVASCRIPT += none.c fetcher.c +# None +include javascript/none/Makefile endif endif -S_JAVASCRIPT := $(addprefix javascript/,$(S_JAVASCRIPT)) $(S_JSAPI_BINDING) +# Fetcher for javascript scheme is always required +S_JAVASCRIPT += fetcher.c + +S_JAVASCRIPT := $(addprefix javascript/,$(S_JAVASCRIPT)) $(S_JAVASCRIPT_BINDING) diff --git a/javascript/duktape/Makefile b/javascript/duktape/Makefile new file mode 100644 index 000000000..6f7019a7f --- /dev/null +++ b/javascript/duktape/Makefile @@ -0,0 +1,37 @@ +# +# NetSurf javascript source file inclusion +# +# Included by javascript/Makefile +# + +javascript/dukky.c: $(OBJROOT)/duktape/binding.h + +BINDINGS := $(wildcard javascript/duktape/*.bnd) + +$(OBJROOT)/duktape/binding.h $(OBJROOT)/duktape/Makefile: javascript/duktape/netsurf.bnd $(BINDINGS) + $(Q)mkdir -p $(OBJROOT)/duktape + $(VQ)echo " GENBIND: $<" + $(Q)nsgenbind -D -g -I javascript/WebIDL $< $(OBJROOT)/duktape + $(VQ)echo " GENBIND: completed" + +# create unimplemented report for doxygen +Docs/UnimplementedJavascript.txt: javascript/duktape/netsurf.bnd $(BINDINGS) + $(Q)mkdir -p $(OBJROOT)/duktape + $(VQ)echo "/** \page unimplemented Unimplemented javascript bindings" > $@ + $(VQ)echo "This is a list of all the binding methods, getters and setters without an implementation in a binding." >> $@ + $(VQ)echo "" >> $@ + $(VQ)echo " GENBIND: $<" + $(Q)nsgenbind -Wunimplemented -I javascript/WebIDL $< $(OBJROOT)/duktape 2>&1 >/dev/null | grep "Unimplemented" | cut -d' ' -f4- | sort -k 2 | awk '{print $$0"\\n" }' >> $@ + $(VQ)echo "*/" >> $@ + +ifeq ($(filter $(MAKECMDGOALS),clean test coverage),) +-include $(OBJROOT)/duktape/Makefile +endif + +S_JAVASCRIPT_BINDING:=$(addprefix $(OBJROOT)/duktape/,$(NSGENBIND_SOURCES)) + +$(S_JAVASCRIPT_BINDING): $(BINDINGS) + +S_JAVASCRIPT += content.c duktape/dukky.c duktape/duktape.c + +CFLAGS += -DDUK_OPT_HAVE_CUSTOM_H diff --git a/javascript/dukky.c b/javascript/duktape/dukky.c similarity index 96% rename from javascript/dukky.c rename to javascript/duktape/dukky.c index 96f78b9a4..9e3608037 100644 --- a/javascript/dukky.c +++ b/javascript/duktape/dukky.c @@ -32,7 +32,7 @@ #include "duktape/binding.h" -#include "duktape/duktape.h" +#include "duktape.h" #include "dukky.h" #include @@ -143,16 +143,16 @@ dukky_push_node_klass(duk_context *ctx, struct dom_node *node) { dom_node_type nodetype; dom_exception err; - + err = dom_node_get_node_type(node, &nodetype); if (err != DOM_NO_ERR) { /* Oh bum, just node then */ duk_push_string(ctx, PROTO_NAME(NODE)); return; } - + switch(nodetype) { - case DOM_ELEMENT_NODE: { + case DOM_ELEMENT_NODE: { dom_string *namespace, *tag; err = dom_node_get_namespace(node, &namespace); if (err != DOM_NO_ERR) { @@ -167,7 +167,7 @@ dukky_push_node_klass(duk_context *ctx, struct dom_node *node) duk_push_string(ctx, PROTO_NAME(ELEMENT)); break; } - + if (dom_string_isequal(namespace, corestring_dom_html_namespace) == false) { /* definitely not an HTML element of some kind */ duk_push_string(ctx, PROTO_NAME(ELEMENT)); @@ -175,13 +175,13 @@ dukky_push_node_klass(duk_context *ctx, struct dom_node *node) break; } dom_string_unref(namespace); - + err = dom_node_get_node_name(node, &tag); if (err != DOM_NO_ERR) { duk_push_string(ctx, PROTO_NAME(HTMLUNKNOWNELEMENT)); break; } - + duk_push_string(ctx, PROTO_NAME(HTML)); duk_push_lstring(ctx, dom_string_data(tag), dom_string_length(tag)); dom_string_unref(tag); @@ -190,23 +190,23 @@ dukky_push_node_klass(duk_context *ctx, struct dom_node *node) break; } - case DOM_TEXT_NODE: + case DOM_TEXT_NODE: duk_push_string(ctx, PROTO_NAME(TEXT)); break; - case DOM_COMMENT_NODE: + case DOM_COMMENT_NODE: duk_push_string(ctx, PROTO_NAME(COMMENT)); break; - case DOM_DOCUMENT_NODE: + case DOM_DOCUMENT_NODE: duk_push_string(ctx, PROTO_NAME(DOCUMENT)); break; - case DOM_ATTRIBUTE_NODE: - case DOM_PROCESSING_INSTRUCTION_NODE: + case DOM_ATTRIBUTE_NODE: + case DOM_PROCESSING_INSTRUCTION_NODE: case DOM_DOCUMENT_TYPE_NODE: - case DOM_DOCUMENT_FRAGMENT_NODE: - case DOM_NOTATION_NODE: + case DOM_DOCUMENT_FRAGMENT_NODE: + case DOM_NOTATION_NODE: case DOM_ENTITY_REFERENCE_NODE: - case DOM_ENTITY_NODE: - case DOM_CDATA_SECTION_NODE: + case DOM_ENTITY_NODE: + case DOM_CDATA_SECTION_NODE: default: /* Oh bum, just node then */ duk_push_string(ctx, PROTO_NAME(NODE)); @@ -342,11 +342,11 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv) duk_push_global_object(CTX); duk_put_prop_string(CTX, -2, PROTO_MAGIC); duk_set_global_object(CTX); - + /* Now we need to prepare our node mapping table */ duk_push_object(CTX); duk_put_global_string(CTX, NODE_MAGIC); - + return (jsobject *)ctx; } diff --git a/javascript/dukky.h b/javascript/duktape/dukky.h similarity index 100% rename from javascript/dukky.h rename to javascript/duktape/dukky.h diff --git a/javascript/duktape/netsurf.bnd b/javascript/duktape/netsurf.bnd index 12292454c..c60b66752 100644 --- a/javascript/duktape/netsurf.bnd +++ b/javascript/duktape/netsurf.bnd @@ -47,7 +47,7 @@ struct dom_html_br_element; %}; prologue %{ -#include "javascript/dukky.h" +#include "javascript/duktape/dukky.h" %}; }; diff --git a/javascript/jsapi/Makefile b/javascript/jsapi/Makefile new file mode 100644 index 000000000..f684287ab --- /dev/null +++ b/javascript/jsapi/Makefile @@ -0,0 +1,53 @@ +# +# NetSurf javascript source file inclusion +# +# Included by javascript/Makefile +# + +# ---------------------------------------------------------------------------- +# JSAPI binding +# ---------------------------------------------------------------------------- + +D_JSAPI_BINDING:= + +JSAPI_BINDING_htmldocument := javascript/jsapi/htmldocument.bnd +JSAPI_BINDING_htmlelement := javascript/jsapi/htmlelement.bnd +JSAPI_BINDING_window := javascript/jsapi/window.bnd +JSAPI_BINDING_navigator := javascript/jsapi/navigator.bnd +JSAPI_BINDING_console := javascript/jsapi/console.bnd +JSAPI_BINDING_location := javascript/jsapi/location.bnd +JSAPI_BINDING_htmlcollection := javascript/jsapi/htmlcollection.bnd +JSAPI_BINDING_nodelist := javascript/jsapi/nodelist.bnd +JSAPI_BINDING_text := javascript/jsapi/text.bnd +JSAPI_BINDING_comment := javascript/jsapi/comment.bnd +JSAPI_BINDING_node := javascript/jsapi/node.bnd +JSAPI_BINDING_event := javascript/jsapi/event.bnd + +# 1: input binding file +# 2: source output file +# 3: header output file +# 4: binding name +define convert_jsapi_binding + +S_JAVASCRIPT_BINDING += $(2) +D_JSAPI_BINDING += $(patsubst %.c,%.d,$(2)) + +$(2): $(1) $(OBJROOT)/created + $$(VQ)echo " GENBIND: $(1)" + $(Q)nsgenbind -g -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(3) -o $(2) $(1) + +$(3): $(2) + +endef + + +S_JSAPI := + +S_JAVASCRIPT += content.c jsapi/jsapi.c $(addprefix jsapi/,$(S_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))) + +ifeq ($(filter $(MAKECMDGOALS),clean test coverage),) +-include $(D_JSAPI_BINDING) +endif + diff --git a/javascript/jsapi.c b/javascript/jsapi/jsapi.c similarity index 100% rename from javascript/jsapi.c rename to javascript/jsapi/jsapi.c diff --git a/javascript/jsapi.h b/javascript/jsapi/jsapi.h similarity index 100% rename from javascript/jsapi.h rename to javascript/jsapi/jsapi.h diff --git a/javascript/none/Makefile b/javascript/none/Makefile new file mode 100644 index 000000000..ec7826da4 --- /dev/null +++ b/javascript/none/Makefile @@ -0,0 +1,9 @@ +# +# NetSurf javascript source file inclusion +# +# Included by javascript/Makefile +# + +# no javascript interpreter + +S_JAVASCRIPT += none/none.c \ No newline at end of file diff --git a/javascript/none.c b/javascript/none/none.c similarity index 100% rename from javascript/none.c rename to javascript/none/none.c