changeset 200:dd77bfb38df2

js: cleanup API Since molko-js API isn't meant to be exposed, use duk_context everywhere by default for a simpler code.
author David Demelier <markand@malikania.fr>
date Mon, 09 Nov 2020 19:18:14 +0100
parents ebbcfb31482d
children bd5b3a11fe6f
files molko-js/CMakeLists.txt molko-js/src/js-animation.c molko-js/src/js-animation.h molko-js/src/js-clock.c molko-js/src/js-clock.h molko-js/src/js-event.c molko-js/src/js-event.h molko-js/src/js-font.c molko-js/src/js-font.h molko-js/src/js-painter.c molko-js/src/js-painter.h molko-js/src/js-sprite.c molko-js/src/js-sprite.h molko-js/src/js-texture.c molko-js/src/js-texture.h molko-js/src/js-util.c molko-js/src/js-util.h molko-js/src/js-window.c molko-js/src/js-window.h molko-js/src/js.c molko-js/src/js.h molko-js/src/js_p.c molko-js/src/js_p.h
diffstat 23 files changed, 163 insertions(+), 263 deletions(-) [+]
line wrap: on
line diff
--- a/molko-js/CMakeLists.txt	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/CMakeLists.txt	Mon Nov 09 19:18:14 2020 +0100
@@ -40,8 +40,6 @@
 	${molko-js_SOURCE_DIR}/src/js-window.h
 	${molko-js_SOURCE_DIR}/src/js.c
 	${molko-js_SOURCE_DIR}/src/js.h
-	${molko-js_SOURCE_DIR}/src/js_p.c
-	${molko-js_SOURCE_DIR}/src/js_p.h
 	${molko-js_SOURCE_DIR}/src/main.c
 )
 
--- a/molko-js/src/js-animation.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-animation.c	Mon Nov 09 19:18:14 2020 +0100
@@ -27,7 +27,6 @@
 #include "js.h"
 #include "js-animation.h"
 #include "js-sprite.h"
-#include "js_p.h"
 
 #define SYMBOL          DUK_HIDDEN_SYMBOL("molko::animation")
 #define SPRITE_REF      DUK_HIDDEN_SYMBOL("molko::animation::sprite")
@@ -66,7 +65,7 @@
 	if (!duk_is_constructor_call(ctx))
 		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Animation must be new-constructed");
 
-	sprite = js_sprite_require(js_self(ctx), 0);
+	sprite = js_sprite_require(ctx, 0);
 	delay = duk_require_uint(ctx, 1);
 
 	anim = alloc_zero(1, sizeof (*anim));
@@ -142,18 +141,18 @@
 };
 
 void
-js_animation_load(struct js *js)
+js_animation_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_c_function(js->handle, js_animation_new, 3);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_push_c_function(js->handle, js_animation_finish, 1);
-	duk_set_finalizer(js->handle, -2);
-	duk_put_prop_string(js->handle, -2, "prototype");
-	duk_put_prop_string(js->handle, -2, "Animation");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_animation_new, 3);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_push_c_function(ctx, js_animation_finish, 1);
+	duk_set_finalizer(ctx, -2);
+	duk_put_prop_string(ctx, -2, "prototype");
+	duk_put_prop_string(ctx, -2, "Animation");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-animation.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-animation.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_ANIMATION_H
 #define MOLKO_JS_ANIMATION_H
 
-struct js;
-
 void
-js_animation_load(struct js *js);
+js_animation_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_ANIMATION_H */
--- a/molko-js/src/js-clock.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-clock.c	Mon Nov 09 19:18:14 2020 +0100
@@ -95,18 +95,18 @@
 };
 
 void
-js_clock_load(struct js *js)
+js_clock_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_c_function(js->handle, js_clock_new, 0);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_push_c_function(js->handle, js_clock_finish, 1);
-	duk_set_finalizer(js->handle, -2);
-	duk_put_prop_string(js->handle, -2, "prototype");
-	duk_put_prop_string(js->handle, -2, "Clock");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_clock_new, 0);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_push_c_function(ctx, js_clock_finish, 1);
+	duk_set_finalizer(ctx, -2);
+	duk_put_prop_string(ctx, -2, "prototype");
+	duk_put_prop_string(ctx, -2, "Clock");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-clock.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-clock.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_CLOCK_H
 #define MOLKO_JS_CLOCK_H
 
-struct js;
-
 void
-js_clock_load(struct js *js);
+js_clock_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_CLOCK_H */
--- a/molko-js/src/js-event.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-event.c	Mon Nov 09 19:18:14 2020 +0100
@@ -89,15 +89,15 @@
 };
 
 void
-js_event_load(struct js *js)
+js_event_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_object(js->handle);
-	duk_put_number_list(js->handle, -1, types);
-	duk_put_function_list(js->handle, -1, functions);
-	duk_put_prop_string(js->handle, -2, "Event");
-	duk_pop_n(js->handle, 1);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_object(ctx);
+	duk_put_number_list(ctx, -1, types);
+	duk_put_function_list(ctx, -1, functions);
+	duk_put_prop_string(ctx, -2, "Event");
+	duk_pop_n(ctx, 1);
 }
--- a/molko-js/src/js-event.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-event.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_EVENT_H
 #define MOLKO_JS_EVENT_H
 
-struct js;
-
 void
-js_event_load(struct js *js);
+js_event_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_EVENT_H */
--- a/molko-js/src/js-font.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-font.c	Mon Nov 09 19:18:14 2020 +0100
@@ -28,7 +28,6 @@
 #include "js-font.h"
 #include "js-texture.h"
 #include "js.h"
-#include "js_p.h"
 
 #define SYMBOL  DUK_HIDDEN_SYMBOL("molko::font")
 #define PROTO   DUK_HIDDEN_SYMBOL("molko::font::prototype")
@@ -92,7 +91,7 @@
 	if (!font_render(font, &tex, text, color))
 		duk_error(ctx, DUK_ERR_ERROR, "%s", error());
 
-	js_texture_push(js_self(ctx), &tex);
+	js_texture_push(ctx, &tex);
 
 	return 1;
 }
@@ -146,20 +145,20 @@
 };
 
 void
-js_font_load(struct js *js)
+js_font_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, functions);
-	duk_put_prop_string(js->handle, -2, "Font");
-	duk_push_global_stash(js->handle);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_push_c_function(js->handle, js_font_finish, 1);
-	duk_set_finalizer(js->handle, -2);
-	duk_put_prop_string(js->handle, -2, PROTO);
-	duk_pop_n(js->handle, 3);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, functions);
+	duk_put_prop_string(ctx, -2, "Font");
+	duk_push_global_stash(ctx);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_push_c_function(ctx, js_font_finish, 1);
+	duk_set_finalizer(ctx, -2);
+	duk_put_prop_string(ctx, -2, PROTO);
+	duk_pop_n(ctx, 3);
 }
--- a/molko-js/src/js-font.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-font.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_FONT_H
 #define MOLKO_JS_FONT_H
 
-struct js;
-
 void
-js_font_load(struct js *js);
+js_font_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_FONT_H */
--- a/molko-js/src/js-painter.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-painter.c	Mon Nov 09 19:18:14 2020 +0100
@@ -200,16 +200,16 @@
 };
 
 void
-js_painter_load(struct js *js)
+js_painter_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_c_function(js->handle, js_painter_new, 0);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_put_prop_string(js->handle, -2, "prototype");
-	duk_put_prop_string(js->handle, -2, "Painter");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_painter_new, 0);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_put_prop_string(ctx, -2, "prototype");
+	duk_put_prop_string(ctx, -2, "Painter");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-painter.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-painter.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_PAINTER_H
 #define MOLKO_JS_PAINTER_H
 
-struct js;
-
 void
-js_painter_load(struct js *js);
+js_painter_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_PAINTER_H */
--- a/molko-js/src/js-sprite.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-sprite.c	Mon Nov 09 19:18:14 2020 +0100
@@ -27,7 +27,6 @@
 #include "js-sprite.h"
 #include "js-texture.h"
 #include "js.h"
-#include "js_p.h"
 
 #define SYMBOL          DUK_HIDDEN_SYMBOL("molko::sprite")
 #define TEXTURE_REF     DUK_HIDDEN_SYMBOL("molko::sprite::texture")
@@ -67,7 +66,6 @@
 static duk_ret_t
 js_sprite_new(duk_context *ctx)
 {
-	struct js *js = js_self(ctx);
 	struct texture *tex;
 	struct sprite sprite;
 	unsigned int cellw, cellh;
@@ -75,7 +73,7 @@
 	if (!duk_is_constructor_call(ctx))
 		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Sprite must be new-constructed");
 
-	tex = js_texture_require(js, 0);
+	tex = js_texture_require(ctx, 0);
 	cellw = duk_require_int(ctx, 1);
 	cellh = duk_require_int(ctx, 2);
 
@@ -153,33 +151,33 @@
 };
 
 struct sprite *
-js_sprite_require(struct js *js, unsigned int index)
+js_sprite_require(duk_context *ctx, unsigned int index)
 {
 	struct sprite *sp;
 
-	duk_get_prop_string(js->handle, index, SYMBOL);
-	sp = duk_to_pointer(js->handle, -1);
-	duk_pop(js->handle);
+	duk_get_prop_string(ctx, index, SYMBOL);
+	sp = duk_to_pointer(ctx, -1);
+	duk_pop(ctx);
 
 	if (!sp)
-		duk_error(js->handle, DUK_ERR_TYPE_ERROR, "Sprite expected on argument #%u", index);
+		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Sprite expected on argument #%u", index);
 
 	return sp;
 }
 
 void
-js_sprite_load(struct js *js)
+js_sprite_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_c_function(js->handle, js_sprite_new, 3);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_push_c_function(js->handle, js_sprite_finish, 1);
-	duk_set_finalizer(js->handle, -2);
-	duk_put_prop_string(js->handle, -2, "prototype");
-	duk_put_prop_string(js->handle, -2, "Sprite");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_sprite_new, 3);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_push_c_function(ctx, js_sprite_finish, 1);
+	duk_set_finalizer(ctx, -2);
+	duk_put_prop_string(ctx, -2, "prototype");
+	duk_put_prop_string(ctx, -2, "Sprite");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-sprite.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-sprite.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,12 +19,10 @@
 #ifndef MOLKO_JS_SPRITE_H
 #define MOLKO_JS_SPRITE_H
 
-struct js;
-
 void
-js_sprite_load(struct js *js);
+js_sprite_load(duk_context *ctx);
 
 struct sprite *
-js_sprite_require(struct js *js, unsigned int index);
+js_sprite_require(duk_context *ctx, unsigned int index);
 
 #endif /* !MOLKO_JS_SPRITE_H */
--- a/molko-js/src/js-texture.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-texture.c	Mon Nov 09 19:18:14 2020 +0100
@@ -26,7 +26,6 @@
 #include <core/texture.h>
 
 #include "js.h"
-#include "js_p.h"
 #include "js-texture.h"
 
 #define SYMBOL DUK_HIDDEN_SYMBOL("molko::texture")
@@ -212,7 +211,7 @@
 	if (!image_open(&tex, path))
 		duk_error(ctx, DUK_ERR_ERROR, "%s", error());
 
-	js_texture_push(js_self(ctx), &tex);
+	js_texture_push(ctx, &tex);
 
 	return 1;
 }
@@ -229,70 +228,70 @@
 };
 
 struct texture *
-js_texture_require(struct js *js, unsigned int index)
+js_texture_require(duk_context *ctx, unsigned int index)
 {
 	struct texture *tex;
 
-	duk_get_prop_string(js->handle, index, SYMBOL);
-	tex = duk_to_pointer(js->handle, -1);
-	duk_pop(js->handle);
+	duk_get_prop_string(ctx, index, SYMBOL);
+	tex = duk_to_pointer(ctx, -1);
+	duk_pop(ctx);
 
 	if (!tex)
-		duk_error(js->handle, DUK_ERR_TYPE_ERROR, "Texture expected on argument #%u", index);
+		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Texture expected on argument #%u", index);
 
 	return tex;
 }
 
 void
