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

Function callback

example/multi.cc:10–23  ·  view source on GitHub ↗

A function to be called from Wasm code.

Source from the content-addressed store, hash-verified

8
9// A function to be called from Wasm code.
10auto callback(
11 const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
12) -> wasm::own<wasm::Trap> {
13 std::cout << "Calling back..." << std::endl;
14 std::cout << "> " << args[0].i32();
15 std::cout << " " << args[1].i64();
16 std::cout << " " << args[2].i64();
17 std::cout << " " << args[3].i32() << std::endl;
18 results[0] = args[3].copy();
19 results[1] = args[1].copy();
20 results[2] = args[2].copy();
21 results[3] = args[0].copy();
22 return nullptr;
23}
24
25
26void run() {

Callers

nothing calls this directly

Calls 3

i32Method · 0.80
i64Method · 0.80
copyMethod · 0.45

Tested by

no test coverage detected