Laxystem
03/19/2024, 4:48 PMfun foo() = js("console.log('foo')")
Kotlin generates:
(func $js_code.foo (;3873;) (import "js_code" "foo"))
And (in an object containing all functions exported to Wasm):
'foo' : () => console.log('foo')
Is it possible to provide the foo JS function the WebAssembly.Instance ?
That way, one can call the function named `bar`:
'foo': (instance) => instance.exports.barArtem Kobzar
03/19/2024, 5:03 PMwasmInstance name. You could try to refer to it inside the function body like this:
fun foo() = js("wasmInstance.exports.bar")
But again, I don't recommend you to go this way. It's not something we support, and we can change it anytime in the future.Laxystem
03/19/2024, 5:25 PMLaxystem
03/19/2024, 5:28 PMArtem Kobzar
03/19/2024, 5:34 PMLaxystem
03/19/2024, 6:47 PMLaxystem
03/27/2024, 1:22 PMcom.example.Object_instance), not functions - and getting Wasm globals' values from JS isn't supported - unless I'm wrong?Artem Kobzar
03/27/2024, 1:32 PMLaxystem
03/27/2024, 1:34 PMfun instanceOf(objectQualifiedName: String) = js("wasmInstance.exports[objectQualifiedName + 'instance']")Laxystem
03/27/2024, 1:34 PMexports only allows access to functionsLaxystem
03/27/2024, 1:34 PMArtem Kobzar
03/27/2024, 2:05 PM