[mw-devel] [Git][arthur/mw][master] Remove rpc and ipc bits from mwjs
Andrew Price
welshbyte at sucs.org
Fri Nov 17 12:56:13 GMT 2017
Andrew Price pushed to branch master at Justin Mitchell / mw
Commits:
13710168 by Andrew Price at 2017-11-17T12:55:45+00:00
Remove rpc and ipc bits from mwjs
- - - - -
3 changed files:
- mwjs.rst
- src/client/js-duk.c
- src/client/js.h
Changes:
=====================================
mwjs.rst
=====================================
--- a/mwjs.rst
+++ b/mwjs.rst
@@ -22,10 +22,6 @@ The following symbols are defined in the global scope for ``MWJS`` scripts:
A string containing the name of the current ``Milliways`` user.
-`K_BROADCAST`
-
- A type specifier to be used in `rpc()` and `ipc()` calls (see below).
-
BIND TYPES
==========
@@ -36,10 +32,6 @@ The following constants can be used with the `bind` and `unbind` functions (see
``bind(K_BIND_EVENT, handler)`` hooks a user-defined function named in the
string `handler` to be called when certain events occur.
-`K_BIND_IPC`
-
- ``bind(K_BIND_IPC, )`` - To be documented.
-
`K_BIND_ONOFF`
``bind(K_BIND_ONOFF, )`` - To be documented.
@@ -52,10 +44,6 @@ The following constants can be used with the `bind` and `unbind` functions (see
``bind(K_BIND_SHUTDOWN, )`` - To be documented.
-`K_BIND_RPC`
-
- ``bind(K_BIND_RPC, )`` - To be documented.
-
`K_BIND_ALIAS`
``bind(K_BIND_ALIAS, )`` - To be documented.
@@ -100,14 +88,6 @@ The following functions are defined in the global scope of ``MWJS`` scripts.
Note that the wholist is currently not guaranteed to be available on joining
the talker and so the value returned from `wholist()` could be `undefined`.
-`rpc()`
-
- To be documented.
-
-`ipc()`
-
- To be documented.
-
`urlget(url)`
Takes a URL string, fetches it, and returns the contents of the response.
=====================================
src/client/js-duk.c
=====================================
--- a/src/client/js-duk.c
+++ b/src/client/js-duk.c
@@ -40,10 +40,8 @@ struct binding {
const struct binding bindings[] = {
{ K_BIND, 1, &bind_list, "Bind" },
{ K_BIND_ALIAS, 1, &alias_list, "Alias" },
- { K_BIND_RPC, 1, &rpc_list, "RPC bind" },
{ K_BIND_EVENT, 0, &event_list, "Event bind" },
{ K_BIND_ONOFF, 0, &onoff_list, "Check on/off bind" },
- { K_BIND_IPC, 0, &ipc_list, "IPC bind" },
{ K_BIND_FORCE, 0, &force_list, "Force bind" },
{ K_BIND_SHUTDOWN, 0, &shutdown_list, "Shutdown bind" },
{ K_BIND_INPUT, 0, &eventin_list, "Input event bind" },
@@ -251,62 +249,6 @@ static duk_ret_t js_wholist(duk_context *cx)
return 1; /* Array is returned at top of stack */
}
-static duk_ret_t js_rpc(duk_context *cx)
-{
- const char *username = NULL;
- const char *rpc_type = NULL;
- const char *msg = NULL;
- int broadcast = 0;
-
- if (duk_is_undefined(cx, -1) ||
- duk_is_undefined(cx, -2) ||
- duk_is_undefined(cx, -3)) {
- fprintf(stderr, "mwjs error: rpc() expects 3 arguments\n");
- return DUK_RET_SYNTAX_ERROR;
- }
- if (duk_is_number(cx, -3)) {
- if (duk_get_int(cx, -3) == K_BROADCAST)
- broadcast = 1;
- } else if (duk_is_string(cx, -3)) {
- username = duk_get_string(cx, -3);
- }
- rpc_type = duk_safe_to_string(cx, -2);
- msg = duk_safe_to_string(cx, -1);
-
- if((!broadcast && username[0] == '\0') || rpc_type[0] == '\0') {
- fprintf(stderr, "Error: javascript rpc(): invalid arguments - [%s] [%s]",
- (broadcast ? "K_BROADCAST" : username), rpc_type);
- return DUK_RET_ERROR;
- }
- sendrpc(username, rpc_type, msg, broadcast);
- return 0;
-}
-
-static duk_ret_t js_ipc(duk_context *cx)
-{
- const char *username = NULL;
- const char *msg = NULL;
- int broadcast = 0;
-
- if (duk_is_undefined(cx, -1) || duk_is_undefined(cx, -2)) {
- fprintf(stderr, "mwjs error: ipc() expects 2 arguments\n");
- return DUK_RET_SYNTAX_ERROR;
- }
- if (duk_is_number(cx, -2)) {
- if (duk_get_int(cx, -2) == K_BROADCAST)
- broadcast = 1;
- } else if (duk_is_string(cx, -2)) {
- username = duk_get_string(cx, -2);
- }
- msg = duk_safe_to_string(cx, -1);
- if (broadcast == 0 && (!username || username[0] == '\0')) {
- fprintf(stderr, "mwjs error: ipc() expects either a username or K_BROADCAST\n");
- return DUK_RET_ERROR;
- }
- sendipc(username, msg, broadcast);
- return 0;
-}
-
struct urlget {
duk_context *cx;
duk_idx_t nchunks;
@@ -477,8 +419,7 @@ static duk_ret_t js_bind(duk_context *cx)
} else if (duk_is_number(cx, -3)) {
bind_type = duk_get_int_default(cx, -3, -1);
if (bind_type == K_BIND ||
- bind_type == K_BIND_ALIAS ||
- bind_type == K_BIND_RPC) {
+ bind_type == K_BIND_ALIAS) {
bind_name = duk_get_string(cx, -2);
} else {
duk_pop(cx);
@@ -675,7 +616,6 @@ static duk_ret_t js_dbquery(duk_context *cx)
return 1;
}
-
int js_isrunning(void)
{
return (interrupt == 0 && timeout_event != NULL);
@@ -850,14 +790,11 @@ static void define_string(const char *name, const char *value)
static void define_constants(void)
{
define_number("K_BIND_EVENT", (duk_double_t)K_BIND_EVENT);
- define_number("K_BIND_IPC", (duk_double_t)K_BIND_IPC);
define_number("K_BIND_ONOFF", (duk_double_t)K_BIND_ONOFF);
define_number("K_BIND_FORCE", (duk_double_t)K_BIND_FORCE);
define_number("K_BIND_SHUTDOWN", (duk_double_t)K_BIND_SHUTDOWN);
- define_number("K_BIND_RPC", (duk_double_t)K_BIND_RPC);
define_number("K_BIND_ALIAS", (duk_double_t)K_BIND_ALIAS);
define_number("K_BIND_INPUT", (duk_double_t)K_BIND_INPUT);
- define_number("K_BROADCAST", (duk_double_t)K_BROADCAST);
define_string("whoami", user->record.name);
}
@@ -878,8 +815,6 @@ int setup_js(void)
define_func("exec", js_mwexec, 1);
define_func("say", js_say, 1);
define_func("wholist", js_wholist, 0);
- define_func("rpc", js_rpc, 3);
- define_func("ipc", js_ipc, 2);
define_func("urlget", js_urlget, 1);
define_func("beep", js_beep, 1);
define_func("input", js_input, 1);
=====================================
src/client/js.h
=====================================
--- a/src/client/js.h
+++ b/src/client/js.h
@@ -15,13 +15,10 @@ enum bindtype {
K_BIND = 0,
K_BIND_EVENT,
K_BIND_ONOFF,
- K_BIND_IPC,
K_BIND_FORCE,
K_BIND_SHUTDOWN,
K_BIND_ALIAS,
- K_BIND_RPC,
K_BIND_INPUT
};
-#define K_BROADCAST 1
#endif /* JS_H */
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/1371016890636e98b4ed0950e36fc7ebc9a0764b
---
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/1371016890636e98b4ed0950e36fc7ebc9a0764b
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/20171117/b4efd944/attachment-0001.html>
More information about the mw-devel
mailing list