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

Method func_wrap

crates/c-api/include/wasmtime/linker.hh:149–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147 std::enable_if_t<WasmHostFunc<F>::Params::valid, bool> = true,
148 std::enable_if_t<WasmHostFunc<F>::Results::valid, bool> = true>
149 Result<std::monostate> func_wrap(std::string_view module,
150 std::string_view name, F &&f) {
151 using HostFunc = WasmHostFunc<F>;
152 auto params = HostFunc::Params::types();
153 auto results = HostFunc::Results::types();
154 auto ty = FuncType::from_iters(params, results);
155 auto *error = wasmtime_linker_define_func_unchecked(
156 ptr.get(), module.data(), module.length(), name.data(), name.length(),
157 ty.ptr.get(), Func::raw_callback_unchecked<std::remove_reference_t<F>>,
158 std::make_unique<std::remove_reference_t<F>>(std::forward<F>(f))
159 .release(),
160 Func::raw_finalize<std::remove_reference_t<F>>);
161
162 if (error != nullptr) {
163 return Error(error);
164 }
165
166 return std::monostate();
167 }
168
169 /// Loads the "default" function, according to WASI commands and reactors, of
170 /// the module named `name` in this linker.

Callers 15

add_to_linker_instanceFunction · 0.45
add_to_linker_importsMethod · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_get_hostFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45
add_to_linker_instanceFunction · 0.45

Calls 6

typesFunction · 0.85
releaseMethod · 0.80
ErrorClass · 0.70
getMethod · 0.45
dataMethod · 0.45

Tested by 15

add_to_linker_instanceFunction · 0.36
add_to_linker_importsMethod · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_get_hostFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36
add_to_linker_instanceFunction · 0.36