wasmtime_instance_new function

  1. @Native<Pointer<wasmtime_error_t> Function(Pointer<wasmtime_context_t>, Pointer<wasmtime_module_t>, Pointer<wasmtime_extern_t>, Size, Pointer<wasmtime_instance_t>, Pointer<Pointer<wasm_trap_t>>)>(ffi.Pointer<wasmtime_context_t>, ffi.Pointer<wasmtime_module_t>, ffi.Pointer<wasmtime_extern_t>, ffi.Size, ffi.Pointer<wasmtime_instance_t>, ffi.Pointer<ffi.Pointer<wasm_trap_t>>)>()
Pointer<wasmtime_error_t> wasmtime_instance_new(
  1. Pointer<wasmtime_context_t> store,
  2. Pointer<wasmtime_module_t> module,
  3. Pointer<wasmtime_extern_t> imports,
  4. int nimports,
  5. Pointer<wasmtime_instance_t> instance,
  6. Pointer<Pointer<wasm_trap_t>> trap,
)

\brief Instantiate a wasm module.

This function will instantiate a WebAssembly module with the provided imports, creating a WebAssembly instance. The returned instance can then afterwards be inspected for exports.

\param store the store in which to create the instance \param module the module that's being instantiated \param imports the imports provided to the module \param nimports the size of imports \param instance where to store the returned instance \param trap where to store the returned trap

This function requires that imports is the same size as the imports that module has. Additionally the imports array must be 1:1 lined up with the imports of the module specified. This is intended to be relatively low level, and #wasmtime_linker_instantiate is provided for a more ergonomic name-based resolution API.

The states of return values from this function are similar to #wasmtime_func_call where an error can be returned meaning something like a link error in this context. A trap can be returned (meaning no error or instance is returned), or an instance can be returned (meaning no error or trap is returned).

Note that this function requires that all imports specified must be owned by the store provided as well.

This function does not take ownership of any of its arguments, but all return values are owned by the caller.

Implementation

@ffi.Native<
  ffi.Pointer<wasmtime_error_t> Function(
    ffi.Pointer<wasmtime_context_t>,
    ffi.Pointer<wasmtime_module_t>,
    ffi.Pointer<wasmtime_extern_t>,
    ffi.Size,
    ffi.Pointer<wasmtime_instance_t>,
    ffi.Pointer<ffi.Pointer<wasm_trap_t>>,
  )
>()
external ffi.Pointer<wasmtime_error_t> wasmtime_instance_new(
  ffi.Pointer<wasmtime_context_t> store,
  ffi.Pointer<wasmtime_module_t> module,
  ffi.Pointer<wasmtime_extern_t> imports,
  int nimports,
  ffi.Pointer<wasmtime_instance_t> instance,
  ffi.Pointer<ffi.Pointer<wasm_trap_t>> trap,
);