Stream: wasm

Topic: JS values returns from host functions


view this post on Zulip Dominic Elm (Jul 20 2022 at 15:08):

Is it specified somewhere how non-numeric values are treated if returned from a host function back to WASM? I saw that if I e.g. return an object {} or some other value that doesn't match one of WASM's types it converts that to 0. Is that in the spec somewhere or is it up to the host runtime to decide how to convert the values when returned?

view this post on Zulip Dominic Elm (Jul 20 2022 at 15:14):

I looked here https://webassembly.github.io/spec/js-api/index.html#instances but didn't find anything. Maybe I missed it.

view this post on Zulip fitzgen (he/him) (Jul 20 2022 at 15:18):

I think you're looking for ToWebAssemblyValue and ToJSValue

https://webassembly.github.io/spec/js-api/index.html#towebassemblyvalue

https://webassembly.github.io/spec/js-api/index.html#tojsvalue

view this post on Zulip fitzgen (he/him) (Jul 20 2022 at 15:18):

used in the spec here: https://webassembly.github.io/spec/js-api/index.html#call-an-exported-function

view this post on Zulip Dominic Elm (Jul 21 2022 at 07:57):

Thanks so much @fitzgen (he/him) :pray:


Last updated: Nov 26 2024 at 01:30 UTC