defineFunction method
void
defineFunction(
- String module,
- String name,
- WasmFuncType signature,
- WasmHostFunction function,
Defines module.name as a host function.
Implementation
void defineFunction(
String module,
String name,
WasmFuncType signature,
WasmHostFunction function,
) {
final trampoline = WasmHostTrampoline(signature, function);
_trampolines.add(trampoline);
scoped((arena) {
final (modulePtr, moduleLength) = copyChars(arena, module);
final (namePtr, nameLength) = copyChars(arena, name);
signature.withNative((type) {
throwIfError(
c.wasmtime_linker_define_func(
pointer,
modulePtr,
moduleLength,
namePtr,
nameLength,
type,
trampoline.callback,
ffi.nullptr,
ffi.nullptr,
),
);
});
});
}