summaryrefslogtreecommitdiff
path: root/javascript/jsapi/bindings/example.bnd
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/jsapi/bindings/example.bnd')
-rw-r--r--javascript/jsapi/bindings/example.bnd90
1 files changed, 90 insertions, 0 deletions
diff --git a/javascript/jsapi/bindings/example.bnd b/javascript/jsapi/bindings/example.bnd
new file mode 100644
index 000000000..897e9a530
--- /dev/null
+++ b/javascript/jsapi/bindings/example.bnd
@@ -0,0 +1,90 @@
+/* Binding to generate Navigator 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
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.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 <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+/*
+ * navigator properties for netsurf
+ *
+ * Property | Everyone else | NetSurf | Notes
+ * ------------+-----------------+--------------+------------------------------
+ * appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
+ * | | | constant as everyone returns
+ * | | | "Mozilla" which is dumb
+ * ------------+-----------------+--------------+------------------------------
+ * appName | "<Browsername>" | "NetSurf" | Browsers named other than
+ * | | | "Netscape", "Mozilla",
+ * | | | "Netscape Navigator",
+ * | | | "Microsoft Internet Explorer"
+ * | | | often other browser have
+ * | | | "(compatible with Netscape)"
+ * | | | append.
+ * ------------+-----------------+--------------+------------------------------
+ * appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
+ * | | | number e.g "3.0".
+ * ------------+-----------------+--------------+------------------------------
+ * language | "<lang>" | "<lang>" | The language the frontend is
+ * | | | configured for
+ * ------------+-----------------+--------------+------------------------------
+ * platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
+ * | | | eg "Linux x86_64"
+ * ------------+-----------------+--------------+------------------------------
+ * userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
+ * | | | with excessive lies
+ * ------------+-----------------+--------------+------------------------------
+ */
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* 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.
+ */
+ private "dom_document *" node;
+ private "struct html_content *" htmlc;
+}
+
+operation write %{
+ LOG(("content %p parser %p writing %s",
+ private->htmlc, private->htmlc->parser, text));
+
+ if (private->htmlc->parser != NULL) {
+ dom_hubbub_parser_insert_chunk(private->htmlc->parser, (uint8_t *)text, text_len);
+ }
+%}