pub fn call_dynamic<M: MemorySize>(
ctx: FunctionEnvMut<'_, WasiEnv>,
function_id: u32,
values: WasmPtr<u8, M>,
values_len: M::Offset,
results: WasmPtr<u8, M>,
results_len: M::Offset,
strict: Bool,
) -> Result<Errno, RuntimeError>
Expand description
Call a function from the __indirect_function_table
with parameters and results from memory.
This function can be used to call functions whose types are not known at compile time of the caller. It is the callers responsibility to ensure that the passed parameters and results match the signature of the function beeing called.
§Format of the values and results buffer
The buffers contain all values sequentially. i32, and f32 are 4 bytes, i64 and f64 are 8 bytes, v128 is 16 bytes.
For example if the function takes an i32 and an i64, the values buffer will be 12 bytes long, with the first 4 bytes being the i32 and the next 8 bytes being the i64.
§Parameters
-
function_id: The indirect function table index of the function to call
-
values: Pointer to a sequence of values that will be passed to the function. The buffer will be interpreted as described above. If the function does not have any parameters, this can be a nullptr (0).
-
results: Pointer to a sequence of values. If the function does not return a value, this can be a nullptr (0). The buffer needs to be large enough to hold all return values.