-js_texture_push(struct js *js, const struct texture *tex)
+js_texture_push(duk_context *ctx, const struct texture *tex)
 {
-	assert(js);
+	assert(ctx);
 	assert(texture_ok(tex));
 
-	duk_push_object(js->handle);
-	duk_push_global_stash(js->handle);
-	duk_get_prop_string(js->handle, -1, PROTO);
-	duk_remove(js->handle, -2);
-	duk_push_pointer(js->handle, alloc_dup(tex, sizeof (*tex)));
-	duk_put_prop_string(js->handle, -3, SYMBOL);
-	duk_set_prototype(js->handle, -2);
+	duk_push_object(ctx);
+	duk_push_global_stash(ctx);
+	duk_get_prop_string(ctx, -1, PROTO);
+	duk_remove(ctx, -2);
+	duk_push_pointer(ctx, alloc_dup(tex, sizeof (*tex)));
+	duk_put_prop_string(ctx, -3, SYMBOL);
+	duk_set_prototype(ctx, -2);
 
 	/* Put some properties. */
-	duk_push_string(js->handle, "width");
-	duk_push_c_function(js->handle, js_texture_getWidth, 0);
-	duk_def_prop(js->handle, -3, DUK_DEFPROP_HAVE_GETTER);
-	duk_push_string(js->handle, "height");
-	duk_push_c_function(js->handle, js_texture_getHeight, 0);
-	duk_def_prop(js->handle, -3, DUK_DEFPROP_HAVE_GETTER);
-	duk_push_string(js->handle, "blendMode");
-	duk_push_c_function(js->handle, js_texture_setBlendMode, 1);
-	duk_def_prop(js->handle, -3, DUK_DEFPROP_HAVE_SETTER);
-	duk_push_string(js->handle, "alphaMod");
-	duk_push_c_function(js->handle, js_texture_setAlphaMod, 1);
-	duk_def_prop(js->handle, -3, DUK_DEFPROP_HAVE_SETTER);
-	duk_push_string(js->handle, "colorMod");
-	duk_push_c_function(js->handle, js_texture_setColorMod, 1);
-	duk_def_prop(js->handle, -3, DUK_DEFPROP_HAVE_SETTER);
+	duk_push_string(ctx, "width");
+	duk_push_c_function(ctx, js_texture_getWidth, 0);
+	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER);
+	duk_push_string(ctx, "height");
+	duk_push_c_function(ctx, js_texture_getHeight, 0);
+	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER);
+	duk_push_string(ctx, "blendMode");
+	duk_push_c_function(ctx, js_texture_setBlendMode, 1);
+	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_SETTER);
+	duk_push_string(ctx, "alphaMod");
+	duk_push_c_function(ctx, js_texture_setAlphaMod, 1);
+	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_SETTER);
+	duk_push_string(ctx, "colorMod");
+	duk_push_c_function(ctx, js_texture_setColorMod, 1);
+	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_SETTER);
 }
 
 void
-js_texture_load(struct js *js)
+js_texture_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_c_function(js->handle, js_texture_new, 2);
-	duk_put_function_list(js->handle, -1, functions);
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, methods);
-	duk_push_c_function(js->handle, js_texture_finish, 1);
-	duk_set_finalizer(js->handle, -2);
-	duk_push_global_stash(js->handle);
-	duk_dup(js->handle, -2);
-	duk_put_prop_string(js->handle, -2, PROTO);
-	duk_pop(js->handle);
-	duk_put_prop_string(js->handle, -2, "prototype");
-	duk_put_prop_string(js->handle, -2, "Texture");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_texture_new, 2);
+	duk_put_function_list(ctx, -1, functions);
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, methods);
+	duk_push_c_function(ctx, js_texture_finish, 1);
+	duk_set_finalizer(ctx, -2);
+	duk_push_global_stash(ctx);
+	duk_dup(ctx, -2);
+	duk_put_prop_string(ctx, -2, PROTO);
+	duk_pop(ctx);
+	duk_put_prop_string(ctx, -2, "prototype");
+	duk_put_prop_string(ctx, -2, "Texture");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-texture.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-texture.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,15 +19,13 @@
 #ifndef MOLKO_JS_TEXTURE_H
 #define MOLKO_JS_TEXTURE_H
 
-struct js;
-
 struct texture *
-js_texture_require(struct js *js, unsigned int index);
+js_texture_require(duk_context *ctx, unsigned int index);
 
 void
-js_texture_push(struct js *js, const struct texture *tex);
+js_texture_push(duk_context *ctx, const struct texture *tex);
 
 void
-js_texture_load(struct js *js);
+js_texture_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_TEXTURE_H */
--- a/molko-js/src/js-util.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-util.c	Mon Nov 09 19:18:14 2020 +0100
@@ -39,14 +39,14 @@
 };
 
 void
-js_util_load(struct js *js)
+js_util_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);
-	duk_get_prop_string(js->handle, -1, "Molko");
-	duk_push_object(js->handle);
-	duk_put_function_list(js->handle, -1, functions);
-	duk_put_prop_string(js->handle, -2, "Util");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_object(ctx);
+	duk_put_function_list(ctx, -1, functions);
+	duk_put_prop_string(ctx, -2, "Util");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-util.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-util.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_UTIL_H
 #define MOLKO_JS_UTIL_H
 
-struct js;
-
 void
-js_util_load(struct js *js);
+js_util_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_UTIL_H */
--- a/molko-js/src/js-window.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-window.c	Mon Nov 09 19:18:14 2020 +0100
@@ -73,16 +73,16 @@
 };
 
 void
-js_window_load(struct js *js)
+js_window_load(duk_context *ctx)
 {
-	assert(js);
+	assert(ctx);
 
-	duk_push_global_object(js->handle);                  // [g]
-	duk_get_prop_string(js->handle, -1, "Molko");        // [g] [Molko]
-	duk_push_c_function(js->handle, js_window_new, 3);   // [g] [Molko] [Window]
-	duk_push_object(js->handle);                         // [g] [Molko] [Window] [Cursor]
-	duk_put_number_list(js->handle, -1, cursors);
-	duk_put_prop_string(js->handle, -2, "Cursor");       // [g] [Molko] [Window]
-	duk_put_prop_string(js->handle, -2, "Window");
-	duk_pop_n(js->handle, 2);
+	duk_push_global_object(ctx);
+	duk_get_prop_string(ctx, -1, "Molko");
+	duk_push_c_function(ctx, js_window_new, 3);
+	duk_push_object(ctx);
+	duk_put_number_list(ctx, -1, cursors);
+	duk_put_prop_string(ctx, -2, "Cursor");
+	duk_put_prop_string(ctx, -2, "Window");
+	duk_pop_n(ctx, 2);
 }
--- a/molko-js/src/js-window.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js-window.h	Mon Nov 09 19:18:14 2020 +0100
@@ -19,9 +19,7 @@
 #ifndef MOLKO_JS_WINDOW_H
 #define MOLKO_JS_WINDOW_H
 
-struct js;
-
 void
-js_window_load(struct js *js);
+js_window_load(duk_context *ctx);
 
 #endif /* !MOLKO_JS_WINDOW_H */
--- a/molko-js/src/js.c	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js.c	Mon Nov 09 19:18:14 2020 +0100
@@ -182,15 +182,15 @@
 {
 	assert(js);
 
-	js_animation_load(js);
-	js_clock_load(js);
-	js_event_load(js);
-	js_font_load(js);
-	js_painter_load(js);
-	js_texture_load(js);
-	js_sprite_load(js);
-	js_util_load(js);
-	js_window_load(js);
+	js_animation_load(js->handle);
+	js_clock_load(js->handle);
+	js_event_load(js->handle);
+	js_font_load(js->handle);
+	js_painter_load(js->handle);
+	js_texture_load(js->handle);
+	js_sprite_load(js->handle);
+	js_util_load(js->handle);
+	js_window_load(js->handle);
 }
 
 bool
@@ -223,19 +223,6 @@
 	return ret;
 }
 
-bool
-js_openmem(struct js *js, const void *data, size_t datasz)
-{
-	assert(js);
-	assert(data);
-	
-	(void)js;
-	(void)data;
-	(void)datasz;
-
-	return true;
-}
-
 void
 js_finish(struct js *js)
 {
--- a/molko-js/src/js.h	Mon Nov 09 19:07:30 2020 +0100
+++ b/molko-js/src/js.h	Mon Nov 09 19:18:14 2020 +0100
@@ -35,9 +35,6 @@
 bool
 js_open(struct js *js, const char *path);
 
-bool
-js_openmem(struct js *js, const void *data, size_t datasz);
-
 void
 js_finish(struct js *js);
 
--- a/molko-js/src/js_p.c	Mon Nov 09 19:07:30 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * js_p.c -- private functions for Javascript bindings
- *
- * Copyright (c) 2020 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "js_p.h"
-
-struct js *
-js_self(duk_context *ctx)
-{
-	struct js *self;
-
-	duk_push_global_stash(ctx);
-	duk_get_prop_string(ctx, -1, DUK_HIDDEN_SYMBOL("molko::pointer"));
-	self = duk_to_pointer(ctx, -1);
-	duk_pop_n(ctx, 2);
-
-	return self;
-}
--- a/molko-js/src/js_p.h	Mon Nov 09 19:07:30 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * js_p.h -- private functions for Javascript bindings
- *
- * Copyright (c) 2020 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_JS_P_H
-#define MOLKO_JS_P_H
-
-#include <duktape.h>
-
-struct js *
-js_self(duk_context *);
-
-#endif /* !MOLKO_JS_P_H */