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

Function wasm_func_new_with_env

crates/c-api/src/func.rs:105–117  ·  view source on GitHub ↗
(
    store: &mut wasm_store_t,
    ty: &wasm_functype_t,
    callback: wasm_func_callback_with_env_t,
    data: *mut c_void,
    finalizer: Option<extern "C" fn(arg1: *mut std::ffi::c_void)>,
)

Source from the content-addressed store, hash-verified

103
104#[unsafe(no_mangle)]
105pub unsafe extern "C" fn wasm_func_new_with_env(
106 store: &mut wasm_store_t,
107 ty: &wasm_functype_t,
108 callback: wasm_func_callback_with_env_t,
109 data: *mut c_void,
110 finalizer: Option<extern "C" fn(arg1: *mut std::ffi::c_void)>,
111) -> Box<wasm_func_t> {
112 let finalizer = crate::ForeignData { data, finalizer };
113 create_function(store, ty, move |params, results| {
114 let _ = &finalizer; // move entire finalizer into this closure
115 callback(finalizer.data, params, results)
116 })
117}
118
119/// Places the `args` into `dst` and additionally reserves space in `dst` for `results_size`
120/// returns. The params/results slices are then returned separately.

Callers

nothing calls this directly

Calls 2

create_functionFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected