提交 813d559b 编写于 作者: E elibdev 提交者: Damien George

webassembly: Make mp_js_process_char asynchronous.

This may also call the garbage collector.
Signed-off-by: NEli Bierman <eli@elib.dev>
上级 b2ad7e23
......@@ -121,7 +121,7 @@ Initialize MicroPython repl. Must be called before entering characters into
the repl.
```
mp_js_process_char(char)
await mp_js_process_char(char)
```
Input character into MicroPython repl. `char` must be of type `number`. This
......
......@@ -31,7 +31,7 @@ var mainProgram = function()
mp_js_init = Module.cwrap('mp_js_init', 'null', ['number']);
mp_js_do_str = Module.cwrap('mp_js_do_str', 'number', ['string'], {async: true});
mp_js_init_repl = Module.cwrap('mp_js_init_repl', 'null', ['null']);
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number']);
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number'], {async: true});
MP_JS_EPOCH = Date.now();
......@@ -69,9 +69,11 @@ var mainProgram = function()
process.stdin.setRawMode(true);
process.stdin.on('data', function (data) {
for (var i = 0; i < data.length; i++) {
if (mp_js_process_char(data[i])) {
process.exit()
}
mp_js_process_char(data[i]).then(result => {
if (result) {
process.exit()
}
})
}
});
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册