summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/static/dartboat.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 9921cf3..e43488b 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -47,8 +47,20 @@ function promptMsgR(p) {
document.getElementById('prompt-msg-r').textContent = UTF8ToString(p);
}
+function stringToCString(str) { // caller must free
+ const len = lengthBytesUTF8(str) + 1;
+ const cstr = _malloc(len);
+ stringToUTF8(str, cstr, len);
+ return cstr;
+}
+
function promptHandle(command, data) {
- Module.ccall('prompt_handle', null, ['string', 'string'], [command, data]);
+ const str_c = stringToCString(command);
+ const str_d = data && stringToCString(data);
+ _prompt_handle(str_c, str_d);
+
+ _free(str_c);
+ if (str_d) _free(str_d);
}
function setKeypad(keypad) {