[mw-devel] [Git][arthur/mw][master] js-duk: Define the Store object as mw.store
Andrew Price
welshbyte at sucs.org
Sat Oct 13 20:39:13 BST 2018
Andrew Price pushed to branch master at Justin Mitchell / mw
Commits:
dfe09636 by Andrew Price at 2018-10-13T20:35:57+01:00
js-duk: Define the Store object as mw.store
Also make use of the new duk_push_proxy() api.
- - - - -
1 changed file:
- src/client/js-duk.c
Changes:
=====================================
src/client/js-duk.c
=====================================
--- a/src/client/js-duk.c
+++ b/src/client/js-duk.c
@@ -895,15 +895,14 @@ static const duk_function_list_entry store_handlers[] = {
};
/* The owning object must be at the top of the stack when calling this */
-static void define_store_object(void)
+static void define_store_object(const char *name)
{
- duk_push_string(ctx, "Store"); /* To be used by duk_def_prop() below */
+ duk_push_string(ctx, name); /* To be used by duk_def_prop() below */
- duk_get_prop_string(ctx, -2, "Proxy"); /* Push the built-in Proxy constructor */
- duk_push_object(ctx); /* Store */
+ duk_push_object(ctx); /* Store object */
duk_push_object(ctx); /* Handler object */
duk_put_function_list(ctx, -1, store_handlers);
- duk_new(ctx, 2); /* js equiv: new Proxy(Store, handler); */
+ duk_push_proxy(ctx, 0);
/* Define the Store object in the global object */
duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE);
@@ -964,6 +963,7 @@ static void define_api(void)
define_func("beep", js_beep, 1);
define_func("input", js_input, 1);
define_func("termsize", js_termsize, 0);
+ define_store_object("store");
/* mw object */
duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE);
@@ -1005,7 +1005,7 @@ int setup_js(void)
define_func("termsize", js_termsize, 0);
define_func("bind", js_bind, 3);
define_func("unbind", js_unbind, 2);
- define_store_object();
+ define_store_object("Store");
if (is_local) // Don't allow bbs user to use dbquery
define_func("dbquery", js_dbquery, 2);
duk_pop(ctx);
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/dfe096360c7ad6239e9802fceb6e7d7e2f4c87a5
--
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/dfe096360c7ad6239e9802fceb6e7d7e2f4c87a5
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20181013/461da62a/attachment-0001.html>
More information about the mw-devel
mailing list