WebAssembly / wasm-c-api

Wasm C API prototype
Apache License 2.0
550 stars 77 forks source link

wasm-c-api lacks an import reflection example - one attached. #137

Open adv-sw opened 4 years ago

adv-sw commented 4 years ago

Hi all,

Was trying to figure out what imports were required by a wasm I'd just loaded & couldn't spot a suitable example. Have created one with help from the wasmtime guys - thank you.

Please consider adding this to wasm-c-api examples to help others wanting to accomplish the same thing.

Example output:

Initializing... Loading binary... Compiling module... Extracting imports... import 0 "create_native" func i32 -> i32 import 1 "release_native" func i32 -> i32 Shutting down...

Cheers, Steve. imports.c.txt

FGasper commented 3 years ago

NB: This would be a bit more complete with the inclusion of wasm_importtype_module().