diff options
author | bptato <nincsnevem662@gmail.com> | 2024-05-08 18:39:27 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-05-08 18:39:27 +0200 |
commit | 86f4c56507bc94d03e7d94be6ede884b9e7b5358 (patch) | |
tree | 929ce32ada67e8b1d57787d8e6d038fa603fc31e /src/local/client.nim | |
parent | 5c891488423aa7ccbef2fb4332ff6cb4e3c05154 (diff) | |
download | chawan-86f4c56507bc94d03e7d94be6ede884b9e7b5358.tar.gz |
js: refactor
* prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index 237ee284..af5e89a0 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -30,14 +30,14 @@ import js/base64 import js/console import js/domexception import js/encoding -import js/error +import js/jserror import js/fromjs import js/intl import js/javascript import js/jstypes import js/jsutils -import js/module -import js/opaque +import js/jsmodule +import js/jsopaque import js/timeout import js/tojs import loader/headers @@ -113,7 +113,12 @@ proc interruptHandler(rt: JSRuntime; opaque: pointer): cint {.cdecl.} = return 0 proc runJSJobs(client: Client) = - client.jsrt.runJSJobs(client.console.err) + while true: + let r = client.jsrt.runJSJobs() + if r.isSome: + break + let ctx = r.error + ctx.writeException(client.console.err) proc cleanup(client: Client) = if client.alive: @@ -221,8 +226,8 @@ proc evalAction(client: Client; action: string; arg0: int32): EmptyPromise = client.quit(client.exitCode) if JS_IsException(ret): client.jsctx.writeException(client.console.err) - if JS_IsObject(ret): - let maybep = fromJS[EmptyPromise](ctx, ret) + elif JS_IsObject(ret): + let maybep = fromJSEmptyPromise(ctx, ret) if maybep.isSome: p = maybep.get JS_FreeValue(ctx, ret) |