[mw-devel] [Git][arthur/mw][master] js-duk: Implement mw.whoami()

Andrew Price welshbyte at sucs.org
Wed Oct 17 09:00:21 BST 2018


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
5301459f by Andrew Price at 2018-10-17T08:59:13+01:00
js-duk: Implement mw.whoami()

It's now defined as a function instead of a string because the username
can change.

- - - - -


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
@@ -465,6 +465,13 @@ static duk_ret_t js_termsize(duk_context *cx)
 	return 1; /* Result is at top of stack */
 }
 
+/* me = mw.whoami(); */
+static duk_ret_t js_whoami(duk_context *cx)
+{
+	duk_push_string(cx, user->record.name);
+	return 1;
+}
+
 static duk_ret_t js_bind(duk_context *cx)
 {
 	const char *bind_name = NULL;
@@ -991,6 +998,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_func("whoami", js_whoami, 0);
 	define_store_object("store");
 
 	/* mw object */



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/5301459fca5f7a6e1bdd3277a2e4a71915d837a9

-- 
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/5301459fca5f7a6e1bdd3277a2e4a71915d837a9
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/20181017/c7b302fb/attachment.html>


More information about the mw-devel mailing list