Skip to content

Commit 813d559

Browse files
elibdevdpgeorge
authored andcommitted
webassembly: Make mp_js_process_char asynchronous.
This may also call the garbage collector. Signed-off-by: Eli Bierman <eli@elib.dev>
1 parent b2ad7e2 commit 813d559

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ports/webassembly/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Initialize MicroPython repl. Must be called before entering characters into
121121
the repl.
122122

123123
```
124-
mp_js_process_char(char)
124+
await mp_js_process_char(char)
125125
```
126126

127127
Input character into MicroPython repl. `char` must be of type `number`. This

ports/webassembly/wrapper.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var mainProgram = function()
3131
mp_js_init = Module.cwrap('mp_js_init', 'null', ['number']);
3232
mp_js_do_str = Module.cwrap('mp_js_do_str', 'number', ['string'], {async: true});
3333
mp_js_init_repl = Module.cwrap('mp_js_init_repl', 'null', ['null']);
34-
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number']);
34+
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number'], {async: true});
3535

3636
MP_JS_EPOCH = Date.now();
3737

@@ -69,9 +69,11 @@ var mainProgram = function()
6969
process.stdin.setRawMode(true);
7070
process.stdin.on('data', function (data) {
7171
for (var i = 0; i < data.length; i++) {
72-
if (mp_js_process_char(data[i])) {
73-
process.exit()
74-
}
72+
mp_js_process_char(data[i]).then(result => {
73+
if (result) {
74+
process.exit()
75+
}
76+
})
7577
}
7678
});
7779
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy