Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/881daebce29e7c4c956a3...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/881daebce29e7c4c956a399...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/881daebce29e7c4c956a3999a...
The branch, vince/nsgenbind has been updated
via 881daebce29e7c4c956a3999aa9088179aa5b655 (commit)
via ac286c4a95f280fb9546f80f0e256543faa8354a (commit)
from b5313189058a15cf3a30709875fd4ced1d3a6927 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commitdiff/881daebce29e7c4c956...
commit 881daebce29e7c4c956a3999aa9088179aa5b655
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
get minimal window property functionality working on window object
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index c568385..c0b659e 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -30,6 +30,14 @@ operation prompt %{
warn_user(message, NULL);
%}
+getter window %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+getter self %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
api init %{
JSObject *user_proto;
@@ -119,7 +127,7 @@ binding window {
* context structure.
*
* internal are value stored in private context structure but not
- * passed to constructor.
+ * passed to constructor but are considered for property getters/setters.
*/
private "struct browser_window *" bw;
private "struct html_content *" htmlc;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commitdiff/ac286c4a95f280fb954...
commit ac286c4a95f280fb9546f80f0e256543faa8354a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add binding for window class
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 48cd1cf..db63050 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -11,6 +11,7 @@
S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
+JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
# 1: input file
# 2: output file
@@ -27,8 +28,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmlelement.c
-#htmldocument.c
+S_JSAPI = navigator.c console.c htmlelement.c
+#htmldocument.c window.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/bindings/htmldocument.bnd
b/javascript/jsapi/bindings/htmldocument.bnd
index 44f8ee6..c901141 100644
--- a/javascript/jsapi/bindings/htmldocument.bnd
+++ b/javascript/jsapi/bindings/htmldocument.bnd
@@ -1,4 +1,4 @@
-/* test binding to generate htmldocument */
+/* Binding to generate htmldocument */
#include "dom.bnd"
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
new file mode 100644
index 0000000..c568385
--- /dev/null
+++ b/javascript/jsapi/bindings/window.bnd
@@ -0,0 +1,130 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+api init %{
+ JSObject *user_proto;
+
+ prototype = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (prototype == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, prototype);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, prototype)) {
+ return NULL;
+ }
+
+ /* add functions to prototype */
+ if (!JS_DefineFunctions(cx, prototype, jsclass_functions)) {
+ return NULL;
+ }
+
+ /* add properties to prototype */
+ if (!JS_DefineProperties(cx, prototype, jsclass_properties))
+ return NULL;
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ user_proto = jsapi_InitClass_Document(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+%}
+
+api new %{
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* the window object is the global so its prototype *is* the instance */
+ newobject = prototype;
+
+ /* instantiate the subclasses off the window global */
+ private->document = jsapi_new_Document(cx,
+ NULL,
+ newobject,
+ htmlc->document,
+ htmlc);
+ if (private->document == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console = jsapi_new_Console(cx, newobject);
+ if (private->console == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ LOG(("Created new window object %p", newobject));
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ interface Window; /* Web IDL interface to generate */
+
+ /* private are parameters to constructor stored in private
+ * context structure.
+ *
+ * internal are value stored in private context structure but not
+ * passed to constructor.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+
+}
-----------------------------------------------------------------------
Summary of changes:
Makefile.sources.javascript | 5 +-
javascript/jsapi/bindings/htmldocument.bnd | 2 +-
javascript/jsapi/bindings/window.bnd | 138 ++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 3 deletions(-)
create mode 100644 javascript/jsapi/bindings/window.bnd
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 48cd1cf..db63050 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -11,6 +11,7 @@
S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
+JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
# 1: input file
# 2: output file
@@ -27,8 +28,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmlelement.c
-#htmldocument.c
+S_JSAPI = navigator.c console.c htmlelement.c
+#htmldocument.c window.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/bindings/htmldocument.bnd
b/javascript/jsapi/bindings/htmldocument.bnd
index 44f8ee6..c901141 100644
--- a/javascript/jsapi/bindings/htmldocument.bnd
+++ b/javascript/jsapi/bindings/htmldocument.bnd
@@ -1,4 +1,4 @@
-/* test binding to generate htmldocument */
+/* Binding to generate htmldocument */
#include "dom.bnd"
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
new file mode 100644
index 0000000..c0b659e
--- /dev/null
+++ b/javascript/jsapi/bindings/window.bnd
@@ -0,0 +1,138 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+getter window %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+getter self %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+api init %{
+ JSObject *user_proto;
+
+ prototype = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (prototype == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, prototype);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, prototype)) {
+ return NULL;
+ }
+
+ /* add functions to prototype */
+ if (!JS_DefineFunctions(cx, prototype, jsclass_functions)) {
+ return NULL;
+ }
+
+ /* add properties to prototype */
+ if (!JS_DefineProperties(cx, prototype, jsclass_properties))
+ return NULL;
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ user_proto = jsapi_InitClass_Document(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+%}
+
+api new %{
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* the window object is the global so its prototype *is* the instance */
+ newobject = prototype;
+
+ /* instantiate the subclasses off the window global */
+ private->document = jsapi_new_Document(cx,
+ NULL,
+ newobject,
+ htmlc->document,
+ htmlc);
+ if (private->document == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console = jsapi_new_Console(cx, newobject);
+ if (private->console == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ LOG(("Created new window object %p", newobject));
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ interface Window; /* Web IDL interface to generate */
+
+ /* private are parameters to constructor stored in private
+ * context structure.
+ *
+ * internal are value stored in private context structure but not
+ * passed to constructor but are considered for property getters/setters.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+
+}
--
NetSurf Browser