From 4424eab651436bfa1b05ec984d82b0d529e62891 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Fri, 28 Jul 2023 14:35:52 +0200 Subject: [PATCH] Added converter to upcast JSObj --- wasmrt.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wasmrt.nim b/wasmrt.nim index f7e9411..42b90a9 100644 --- a/wasmrt.nim +++ b/wasmrt.nim @@ -219,6 +219,11 @@ when not defined(release): writeStackTrace() raise newException(Exception, "") +proc to*(o: sink JSObj, T: typedesc[JSObj]): T {.inline.} = + let r = o.o + wasMoved(o) + T(o: r) + # Return type # R - 4 - 0 return void, 1 as is, 2 obj, 3 string # F - 2 - 0 dont prepend first arg, 1 prepend