summaryrefslogtreecommitdiff
path: root/javascript/jsapi
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/jsapi')
-rw-r--r--javascript/jsapi/binding.h3
-rw-r--r--javascript/jsapi/bindings/console.bnd59
-rw-r--r--javascript/jsapi/bindings/window.bnd8
3 files changed, 68 insertions, 2 deletions
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 2d88c005b..80340a57a 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -57,13 +57,14 @@ JSObject *jsapi_new_Document(JSContext *cx,
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 *parent);
+JSObject *jsapi_new_Console(JSContext *cx, JSObject *prototype, JSObject *parent);
JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent);
diff --git a/javascript/jsapi/bindings/console.bnd b/javascript/jsapi/bindings/console.bnd
new file mode 100644
index 000000000..6aef9dcb8
--- /dev/null
+++ b/javascript/jsapi/bindings/console.bnd
@@ -0,0 +1,59 @@
+/* Binding to generate Console interface
+ *
+ * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+webidlfile "console.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Console; /* Web IDL interface to generate */
+
+ /* private members:
+ * - stored in private context structure.
+ * - passed as parameters to constructor and stored automatically.
+ * - are *not* considered for property getters/setters.
+ *
+ * internal members:
+ * - value stored in private context structure
+ * - not passed to constructor
+ * - must be instantiated by constructor
+ * - are considered for property getters/setters.
+ */
+ internal "void *" gui_console;
+}
+
+operation log %{
+ unsigned int argloop;
+ JSString *jsstr;
+ unsigned long jsstrlen;
+ char *txt;
+
+ for (argloop = 0; argloop < argc; argloop++) {
+ jsstr = JS_ValueToString(cx, argv[argloop]);
+
+ JSString_to_char(jsstr, txt, jsstrlen);
+ LOG(("%s", txt));
+ }
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index 9d4a844a1..ba2db52b2 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -84,6 +84,12 @@ api init %{
if (user_proto == NULL) {
return NULL;
}
+
+ user_proto = jsapi_InitClass_Console(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
@@ -112,7 +118,7 @@ api new %{
/** @todo forms, history, location */
- private->console = jsapi_new_Console(cx, newobject);
+ private->console = jsapi_new_Console(cx, NULL, newobject);
if (private->console == NULL) {
free(private);
return NULL;