MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / callback

Function callback

examples/multi.c:27–42  ·  view source on GitHub ↗

A function to be called from Wasm code.

Source from the content-addressed store, hash-verified

25
26// A function to be called from Wasm code.
27wasm_trap_t *callback(void *env, wasmtime_caller_t *caller,
28 const wasmtime_val_t *args, size_t nargs,
29 wasmtime_val_t *results, size_t nresults) {
30 (void)env;
31 (void)caller;
32 (void)nargs;
33 (void)nresults;
34
35 printf("Calling back...\n");
36 printf("> %" PRIu32 " %" PRIu64 "\n", args[0].of.i32, args[1].of.i64);
37 printf("\n");
38
39 results[0] = args[1];
40 results[1] = args[0];
41 return NULL;
42}
43
44// A function closure.
45wasm_trap_t *closure_callback(void *env, wasmtime_caller_t *caller,

Calls

no outgoing calls

Tested by

no test coverage detected