webassembly: Make mp_js_process_char asynchronous.
This may also call the garbage collector. Signed-off-by: Eli Bierman <eli@elib.dev>
This commit is contained in:
parent
b2ad7e238b
commit
813d559bc0
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user