summaryrefslogtreecommitdiff
path: root/javascript/duktape/html_collection.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-07-19 16:50:46 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-07-19 16:50:46 +0100
commit72a78ba9f5e2098480b922ab5cb5117ecdb05b36 (patch)
tree5a105118a75d8d896d78a000f336fb3c212edc7a /javascript/duktape/html_collection.c
parent8ec9e559e00f7c2288fa724591208e710690eff5 (diff)
downloadnetsurf-72a78ba9f5e2098480b922ab5cb5117ecdb05b36.tar.gz
netsurf-72a78ba9f5e2098480b922ab5cb5117ecdb05b36.tar.bz2
Getting further
Diffstat (limited to 'javascript/duktape/html_collection.c')
-rw-r--r--javascript/duktape/html_collection.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/javascript/duktape/html_collection.c b/javascript/duktape/html_collection.c
new file mode 100644
index 000000000..835398a0e
--- /dev/null
+++ b/javascript/duktape/html_collection.c
@@ -0,0 +1,48 @@
+/* DO NOT USE, DODGY EXAMPLE FOR VINCE */
+
+#include "utils/log.h"
+
+#include <dom/dom.h>
+
+#include "javascript/dukky.h"
+
+DUKKY_FUNC_INIT(html_collection, struct dom_html_collection *coll)
+{
+ LOG("Initialise %p (priv=%p)", duk_get_heapptr(ctx, 0), priv);
+ priv->coll = coll;
+ dom_html_collection_ref(coll);
+}
+
+DUKKY_FUNC_FINI(html_collection)
+{
+ /* do any html_collection finalisation here, priv ptr exists */
+ LOG("Finalise %p", duk_get_heapptr(ctx, 0));
+ dom_html_collection_unref(priv->coll);
+}
+
+static DUKKY_FUNC(html_collection, __constructor)
+{
+ DUKKY_CREATE_PRIVATE(html_collection);
+ DUKKY_FUNC_T(html_collection, __init)(ctx, priv,
+ duk_get_pointer(ctx, 1));
+ return 1;
+}
+
+static DUKKY_FUNC(html_collection, __destructor)
+{
+ DUKKY_SAFE_GET_PRIVATE(html_collection, 0);
+ DUKKY_FUNC_T(html_collection, __fini)(ctx, priv);
+ free(priv);
+ return 0;
+}
+
+DUKKY_FUNC(html_collection, __proto)
+{
+ /* Populate html_collection's prototypical functionality */
+
+ /* Set this prototype's prototype (left-parent)*/
+ /* And the initialiser/finalizer */
+ DUKKY_SET_DESTRUCTOR(0, html_collection);
+ DUKKY_SET_CONSTRUCTOR(0, html_collection, 0);
+ return 1; /* The proto object */
+}