MCPcopy Create free account
hub / github.com/WebAssembly/wasm-c-api / callback

Function callback

example/hostref.cc:11–18  ·  view source on GitHub ↗

A function to be called from Wasm code.

Source from the content-addressed store, hash-verified

9
10// A function to be called from Wasm code.
11auto callback(
12 const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
13) -> wasm::own<wasm::Trap> {
14 std::cout << "Calling back..." << std::endl;
15 std::cout << "> " << (args[0].ref() ? args[0].ref()->get_host_info() : nullptr) << std::endl;
16 results[0] = args[0].copy();
17 return nullptr;
18}
19
20
21auto get_export_func(const wasm::ownvec<wasm::Extern>& exports, size_t i) -> const wasm::Func* {

Callers

nothing calls this directly

Calls 3

refMethod · 0.80
get_host_infoMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected