Stream: git-wasmtime

Topic: wasmtime / Issue #2196 Looking up an exported function by...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 11 2020 at 17:50):

jovanivanovic opened Issue #2196:

Hello, I've been going through the C Hello World embed and I've seen that in order to get an exported function from wasm, you get it by an index:

wasm_extern_vec_t externs;
wasm_instance_exports(instance, &externs);
assert(externs.size == 1);
wasm_func_t *run = wasm_extern_as_func(externs.data[0]);

Is there a possibility that I can lookup the function using it's name, run for example?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 11 2020 at 18:13):

alexcrichton commented on Issue #2196:

Currently this can't be directly done with one function, but you can match up the list returned by wasm_module_exports with the list returned by wasm_instance_exports to get the name of each item.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 11 2020 at 18:17):

jovanivanovic commented on Issue #2196:

@alexcrichton Thanks for the answer. Would it be possible for you to write an example on the matter please?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 16 2020 at 14:02):

jovanivanovic closed Issue #2196:

Hello, I've been going through the C Hello World embed and I've seen that in order to get an exported function from wasm, you get it by an index:

wasm_extern_vec_t externs;
wasm_instance_exports(instance, &externs);
assert(externs.size == 1);
wasm_func_t *run = wasm_extern_as_func(externs.data[0]);

Is there a possibility that I can lookup the function using it's name, run for example?


Last updated: Oct 23 2024 at 20:03 UTC