Wasmtime
wasm.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  wasm_byte_vec_t
 A list of bytes. More...
 
struct  wasm_limits_t
 Limits for tables/memories in wasm modules. More...
 
struct  wasm_valtype_vec_t
 A list of wasm_valtype_t values. More...
 
struct  wasm_functype_vec_t
 A list of wasm_functype_t values. More...
 
struct  wasm_globaltype_vec_t
 A list of wasm_globaltype_t values. More...
 
struct  wasm_tabletype_vec_t
 A list of wasm_tabletype_t values. More...
 
struct  wasm_memorytype_vec_t
 A list of wasm_memorytype_t values. More...
 
struct  wasm_externtype_vec_t
 A list of wasm_externtype_t values. More...
 
struct  wasm_importtype_vec_t
 A list of wasm_importtype_t values. More...
 
struct  wasm_exporttype_vec_t
 A list of wasm_exporttype_t values. More...
 
struct  wasm_val_t
 Representation of a WebAssembly value. More...
 
struct  wasm_val_vec_t
 A list of wasm_val_t values. More...
 
struct  wasm_frame_vec_t
 A list of wasm_frame_t frameues. More...
 
struct  wasm_extern_vec_t
 A list of wasm_extern_t values. More...
 

Macros

#define wasm_name   wasm_byte_vec
 Unused by Wasmtime.
 
#define wasm_name_new   wasm_byte_vec_new
 Convenience alias.
 
#define wasm_name_new_empty   wasm_byte_vec_new_empty
 Convenience alias.
 
#define wasm_name_new_new_uninitialized   wasm_byte_vec_new_uninitialized
 Convenience alias.
 
#define wasm_name_copy   wasm_byte_vec_copy
 Convenience alias.
 
#define wasm_name_delete   wasm_byte_vec_delete
 Convenience alias.
 
#define WASM_EMPTY_VEC   {0, NULL}
 Used to initialize an empty vector type.
 
#define WASM_ARRAY_VEC(array)   {sizeof(array)/sizeof(*(array)), array}
 Used to initialize a vector type from a C array.
 
#define WASM_I32_VAL(i)   {.kind = WASM_I32, .of = {.i32 = i}}
 Used to initialize a 32-bit integer wasm_val_t value.
 
#define WASM_I64_VAL(i)   {.kind = WASM_I64, .of = {.i64 = i}}
 Used to initialize a 64-bit integer wasm_val_t value.
 
#define WASM_F32_VAL(z)   {.kind = WASM_F32, .of = {.f32 = z}}
 Used to initialize a 32-bit floating point wasm_val_t value.
 
#define WASM_F64_VAL(z)   {.kind = WASM_F64, .of = {.f64 = z}}
 Used to initialize a 64-bit floating point wasm_val_t value.
 
#define WASM_REF_VAL(r)   {.kind = WASM_EXTERNREF, .of = {.ref = r}}
 Used to initialize an externref wasm_val_t value.
 
#define WASM_INIT_VAL   {.kind = WASM_EXTERNREF, .of = {.ref = NULL}}
 Used to initialize a null externref wasm_val_t value.
 

Typedefs

typedef char byte_t
 A type definition for a number that occupies a single byte of data.
 
typedef float float32_t
 A type definition for a 32-bit float.
 
typedef double float64_t
 A type definition for a 64-bit float.
 
typedef byte_t wasm_byte_t
 A type definition for a number that occupies a single byte of data.
 
typedef struct wasm_byte_vec_t wasm_byte_vec_t
 Convenience alias for wasm_byte_vec_t.
 
typedef wasm_byte_vec_t wasm_name_t
 Convenience for hinting that an argument only accepts utf-8 input.
 
typedef struct wasm_config_t wasm_config_t
 Convenience alias for wasm_config_t.
 
typedef struct wasm_engine_t wasm_engine_t
 Convenience alias for wasm_engine_t.
 
typedef struct wasm_store_t wasm_store_t
 Convenience alias for wasm_store_t.
 
typedef uint8_t wasm_mutability_t
 Boolean flag for whether a global is mutable or not.
 
typedef struct wasm_limits_t wasm_limits_t
 A convenience typedef to wasm_limits_t.
 
typedef struct wasm_valtype_t wasm_valtype_t
 Convenience alias for wasm_valtype_t.
 
typedef struct wasm_valtype_vec_t wasm_valtype_vec_t
 Convenience alias for wasm_valtype_vec_t.
 
typedef uint8_t wasm_valkind_t
 Different kinds of types supported in wasm.
 
typedef struct wasm_functype_t wasm_functype_t
 Convenience alias for wasm_functype_t.
 
typedef struct wasm_functype_vec_t wasm_functype_vec_t
 Convenience alias for wasm_functype_vec_t.
 
typedef struct wasm_globaltype_t wasm_globaltype_t
 Convenience alias for wasm_globaltype_t.
 
typedef struct wasm_globaltype_vec_t wasm_globaltype_vec_t
 Convenience alias for wasm_globaltype_vec_t.
 
typedef struct wasm_tabletype_t wasm_tabletype_t
 Convenience alias for wasm_tabletype_t.
 
typedef struct wasm_tabletype_vec_t wasm_tabletype_vec_t
 Convenience alias for wasm_tabletype_vec_t.
 
typedef struct wasm_memorytype_t wasm_memorytype_t
 Convenience alias for wasm_memorytype_t.
 
typedef struct wasm_memorytype_vec_t wasm_memorytype_vec_t
 Convenience alias for wasm_memorytype_vec_t.
 
typedef struct wasm_externtype_t wasm_externtype_t
 Convenience alias for wasm_externtype_t.
 
typedef struct wasm_externtype_vec_t wasm_externtype_vec_t
 Convenience alias for wasm_externtype_vec_t.
 
typedef uint8_t wasm_externkind_t
 Classifier for wasm_externtype_t. More...
 
typedef struct wasm_importtype_t wasm_importtype_t
 Convenience alias for wasm_importtype_t.
 
typedef struct wasm_importtype_vec_t wasm_importtype_vec_t
 Convenience alias for wasm_importtype_vec_t.
 
typedef struct wasm_exporttype_t wasm_exporttype_t
 Convenience alias for wasm_exporttype_t.
 
typedef struct wasm_exporttype_vec_t wasm_exporttype_vec_t
 Convenience alias for wasm_exporttype_vec_t.
 
typedef struct wasm_val_t wasm_val_t
 Convenience alias for wasm_val_t.
 
typedef struct wasm_val_vec_t wasm_val_vec_t
 Convenience alias for wasm_val_vec_t.
 
typedef struct wasm_ref_t wasm_ref_t
 Convenience alias for wasm_ref_t.
 
typedef struct wasm_frame_t wasm_frame_t
 Convenience alias for wasm_frame_t.
 
typedef struct wasm_frame_vec_t wasm_frame_vec_t
 Convenience alias for wasm_frame_vec_t.
 
typedef wasm_name_t wasm_message_t
 Alias of wasm_byte_vec_t which always has a trailing 0-byte.
 
typedef struct wasm_trap_t wasm_trap_t
 Convenience alias for wasm_trap_t.
 
typedef struct wasm_foreign_t wasm_foreign_t
 Convenience alias for wasm_foreign_t.
 
typedef struct wasm_module_t wasm_module_t
 Convenience alias for wasm_module_t.
 
typedef struct wasm_shared_module_t wasm_shared_module_t
 Convenience alias for wasm_shared_module_t.
 
typedef struct wasm_func_t wasm_func_t
 Convenience alias for wasm_func_t.
 
typedef wasm_trap_t *(* wasm_func_callback_t) (const wasm_val_vec_t *args, wasm_val_vec_t *results)
 Type definition for functions passed to wasm_func_new. More...
 
typedef wasm_trap_t *(* wasm_func_callback_with_env_t) (void *env, const wasm_val_vec_t *args, wasm_val_vec_t *results)
 Type definition for functions passed to wasm_func_new_with_env. More...
 
typedef struct wasm_global_t wasm_global_t
 Convenience alias for wasm_global_t.
 
typedef struct wasm_table_t wasm_table_t
 Convenience alias for wasm_table_t.
 
typedef uint32_t wasm_table_size_t
 Typedef for indices and sizes of wasm tables.
 
typedef struct wasm_memory_t wasm_memory_t
 Convenience alias for wasm_memory_t.
 
typedef uint32_t wasm_memory_pages_t
 Unsigned integer to hold the number of pages a memory has.
 
typedef struct wasm_extern_t wasm_extern_t
 Convenience alias for wasm_extern_t.
 
typedef struct wasm_extern_vec_t wasm_extern_vec_t
 Convenience alias for wasm_extern_vec_t.
 
typedef struct wasm_instance_t wasm_instance_t
 Convenience alias for wasm_instance_t.
 

Functions

void wasm_byte_vec_new_empty (wasm_byte_vec_t *out)
 Initializes an empty byte vector.
 
void wasm_byte_vec_new_uninitialized (wasm_byte_vec_t *out, size_t)
 Initializes an byte vector with the specified capacity. More...
 
void wasm_byte_vec_new (wasm_byte_vec_t *out, size_t, wasm_byte_t const[])
 Copies the specified data into a new byte vector. More...
 
void wasm_byte_vec_copy (wasm_byte_vec_t *out, const wasm_byte_vec_t *)
 Copies one vector into a new vector. More...
 
void wasm_byte_vec_delete (wasm_byte_vec_t *)
 Deletes a byte vector. More...
 
void wasm_config_delete (wasm_config_t *)
 Deletes a configuration object.
 
wasm_config_twasm_config_new (void)
 Creates a new empty configuration object. More...
 
void wasm_engine_delete (wasm_engine_t *)
 Deletes an engine.
 
wasm_engine_twasm_engine_new (void)
 Creates a new engine with the default configuration. More...
 
wasm_engine_twasm_engine_new_with_config (wasm_config_t *)
 Creates a new engine with the specified configuration. More...
 
void wasm_store_delete (wasm_store_t *)
 Deletes the specified store.
 
wasm_store_twasm_store_new (wasm_engine_t *)
 Creates a new store within the specified engine. More...
 
void wasm_valtype_delete (wasm_valtype_t *)
 Deletes a type.
 
void wasm_valtype_vec_new_empty (wasm_valtype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_valtype_vec_new_uninitialized (wasm_valtype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_valtype_vec_new (wasm_valtype_vec_t *out, size_t, wasm_valtype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_valtype_vec_copy (wasm_valtype_vec_t *out, const wasm_valtype_vec_t *)
 Copies one vector to another. More...
 
void wasm_valtype_vec_delete (wasm_valtype_vec_t *)
 Deallocates memory for a vector. More...
 
wasm_valtype_twasm_valtype_copy (const wasm_valtype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_valtype_twasm_valtype_new (wasm_valkind_t)
 Creates a new value type from the specified kind. More...
 
wasm_valkind_t wasm_valtype_kind (const wasm_valtype_t *)
 Returns the associated kind for this value type.
 
void wasm_functype_delete (wasm_functype_t *)
 Deletes a type.
 
void wasm_functype_vec_new_empty (wasm_functype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_functype_vec_new_uninitialized (wasm_functype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_functype_vec_new (wasm_functype_vec_t *out, size_t, wasm_functype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_functype_vec_copy (wasm_functype_vec_t *out, const wasm_functype_vec_t *)
 Copies one vector to another. More...
 
void wasm_functype_vec_delete (wasm_functype_vec_t *)
 Deallocates memory for a vector. More...
 
wasm_functype_twasm_functype_copy (const wasm_functype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_functype_twasm_functype_new (wasm_valtype_vec_t *params, wasm_valtype_vec_t *results)
 Creates a new function type with the provided parameter and result types. More...
 
const wasm_valtype_vec_twasm_functype_params (const wasm_functype_t *)
 Returns the list of parameters of this function type. More...
 
const wasm_valtype_vec_twasm_functype_results (const wasm_functype_t *)
 Returns the list of results of this function type. More...
 
void wasm_globaltype_delete (wasm_globaltype_t *)
 Deletes a type.
 
void wasm_globaltype_vec_new_empty (wasm_globaltype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_globaltype_vec_new_uninitialized (wasm_globaltype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_globaltype_vec_new (wasm_globaltype_vec_t *out, size_t, wasm_globaltype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_globaltype_vec_copy (wasm_globaltype_vec_t *out, const wasm_globaltype_vec_t *)
 Copies one vector to another. More...
 
void wasm_globaltype_vec_delete (wasm_globaltype_vec_t *)
 Deallocates memory for a vector. More...
 
wasm_globaltype_twasm_globaltype_copy (const wasm_globaltype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_globaltype_twasm_globaltype_new (wasm_valtype_t *, wasm_mutability_t)
 Creates a new global type. More...
 
const wasm_valtype_twasm_globaltype_content (const wasm_globaltype_t *)
 Returns the type of value contained in a global. More...
 
wasm_mutability_t wasm_globaltype_mutability (const wasm_globaltype_t *)
 Returns whether or not a global is mutable.
 
void wasm_tabletype_delete (wasm_tabletype_t *)
 Deletes a type.
 
void wasm_tabletype_vec_new_empty (wasm_tabletype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_tabletype_vec_new_uninitialized (wasm_tabletype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_tabletype_vec_new (wasm_tabletype_vec_t *out, size_t, wasm_tabletype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_tabletype_vec_copy (wasm_tabletype_vec_t *out, const wasm_tabletype_vec_t *)
 Copies one vector to another. More...
 
void wasm_tabletype_vec_delete (wasm_tabletype_vec_t *)
 Deallocates memory for a vector. More...
 
wasm_tabletype_twasm_tabletype_copy (const wasm_tabletype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_tabletype_twasm_tabletype_new (wasm_valtype_t *, const wasm_limits_t *)
 Creates a new table type. More...
 
const wasm_valtype_twasm_tabletype_element (const wasm_tabletype_t *)
 Returns the element type of this table. More...
 
const wasm_limits_twasm_tabletype_limits (const wasm_tabletype_t *)
 Returns the limits of this table. More...
 
void wasm_memorytype_delete (wasm_memorytype_t *)
 Deletes a type.
 
void wasm_memorytype_vec_new_empty (wasm_memorytype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_memorytype_vec_new_uninitialized (wasm_memorytype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_memorytype_vec_new (wasm_memorytype_vec_t *out, size_t, wasm_memorytype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_memorytype_vec_copy (wasm_memorytype_vec_t *out, const wasm_memorytype_vec_t *)
 Copies one vector to another. More...
 
void wasm_memorytype_vec_delete (wasm_memorytype_vec_t *)
 Deallocates memory for a vector. More...
 
wasm_memorytype_twasm_memorytype_copy (const wasm_memorytype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_memorytype_twasm_memorytype_new (const wasm_limits_t *)
 Creates a new memory type. More...
 
const wasm_limits_twasm_memorytype_limits (const wasm_memorytype_t *)
 Returns the limits of this memory. More...
 
void wasm_externtype_delete (wasm_externtype_t *)
 Deletes a type.
 
void wasm_externtype_vec_new_empty (wasm_externtype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_externtype_vec_new_uninitialized (wasm_externtype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_externtype_vec_new (wasm_externtype_vec_t *out, size_t, wasm_externtype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_externtype_vec_copy (wasm_externtype_vec_t *out, const wasm_externtype_vec_t *)
 Copies one vector to another. More...
 
void wasm_externtype_vec_delete (wasm_externtype_vec_t *)
 Deallocates extern for a vector. More...
 
wasm_externtype_twasm_externtype_copy (const wasm_externtype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_externkind_t wasm_externtype_kind (const wasm_externtype_t *)
 Returns the kind of external item this type represents.
 
wasm_externtype_twasm_functype_as_externtype (wasm_functype_t *)
 Converts a wasm_functype_t to a wasm_externtype_t. More...
 
wasm_externtype_twasm_globaltype_as_externtype (wasm_globaltype_t *)
 Converts a wasm_globaltype_t to a wasm_externtype_t. More...
 
wasm_externtype_twasm_tabletype_as_externtype (wasm_tabletype_t *)
 Converts a wasm_tabletype_t to a wasm_externtype_t. More...
 
wasm_externtype_twasm_memorytype_as_externtype (wasm_memorytype_t *)
 Converts a wasm_memorytype_t to a wasm_externtype_t. More...
 
wasm_functype_twasm_externtype_as_functype (wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_functype_t. More...
 
wasm_globaltype_twasm_externtype_as_globaltype (wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_globaltype_t. More...
 
wasm_tabletype_twasm_externtype_as_tabletype (wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_tabletype_t. More...
 
wasm_memorytype_twasm_externtype_as_memorytype (wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_memorytype_t. More...
 
const wasm_externtype_twasm_functype_as_externtype_const (const wasm_functype_t *)
 Converts a wasm_functype_t to a wasm_externtype_t. More...
 
const wasm_externtype_twasm_globaltype_as_externtype_const (const wasm_globaltype_t *)
 Converts a wasm_globaltype_t to a wasm_externtype_t. More...
 
const wasm_externtype_twasm_tabletype_as_externtype_const (const wasm_tabletype_t *)
 Converts a wasm_tabletype_t to a wasm_externtype_t. More...
 
const wasm_externtype_twasm_memorytype_as_externtype_const (const wasm_memorytype_t *)
 Converts a wasm_memorytype_t to a wasm_externtype_t. More...
 
const wasm_functype_twasm_externtype_as_functype_const (const wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_functype_t. More...
 
const wasm_globaltype_twasm_externtype_as_globaltype_const (const wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_globaltype_t. More...
 
const wasm_tabletype_twasm_externtype_as_tabletype_const (const wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_tabletype_t. More...
 
const wasm_memorytype_twasm_externtype_as_memorytype_const (const wasm_externtype_t *)
 Attempts to convert a wasm_externtype_t to a wasm_memorytype_t. More...
 
void wasm_importtype_delete (wasm_importtype_t *)
 Deletes a type.
 
void wasm_importtype_vec_new_empty (wasm_importtype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_importtype_vec_new_uninitialized (wasm_importtype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_importtype_vec_new (wasm_importtype_vec_t *out, size_t, wasm_importtype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_importtype_vec_copy (wasm_importtype_vec_t *out, const wasm_importtype_vec_t *)
 Copies one vector to another. More...
 
void wasm_importtype_vec_delete (wasm_importtype_vec_t *)
 Deallocates import for a vector. More...
 
wasm_importtype_twasm_importtype_copy (const wasm_importtype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_importtype_twasm_importtype_new (wasm_name_t *module, wasm_name_t *name, wasm_externtype_t *)
 Creates a new import type. More...
 
const wasm_name_twasm_importtype_module (const wasm_importtype_t *)
 Returns the module this import is importing from. More...
 
const wasm_name_twasm_importtype_name (const wasm_importtype_t *)
 Returns the name this import is importing from. More...
 
const wasm_externtype_twasm_importtype_type (const wasm_importtype_t *)
 Returns the type of item this import is importing. More...
 
void wasm_exporttype_delete (wasm_exporttype_t *)
 Deletes a type.
 
void wasm_exporttype_vec_new_empty (wasm_exporttype_vec_t *out)
 Creates an empty vector. More...
 
void wasm_exporttype_vec_new_uninitialized (wasm_exporttype_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_exporttype_vec_new (wasm_exporttype_vec_t *out, size_t, wasm_exporttype_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_exporttype_vec_copy (wasm_exporttype_vec_t *out, const wasm_exporttype_vec_t *)
 Copies one vector to another. More...
 
void wasm_exporttype_vec_delete (wasm_exporttype_vec_t *)
 Deallocates export for a vector. More...
 
wasm_exporttype_twasm_exporttype_copy (const wasm_exporttype_t *)
 Creates a new value which matches the provided one. More...
 
wasm_exporttype_twasm_exporttype_new (wasm_name_t *, wasm_externtype_t *)
 Creates a new export type. More...
 
const wasm_name_twasm_exporttype_name (const wasm_exporttype_t *)
 Returns the name of this export. More...
 
const wasm_externtype_twasm_exporttype_type (const wasm_exporttype_t *)
 Returns the type of this export. More...
 
void wasm_val_delete (wasm_val_t *v)
 Deletes a type. More...
 
void wasm_val_copy (wasm_val_t *out, const wasm_val_t *)
 Copies a wasm_val_t to a new one. More...
 
void wasm_val_vec_new_empty (wasm_val_vec_t *out)
 Creates an empty vector. More...
 
void wasm_val_vec_new_uninitialized (wasm_val_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_val_vec_new (wasm_val_vec_t *out, size_t, wasm_val_t const[])
 Creates a vector with the provided contents. More...
 
void wasm_val_vec_copy (wasm_val_vec_t *out, const wasm_val_vec_t *)
 Copies one vector to another. More...
 
void wasm_val_vec_delete (wasm_val_vec_t *)
 Deallocates export for a vector. More...
 
void wasm_ref_delete (wasm_ref_t *)
 Delete a reference.
 
wasm_ref_twasm_ref_copy (const wasm_ref_t *)
 Copy a reference.
 
bool wasm_ref_same (const wasm_ref_t *, const wasm_ref_t *)
 Are the given references pointing to the same externref? More...
 
void * wasm_ref_get_host_info (const wasm_ref_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_ref_set_host_info (wasm_ref_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_ref_set_host_info_with_finalizer (wasm_ref_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_frame_delete (wasm_frame_t *)
 Deletes a frame.
 
void wasm_frame_vec_new_empty (wasm_frame_vec_t *out)
 Creates an empty vector. More...
 
void wasm_frame_vec_new_uninitialized (wasm_frame_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_frame_vec_new (wasm_frame_vec_t *out, size_t, wasm_frame_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_frame_vec_copy (wasm_frame_vec_t *out, const wasm_frame_vec_t *)
 Copies one vector to another. More...
 
void wasm_frame_vec_delete (wasm_frame_vec_t *)
 Deallocates export for a vector. More...
 
wasm_frame_twasm_frame_copy (const wasm_frame_t *)
 Returns a copy of the provided frame. More...
 
struct wasm_instance_twasm_frame_instance (const wasm_frame_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
uint32_t wasm_frame_func_index (const wasm_frame_t *)
 Returns the function index in the original wasm module that this frame corresponds to.
 
size_t wasm_frame_func_offset (const wasm_frame_t *)
 Returns the byte offset from the beginning of the function in the original wasm file to the instruction this frame points to.
 
size_t wasm_frame_module_offset (const wasm_frame_t *)
 Returns the byte offset from the beginning of the original wasm file to the instruction this frame points to.
 
void wasm_trap_delete (wasm_trap_t *)
 Deletes a trap.
 
wasm_trap_twasm_trap_copy (const wasm_trap_t *)
 Copies a wasm_trap_t to a new one. More...
 
bool wasm_trap_same (const wasm_trap_t *, const wasm_trap_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_trap_get_host_info (const wasm_trap_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_trap_set_host_info (wasm_trap_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_trap_set_host_info_with_finalizer (wasm_trap_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_trap_as_ref (wasm_trap_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_trap_twasm_ref_as_trap (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_trap_as_ref_const (const wasm_trap_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_trap_twasm_ref_as_trap_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_trap_twasm_trap_new (wasm_store_t *store, const wasm_message_t *)
 Creates a new wasm_trap_t with the provided message. More...
 
void wasm_trap_message (const wasm_trap_t *, wasm_message_t *out)
 Retrieves the message associated with this trap. More...
 
wasm_frame_twasm_trap_origin (const wasm_trap_t *)
 Returns the top frame of the wasm stack responsible for this trap. More...
 
void wasm_trap_trace (const wasm_trap_t *, wasm_frame_vec_t *out)
 Returns the trace of wasm frames for this trap. More...
 
void wasm_foreign_delete (wasm_foreign_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_foreign_twasm_foreign_copy (const wasm_foreign_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
bool wasm_foreign_same (const wasm_foreign_t *, const wasm_foreign_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_foreign_get_host_info (const wasm_foreign_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_foreign_set_host_info (wasm_foreign_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_foreign_set_host_info_with_finalizer (wasm_foreign_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_foreign_as_ref (wasm_foreign_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_foreign_twasm_ref_as_foreign (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_foreign_as_ref_const (const wasm_foreign_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_foreign_twasm_ref_as_foreign_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_foreign_twasm_foreign_new (wasm_store_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_module_delete (wasm_module_t *)
 Deletes a module.
 
wasm_module_twasm_module_copy (const wasm_module_t *)
 Copies a wasm_module_t to a new one. More...
 
bool wasm_module_same (const wasm_module_t *, const wasm_module_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_module_get_host_info (const wasm_module_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_module_set_host_info (wasm_module_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_module_set_host_info_with_finalizer (wasm_module_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_module_as_ref (wasm_module_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_module_twasm_ref_as_module (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_module_as_ref_const (const wasm_module_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_module_twasm_ref_as_module_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_shared_module_delete (wasm_shared_module_t *)
 Deletes the provided module.
 
wasm_shared_module_twasm_module_share (const wasm_module_t *)
 Creates a shareable module from the provided module. More...
 
wasm_module_twasm_module_obtain (wasm_store_t *, const wasm_shared_module_t *)
 Attempts to create a wasm_module_t from the shareable module. More...
 
wasm_module_twasm_module_new (wasm_store_t *, const wasm_byte_vec_t *binary)
 Compiles a raw WebAssembly binary to a wasm_module_t. More...
 
bool wasm_module_validate (wasm_store_t *, const wasm_byte_vec_t *binary)
 Validates whether a provided byte sequence is a valid wasm binary. More...
 
void wasm_module_imports (const wasm_module_t *, wasm_importtype_vec_t *out)
 Returns the list of imports that this module expects. More...
 
void wasm_module_exports (const wasm_module_t *, wasm_exporttype_vec_t *out)
 Returns the list of exports that this module provides. More...
 
void wasm_module_serialize (const wasm_module_t *, wasm_byte_vec_t *out)
 Serializes the provided module to a byte vector. More...
 
wasm_module_twasm_module_deserialize (wasm_store_t *, const wasm_byte_vec_t *)
 Deserializes a previously-serialized module. More...
 
void wasm_func_delete (wasm_func_t *)
 Deletes a func.
 
wasm_func_twasm_func_copy (const wasm_func_t *)
 Copies a wasm_func_t to a new one. More...
 
bool wasm_func_same (const wasm_func_t *, const wasm_func_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_func_get_host_info (const wasm_func_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_func_set_host_info (wasm_func_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_func_set_host_info_with_finalizer (wasm_func_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_func_as_ref (wasm_func_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_func_twasm_ref_as_func (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_func_as_ref_const (const wasm_func_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_func_twasm_ref_as_func_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_func_twasm_func_new (wasm_store_t *, const wasm_functype_t *, wasm_func_callback_t)
 Creates a new WebAssembly function with host functionality. More...
 
wasm_func_twasm_func_new_with_env (wasm_store_t *, const wasm_functype_t *type, wasm_func_callback_with_env_t, void *env, void(*finalizer)(void *))
 Creates a new WebAssembly function with host functionality. More...
 
wasm_functype_twasm_func_type (const wasm_func_t *)
 Returns the type of this function. More...
 
size_t wasm_func_param_arity (const wasm_func_t *)
 Returns the number of arguments expected by this function.
 
size_t wasm_func_result_arity (const wasm_func_t *)
 Returns the number of results returned by this function.
 
wasm_trap_twasm_func_call (const wasm_func_t *, const wasm_val_vec_t *args, wasm_val_vec_t *results)
 Calls the provided function with the arguments given. More...
 
void wasm_global_delete (wasm_global_t *)
 Deletes a global.
 
wasm_global_twasm_global_copy (const wasm_global_t *)
 Copies a wasm_global_t to a new one. More...
 
bool wasm_global_same (const wasm_global_t *, const wasm_global_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_global_get_host_info (const wasm_global_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_global_set_host_info (wasm_global_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_global_set_host_info_with_finalizer (wasm_global_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_global_as_ref (wasm_global_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_global_twasm_ref_as_global (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_global_as_ref_const (const wasm_global_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_global_twasm_ref_as_global_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_global_twasm_global_new (wasm_store_t *, const wasm_globaltype_t *, const wasm_val_t *)
 Creates a new WebAssembly global. More...
 
wasm_globaltype_twasm_global_type (const wasm_global_t *)
 Returns the type of this global. More...
 
void wasm_global_get (const wasm_global_t *, wasm_val_t *out)
 Gets the value of this global. More...
 
void wasm_global_set (wasm_global_t *, const wasm_val_t *)
 Sets the value of this global. More...
 
void wasm_table_delete (wasm_table_t *)
 Deletes a table.
 
wasm_table_twasm_table_copy (const wasm_table_t *)
 Copies a wasm_table_t to a new one. More...
 
bool wasm_table_same (const wasm_table_t *, const wasm_table_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_table_get_host_info (const wasm_table_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_table_set_host_info (wasm_table_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_table_set_host_info_with_finalizer (wasm_table_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_table_as_ref (wasm_table_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_table_twasm_ref_as_table (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_table_as_ref_const (const wasm_table_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_table_twasm_ref_as_table_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_table_twasm_table_new (wasm_store_t *, const wasm_tabletype_t *, wasm_ref_t *init)
 Creates a new WebAssembly table. More...
 
wasm_tabletype_twasm_table_type (const wasm_table_t *)
 Returns the type of this table. More...
 
wasm_ref_twasm_table_get (const wasm_table_t *, wasm_table_size_t index)
 Gets an element from this table. More...
 
bool wasm_table_set (wasm_table_t *, wasm_table_size_t index, wasm_ref_t *)
 Sets an element in this table. More...
 
wasm_table_size_t wasm_table_size (const wasm_table_t *)
 Gets the current size, in elements, of this table.
 
bool wasm_table_grow (wasm_table_t *, wasm_table_size_t delta, wasm_ref_t *init)
 Attempts to grow this table by delta elements. More...
 
void wasm_memory_delete (wasm_memory_t *)
 Deletes a memory.
 
wasm_memory_twasm_memory_copy (const wasm_memory_t *)
 Copies a wasm_memory_t to a new one. More...
 
bool wasm_memory_same (const wasm_memory_t *, const wasm_memory_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_memory_get_host_info (const wasm_memory_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_memory_set_host_info (wasm_memory_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_memory_set_host_info_with_finalizer (wasm_memory_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_memory_as_ref (wasm_memory_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_memory_twasm_ref_as_memory (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_memory_as_ref_const (const wasm_memory_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_memory_twasm_ref_as_memory_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_memory_twasm_memory_new (wasm_store_t *, const wasm_memorytype_t *)
 Creates a new WebAssembly memory.
 
wasm_memorytype_twasm_memory_type (const wasm_memory_t *)
 Returns the type of this memory. More...
 
byte_twasm_memory_data (wasm_memory_t *)
 Returns the base address, in memory, where this memory is located. More...
 
size_t wasm_memory_data_size (const wasm_memory_t *)
 Returns the size, in bytes, of this memory.
 
wasm_memory_pages_t wasm_memory_size (const wasm_memory_t *)
 Returns the size, in wasm pages, of this memory.
 
bool wasm_memory_grow (wasm_memory_t *, wasm_memory_pages_t delta)
 Attempts to grow this memory by delta wasm pages. More...
 
void wasm_extern_delete (wasm_extern_t *)
 Deletes a extern.
 
wasm_extern_twasm_extern_copy (const wasm_extern_t *)
 Copies a wasm_extern_t to a new one. More...
 
bool wasm_extern_same (const wasm_extern_t *, const wasm_extern_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_extern_get_host_info (const wasm_extern_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_extern_set_host_info (wasm_extern_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_extern_set_host_info_with_finalizer (wasm_extern_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_extern_as_ref (wasm_extern_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_extern_twasm_ref_as_extern (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_extern_as_ref_const (const wasm_extern_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_extern_twasm_ref_as_extern_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_extern_vec_new_empty (wasm_extern_vec_t *out)
 Creates an empty vector. More...
 
void wasm_extern_vec_new_uninitialized (wasm_extern_vec_t *out, size_t)
 Creates a vector with the given capacity. More...
 
void wasm_extern_vec_new (wasm_extern_vec_t *out, size_t, wasm_extern_t *const[])
 Creates a vector with the provided contents. More...
 
void wasm_extern_vec_copy (wasm_extern_vec_t *out, const wasm_extern_vec_t *)
 Copies one vector to another. More...
 
void wasm_extern_vec_delete (wasm_extern_vec_t *)
 Deallocates import for a vector. More...
 
wasm_externkind_t wasm_extern_kind (const wasm_extern_t *)
 Returns the kind of this extern, indicating what it will downcast as.
 
wasm_externtype_twasm_extern_type (const wasm_extern_t *)
 Returns the type of this extern. More...
 
wasm_extern_twasm_func_as_extern (wasm_func_t *)
 Converts a wasm_func_t to wasm_extern_t. More...
 
wasm_extern_twasm_global_as_extern (wasm_global_t *)
 Converts a wasm_global_t to wasm_extern_t. More...
 
wasm_extern_twasm_table_as_extern (wasm_table_t *)
 Converts a wasm_table_t to wasm_extern_t. More...
 
wasm_extern_twasm_memory_as_extern (wasm_memory_t *)
 Converts a wasm_memory_t to wasm_extern_t. More...
 
wasm_func_twasm_extern_as_func (wasm_extern_t *)
 Converts a wasm_extern_t to wasm_func_t. More...
 
wasm_global_twasm_extern_as_global (wasm_extern_t *)
 Converts a wasm_extern_t to wasm_global_t. More...
 
wasm_table_twasm_extern_as_table (wasm_extern_t *)
 Converts a wasm_extern_t to wasm_table_t. More...
 
wasm_memory_twasm_extern_as_memory (wasm_extern_t *)
 Converts a wasm_extern_t to wasm_memory_t. More...
 
const wasm_extern_twasm_func_as_extern_const (const wasm_func_t *)
 Converts a wasm_func_t to wasm_extern_t. More...
 
const wasm_extern_twasm_global_as_extern_const (const wasm_global_t *)
 Converts a wasm_global_t to wasm_extern_t. More...
 
const wasm_extern_twasm_table_as_extern_const (const wasm_table_t *)
 Converts a wasm_table_t to wasm_extern_t. More...
 
const wasm_extern_twasm_memory_as_extern_const (const wasm_memory_t *)
 Converts a wasm_memory_t to wasm_extern_t. More...
 
const wasm_func_twasm_extern_as_func_const (const wasm_extern_t *)
 Converts a wasm_extern_t to wasm_func_t. More...
 
const wasm_global_twasm_extern_as_global_const (const wasm_extern_t *)
 Converts a wasm_extern_t to wasm_global_t. More...
 
const wasm_table_twasm_extern_as_table_const (const wasm_extern_t *)
 Converts a wasm_extern_t to wasm_table_t. More...
 
const wasm_memory_twasm_extern_as_memory_const (const wasm_extern_t *)
 Converts a wasm_extern_t to wasm_memory_t. More...
 
void wasm_instance_delete (wasm_instance_t *)
 Deletes a instance.
 
wasm_instance_twasm_instance_copy (const wasm_instance_t *)
 Copies a wasm_instance_t to a new one. More...
 
bool wasm_instance_same (const wasm_instance_t *, const wasm_instance_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void * wasm_instance_get_host_info (const wasm_instance_t *)
 Unimplemented in Wasmtime, always returns NULL.
 
void wasm_instance_set_host_info (wasm_instance_t *, void *)
 Unimplemented in Wasmtime, aborts the process if called.
 
void wasm_instance_set_host_info_with_finalizer (wasm_instance_t *, void *, void(*)(void *))
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_ref_twasm_instance_as_ref (wasm_instance_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_instance_twasm_ref_as_instance (wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_ref_twasm_instance_as_ref_const (const wasm_instance_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
const wasm_instance_twasm_ref_as_instance_const (const wasm_ref_t *)
 Unimplemented in Wasmtime, aborts the process if called.
 
wasm_instance_twasm_instance_new (wasm_store_t *, const wasm_module_t *, const wasm_extern_vec_t *imports, wasm_trap_t **)
 Instantiates a module with the provided imports. More...
 
void wasm_instance_exports (const wasm_instance_t *, wasm_extern_vec_t *out)
 Returns the exports of an instance. More...
 

Detailed Description

Upstream Embedding API for WebAssembly.

This API is defined by the upstream wasm-c-api proposal at https://github.com/WebAssembly/wasm-c-api. That proposal is in flux but Wasmtime intends to be active in its development.

The documentation for this header file is currently defined in the Wasmtime project, not in the upstream header file. Some behavior here may be Wasmtime-specific and may not be portable to other engines implementing the same C API. Also note that not all functionality from the upstream C API is implemented in Wasmtime. We strive to provide all symbols as to not generate link errors but some functions are unimplemented and will abort the process if called.

Memory Management

Memory management in the wasm C API is intended to be relatively simple. Each individual object is reference counted unless otherwise noted. You can delete any object at any time after you no longer need it. Deletion of an object does not imply that the memory will be deallocated at that time. If another object still internally references the original object then the memory will still be alive.

For example you can delete a wasm_engine_t after you create a wasm_store_t with wasm_store_new. The engine, however, is still referenced by the wasm_store_t so it will not be deallocated. In essence by calling wasm_engine_delete you're release your own strong reference on the wasm_engine_t, but that's it.

Additionally APIs like wasm_memory_copy do not actually copy the underlying data. Instead they only increment the reference count and return a new object. You'll need to still call wasm_memory_delete (or the corresponding *_delete function) for each copy of an object you acquire.

Vectors

This API provides a number of wasm_*_vec_t type definitions and functions to work with them. Each vector is defined by a pointer and a length. "Ownership" of a vector refers to the data pointer, not the memory holding the data pointer and the length. It is safe, for example to create a wasm_name_t on the stack and pass it to wasm_importtype_new. The memory pointed to by wasm_name_t must be properly initialized, however, and cannot reside on the stack.

Typedef Documentation

◆ wasm_externkind_t

Classifier for wasm_externtype_t.

This is returned from wasm_extern_kind and wasm_externtype_kind to determine what kind of type is wrapped.

◆ wasm_func_callback_t

wasm_func_callback_t

Type definition for functions passed to wasm_func_new.

This is the type signature of a host function created with wasm_func_new. This function takes two parameters, the first of which is the list of parameters to the function and the second of which is where to write the results. This function can optionally return a wasm_trap_t and does not have to fill in the results in that case.

It is guaranteed that this function will be called with the appropriate number and types of arguments according to the function type passed to wasm_func_new. It is required that this function produces the correct number and types of results as the original type signature. It is undefined behavior to return other types or different numbers of values.

Ownership of the results and the trap returned, if any, is passed to the caller of this function.

◆ wasm_func_callback_with_env_t

wasm_func_callback_with_env_t

Type definition for functions passed to wasm_func_new_with_env.

The semantics of this function are the same as those of wasm_func_callback_t, except the first argument is the same void* argument passed to wasm_func_new_with_env.

Function Documentation

◆ wasm_byte_vec_copy()

void wasm_byte_vec_copy ( wasm_byte_vec_t out,
const wasm_byte_vec_t  
)

Copies one vector into a new vector.

Copies the second argument's data into the first argument. The out vector should not be previously initialized and after this function returns you're responsible for calling wasm_byte_vec_delete.

◆ wasm_byte_vec_delete()

void wasm_byte_vec_delete ( wasm_byte_vec_t )

Deletes a byte vector.

This function will deallocate the data referenced by the argument provided. This does not deallocate the memory holding the wasm_byte_vec_t itself, it's expected that memory is owned by the caller.

◆ wasm_byte_vec_new()

void wasm_byte_vec_new ( wasm_byte_vec_t out,
size_t  ,
wasm_byte_t const  [] 
)

Copies the specified data into a new byte vector.

This function will copy the provided data into this byte vector. The byte vector should not be previously initialized and the caller is responsible for calling wasm_byte_vec_delete after this function returns.

Note that memory of the the initialization vector provided to this function must be managed externally. This function will copy the contents to the output vector, but it's up to the caller to properly deallocate the memory.

◆ wasm_byte_vec_new_uninitialized()

void wasm_byte_vec_new_uninitialized ( wasm_byte_vec_t out,
size_t   
)

Initializes an byte vector with the specified capacity.

This function will initialize the provided vector with capacity to hold the specified number of bytes. The out parameter must previously not already be initialized and after this function is called you are then responsible for ensuring wasm_byte_vec_delete is called.

◆ wasm_config_new()

wasm_config_t * wasm_config_new ( void  )

Creates a new empty configuration object.

The object returned is owned by the caller and will need to be deleted with wasm_config_delete. May return NULL if a configuration object could not be allocated.

◆ wasm_engine_new()

wasm_engine_t * wasm_engine_new ( void  )

Creates a new engine with the default configuration.

The object returned is owned by the caller and will need to be deleted with wasm_engine_delete. This may return NULL if the engine could not be allocated.

◆ wasm_engine_new_with_config()

wasm_engine_t * wasm_engine_new_with_config ( wasm_config_t )

Creates a new engine with the specified configuration.

This function will take ownership of the configuration specified regardless of the outcome of this function. You do not need to call wasm_config_delete on the argument. The object returned is owned by the caller and will need to be deleted with wasm_engine_delete. This may return NULL if the engine could not be allocated.

◆ wasm_exporttype_copy()

wasm_exporttype_t * wasm_exporttype_copy ( const wasm_exporttype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_exporttype_name()

const wasm_name_t * wasm_exporttype_name ( const wasm_exporttype_t )

Returns the name of this export.

The returned memory is owned by the wasm_exporttype_t argument, the caller should not deallocate it.

◆ wasm_exporttype_new()

wasm_exporttype_t * wasm_exporttype_new ( wasm_name_t name,
wasm_externtype_t  
)

Creates a new export type.

This function takes ownership of the name and wasm_externtype_t arguments. The caller is responsible for deleting the returned value.

◆ wasm_exporttype_type()

const wasm_externtype_t * wasm_exporttype_type ( const wasm_exporttype_t )

Returns the type of this export.

The returned memory is owned by the wasm_exporttype_t argument, the caller should not deallocate it.

◆ wasm_exporttype_vec_copy()

void wasm_exporttype_vec_copy ( wasm_exporttype_vec_t out,
const wasm_exporttype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_exporttype_vec_delete()

void wasm_exporttype_vec_delete ( wasm_exporttype_vec_t out)

Deallocates export for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_exporttype_vec_new()

void wasm_exporttype_vec_new ( wasm_exporttype_vec_t out,
size_t  ,
wasm_exporttype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_exporttype_vec_new_empty()

void wasm_exporttype_vec_new_empty ( wasm_exporttype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_exporttype_vec_new_uninitialized()

void wasm_exporttype_vec_new_uninitialized ( wasm_exporttype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_extern_as_func()

wasm_func_t * wasm_extern_as_func ( wasm_extern_t )

Converts a wasm_extern_t to wasm_func_t.

The returned wasm_func_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_func_t then NULL is returned.

◆ wasm_extern_as_func_const()

const wasm_func_t * wasm_extern_as_func_const ( const wasm_extern_t )

Converts a wasm_extern_t to wasm_func_t.

The returned wasm_func_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_func_t then NULL is returned.

◆ wasm_extern_as_global()

wasm_global_t * wasm_extern_as_global ( wasm_extern_t )

Converts a wasm_extern_t to wasm_global_t.

The returned wasm_global_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_global_t then NULL is returned.

◆ wasm_extern_as_global_const()

const wasm_global_t * wasm_extern_as_global_const ( const wasm_extern_t )

Converts a wasm_extern_t to wasm_global_t.

The returned wasm_global_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_global_t then NULL is returned.

◆ wasm_extern_as_memory()

wasm_memory_t * wasm_extern_as_memory ( wasm_extern_t )

Converts a wasm_extern_t to wasm_memory_t.

The returned wasm_memory_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_memory_t then NULL is returned.

◆ wasm_extern_as_memory_const()

const wasm_memory_t * wasm_extern_as_memory_const ( const wasm_extern_t )

Converts a wasm_extern_t to wasm_memory_t.

The returned wasm_memory_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_memory_t then NULL is returned.

◆ wasm_extern_as_table()

wasm_table_t * wasm_extern_as_table ( wasm_extern_t )

Converts a wasm_extern_t to wasm_table_t.

The returned wasm_table_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_table_t then NULL is returned.

◆ wasm_extern_as_table_const()

const wasm_table_t * wasm_extern_as_table_const ( const wasm_extern_t )

Converts a wasm_extern_t to wasm_table_t.

The returned wasm_table_t is owned by the wasm_extern_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_extern_t argument.

If the wasm_extern_t argument isn't a wasm_table_t then NULL is returned.

◆ wasm_extern_copy()

wasm_extern_t * wasm_extern_copy ( const wasm_extern_t )

Copies a wasm_extern_t to a new one.

The caller is responsible for deleting the returned wasm_extern_t.

◆ wasm_extern_type()

wasm_externtype_t * wasm_extern_type ( const wasm_extern_t )

Returns the type of this extern.

The caller is expected to deallocate the returned wasm_externtype_t.

◆ wasm_extern_vec_copy()

void wasm_extern_vec_copy ( wasm_extern_vec_t out,
const wasm_extern_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_extern_vec_delete()

void wasm_extern_vec_delete ( wasm_extern_vec_t out)

Deallocates import for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_extern_vec_new()

void wasm_extern_vec_new ( wasm_extern_vec_t out,
size_t  ,
wasm_extern_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_extern_vec_new_empty()

void wasm_extern_vec_new_empty ( wasm_extern_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_extern_vec_new_uninitialized()

void wasm_extern_vec_new_uninitialized ( wasm_extern_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_externtype_as_functype()

wasm_functype_t * wasm_externtype_as_functype ( wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_functype_t.

The returned value is owned by the wasm_functype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_functype_t.

◆ wasm_externtype_as_functype_const()

const wasm_functype_t * wasm_externtype_as_functype_const ( const wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_functype_t.

The returned value is owned by the wasm_functype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_functype_t.

◆ wasm_externtype_as_globaltype()

wasm_globaltype_t * wasm_externtype_as_globaltype ( wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_globaltype_t.

The returned value is owned by the wasm_globaltype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_globaltype_t.

◆ wasm_externtype_as_globaltype_const()

const wasm_globaltype_t * wasm_externtype_as_globaltype_const ( const wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_globaltype_t.

The returned value is owned by the wasm_globaltype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_globaltype_t.

◆ wasm_externtype_as_memorytype()

wasm_memorytype_t * wasm_externtype_as_memorytype ( wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_memorytype_t.

The returned value is owned by the wasm_memorytype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_memorytype_t.

◆ wasm_externtype_as_memorytype_const()

const wasm_memorytype_t * wasm_externtype_as_memorytype_const ( const wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_memorytype_t.

The returned value is owned by the wasm_memorytype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_memorytype_t.

◆ wasm_externtype_as_tabletype()

wasm_tabletype_t * wasm_externtype_as_tabletype ( wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_tabletype_t.

The returned value is owned by the wasm_tabletype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_tabletype_t.

◆ wasm_externtype_as_tabletype_const()

const wasm_tabletype_t * wasm_externtype_as_tabletype_const ( const wasm_externtype_t )

Attempts to convert a wasm_externtype_t to a wasm_tabletype_t.

The returned value is owned by the wasm_tabletype_t argument and should not be deleted. Returns NULL if the provided argument is not a wasm_tabletype_t.

◆ wasm_externtype_copy()

wasm_externtype_t * wasm_externtype_copy ( const wasm_externtype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_externtype_vec_copy()

void wasm_externtype_vec_copy ( wasm_externtype_vec_t out,
const wasm_externtype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_externtype_vec_delete()

void wasm_externtype_vec_delete ( wasm_externtype_vec_t out)

Deallocates extern for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_externtype_vec_new()

void wasm_externtype_vec_new ( wasm_externtype_vec_t out,
size_t  ,
wasm_externtype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_externtype_vec_new_empty()

void wasm_externtype_vec_new_empty ( wasm_externtype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_externtype_vec_new_uninitialized()

void wasm_externtype_vec_new_uninitialized ( wasm_externtype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_frame_copy()

wasm_frame_t * wasm_frame_copy ( const wasm_frame_t )

Returns a copy of the provided frame.

The caller is expected to call wasm_frame_delete on the returned frame.

◆ wasm_frame_vec_copy()

void wasm_frame_vec_copy ( wasm_frame_vec_t out,
const wasm_frame_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_frame_vec_delete()

void wasm_frame_vec_delete ( wasm_frame_vec_t out)

Deallocates export for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_frame_vec_new()

void wasm_frame_vec_new ( wasm_frame_vec_t out,
size_t  ,
wasm_frame_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_frame_vec_new_empty()

void wasm_frame_vec_new_empty ( wasm_frame_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_frame_vec_new_uninitialized()

void wasm_frame_vec_new_uninitialized ( wasm_frame_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_func_as_extern()

wasm_extern_t * wasm_func_as_extern ( wasm_func_t f)

Converts a wasm_func_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_func_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_func_t argument.

◆ wasm_func_as_extern_const()

const wasm_extern_t * wasm_func_as_extern_const ( const wasm_func_t f)

Converts a wasm_func_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_func_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_func_t argument.

◆ wasm_func_call()

wasm_trap_t * wasm_func_call ( const wasm_func_t ,
const wasm_val_vec_t args,
wasm_val_vec_t results 
)

Calls the provided function with the arguments given.

This function is used to call WebAssembly from the host. The parameter array provided must be valid for wasm_func_param_arity number of arguments, and the result array must be valid for wasm_func_result_arity number of results. Providing not enough space is undefined behavior.

If any of the arguments do not have the correct type then a trap is returned. Additionally if any of the arguments come from a different store than the wasm_func_t provided a trap is returned.

When no trap happens and no errors are detected then NULL is returned. The results array is guaranteed to be filled in with values appropriate for this function's type signature.

If a trap happens during execution or some other error then a non-NULL trap is returned. In this situation the results are is unmodified.

Does not take ownership of wasm_val_t arguments. Gives ownership of wasm_val_t results.

◆ wasm_func_copy()

wasm_func_t * wasm_func_copy ( const wasm_func_t )

Copies a wasm_func_t to a new one.

The caller is responsible for deleting the returned wasm_func_t.

◆ wasm_func_new()

wasm_func_t * wasm_func_new ( wasm_store_t ,
const wasm_functype_t ,
wasm_func_callback_t   
)

Creates a new WebAssembly function with host functionality.

This function creates a new wasm_func_t from a host-provided function. The host provided function must implement the type signature matching the wasm_functype_t provided here.

The returned wasm_func_t is expected to be deleted by the caller. This function does not take ownership of its arguments.

◆ wasm_func_new_with_env()

wasm_func_t * wasm_func_new_with_env ( wasm_store_t ,
const wasm_functype_t type,
wasm_func_callback_with_env_t  ,
void *  env,
void(*)(void *)  finalizer 
)

Creates a new WebAssembly function with host functionality.

This function is the same as wasm_func_new except that it the host-provided env argument is passed to each invocation of the callback provided. This provides a means of attaching host information to this wasm_func_t.

The finalizer argument will be invoked to deallocate env when the wasm_func_t is deallocated. If this argument is NULL then the data provided will not be finalized.

This function only takes ownership of the env argument (which is later deallocated automatically by calling finalizer). This function yields ownership of the returned wasm_func_t to the caller.

◆ wasm_func_type()

wasm_functype_t * wasm_func_type ( const wasm_func_t )

Returns the type of this function.

The returned wasm_functype_t is expected to be deallocated by the caller.

◆ wasm_functype_as_externtype()

wasm_externtype_t * wasm_functype_as_externtype ( wasm_functype_t )

Converts a wasm_functype_t to a wasm_externtype_t.

The returned value is owned by the wasm_functype_t argument and should not be deleted.

◆ wasm_functype_as_externtype_const()

const wasm_externtype_t * wasm_functype_as_externtype_const ( const wasm_functype_t )

Converts a wasm_functype_t to a wasm_externtype_t.

The returned value is owned by the wasm_functype_t argument and should not be deleted.

◆ wasm_functype_copy()

wasm_functype_t * wasm_functype_copy ( const wasm_functype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_functype_new()

wasm_functype_t * wasm_functype_new ( wasm_valtype_vec_t params,
wasm_valtype_vec_t results 
)

Creates a new function type with the provided parameter and result types.

This function takes ownership of the params and results arguments.

The caller is responsible for deleting the returned value.

◆ wasm_functype_params()

const wasm_valtype_vec_t * wasm_functype_params ( const wasm_functype_t )

Returns the list of parameters of this function type.

The returned memory is owned by the wasm_functype_t argument, the caller should not deallocate it.

◆ wasm_functype_results()

const wasm_valtype_vec_t * wasm_functype_results ( const wasm_functype_t )

Returns the list of results of this function type.

The returned memory is owned by the wasm_functype_t argument, the caller should not deallocate it.

◆ wasm_functype_vec_copy()

void wasm_functype_vec_copy ( wasm_functype_vec_t out,
const wasm_functype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_functype_vec_delete()

void wasm_functype_vec_delete ( wasm_functype_vec_t out)

Deallocates memory for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_functype_vec_new()

void wasm_functype_vec_new ( wasm_functype_vec_t out,
size_t  ,
wasm_functype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_functype_vec_new_empty()

void wasm_functype_vec_new_empty ( wasm_functype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_functype_vec_new_uninitialized()

void wasm_functype_vec_new_uninitialized ( wasm_functype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_global_as_extern()

wasm_extern_t * wasm_global_as_extern ( wasm_global_t f)

Converts a wasm_global_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_global_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_global_t argument.

◆ wasm_global_as_extern_const()

const wasm_extern_t * wasm_global_as_extern_const ( const wasm_global_t f)

Converts a wasm_global_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_global_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_global_t argument.

◆ wasm_global_copy()

wasm_global_t * wasm_global_copy ( const wasm_global_t )

Copies a wasm_global_t to a new one.

The caller is responsible for deleting the returned wasm_global_t.

◆ wasm_global_get()

void wasm_global_get ( const wasm_global_t ,
wasm_val_t out 
)

Gets the value of this global.

The caller is expected to deallocate the returned wasm_val_t. The provided out argument is treated as uninitialized on input.

◆ wasm_global_new()

wasm_global_t * wasm_global_new ( wasm_store_t ,
const wasm_globaltype_t ,
const wasm_val_t  
)

Creates a new WebAssembly global.

This function is used to create a wasm global from the host, typically to provide as the import of a module. The type of the global is specified along with the initial value.

This function will return NULL on errors. Errors include:

  • The type of the global doesn't match the type of the value specified.
  • The initialization value does not come from the provided wasm_store_t.

This function does not take ownership of any of its arguments. The caller is expected to deallocate the returned value.

◆ wasm_global_set()

void wasm_global_set ( wasm_global_t ,
const wasm_val_t  
)

Sets the value of this global.

This function will set the value of a global to a new value. This function does nothing if the global is not mutable, if the wasm_val_t argument has the wrong type, or if the provided value comes from a different store as the wasm_global_t.

This function does not take ownership of its arguments.

◆ wasm_global_type()

wasm_globaltype_t * wasm_global_type ( const wasm_global_t )

Returns the type of this global.

The caller is expected to deallocate the returned wasm_globaltype_t.

◆ wasm_globaltype_as_externtype()

wasm_externtype_t * wasm_globaltype_as_externtype ( wasm_globaltype_t )

Converts a wasm_globaltype_t to a wasm_externtype_t.

The returned value is owned by the wasm_globaltype_t argument and should not be deleted.

◆ wasm_globaltype_as_externtype_const()

const wasm_externtype_t * wasm_globaltype_as_externtype_const ( const wasm_globaltype_t )

Converts a wasm_globaltype_t to a wasm_externtype_t.

The returned value is owned by the wasm_globaltype_t argument and should not be deleted.

◆ wasm_globaltype_content()

const wasm_valtype_t * wasm_globaltype_content ( const wasm_globaltype_t )

Returns the type of value contained in a global.

The returned memory is owned by the provided wasm_globaltype_t, the caller should not deallocate it.

◆ wasm_globaltype_copy()

wasm_globaltype_t * wasm_globaltype_copy ( const wasm_globaltype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_globaltype_new()

wasm_globaltype_t * wasm_globaltype_new ( wasm_valtype_t ,
wasm_mutability_t   
)

Creates a new global type.

This function takes ownership of the wasm_valtype_t argument.

The caller is responsible for deleting the returned value.

◆ wasm_globaltype_vec_copy()

void wasm_globaltype_vec_copy ( wasm_globaltype_vec_t out,
const wasm_globaltype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_globaltype_vec_delete()

void wasm_globaltype_vec_delete ( wasm_globaltype_vec_t out)

Deallocates memory for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_globaltype_vec_new()

void wasm_globaltype_vec_new ( wasm_globaltype_vec_t out,
size_t  ,
wasm_globaltype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_globaltype_vec_new_empty()

void wasm_globaltype_vec_new_empty ( wasm_globaltype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_globaltype_vec_new_uninitialized()

void wasm_globaltype_vec_new_uninitialized ( wasm_globaltype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_importtype_copy()

wasm_importtype_t * wasm_importtype_copy ( const wasm_importtype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_importtype_module()

const wasm_name_t * wasm_importtype_module ( const wasm_importtype_t )

Returns the module this import is importing from.

The returned memory is owned by the wasm_importtype_t argument, the caller should not deallocate it.

◆ wasm_importtype_name()

const wasm_name_t * wasm_importtype_name ( const wasm_importtype_t )

Returns the name this import is importing from.

The returned memory is owned by the wasm_importtype_t argument, the caller should not deallocate it. Note that NULL can be returned which means that the import name is not provided. This is for imports with the module linking proposal that only have the module specified.

◆ wasm_importtype_new()

wasm_importtype_t * wasm_importtype_new ( wasm_name_t module,
wasm_name_t name,
wasm_externtype_t  
)

Creates a new import type.

This function takes ownership of the module, name, and wasm_externtype_t arguments. The caller is responsible for deleting the returned value. Note that name can be NULL where in the module linking proposal the import name can be omitted.

◆ wasm_importtype_type()

const wasm_externtype_t * wasm_importtype_type ( const wasm_importtype_t )

Returns the type of item this import is importing.

The returned memory is owned by the wasm_importtype_t argument, the caller should not deallocate it.

◆ wasm_importtype_vec_copy()

void wasm_importtype_vec_copy ( wasm_importtype_vec_t out,
const wasm_importtype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_importtype_vec_delete()

void wasm_importtype_vec_delete ( wasm_importtype_vec_t out)

Deallocates import for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_importtype_vec_new()

void wasm_importtype_vec_new ( wasm_importtype_vec_t out,
size_t  ,
wasm_importtype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_importtype_vec_new_empty()

void wasm_importtype_vec_new_empty ( wasm_importtype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_importtype_vec_new_uninitialized()

void wasm_importtype_vec_new_uninitialized ( wasm_importtype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_instance_copy()

wasm_instance_t * wasm_instance_copy ( const wasm_instance_t )

Copies a wasm_instance_t to a new one.

The caller is responsible for deleting the returned wasm_instance_t.

◆ wasm_instance_exports()

void wasm_instance_exports ( const wasm_instance_t ,
wasm_extern_vec_t out 
)

Returns the exports of an instance.

This function returns a list of wasm_extern_t values, which will be owned by the caller, which are exported from the instance. The out list will have the same length as wasm_module_exports called on the original module. Each element is 1:1 matched with the elements in the list of wasm_module_exports.

◆ wasm_instance_new()

wasm_instance_t * wasm_instance_new ( wasm_store_t ,
const wasm_module_t ,
const wasm_extern_vec_t imports,
wasm_trap_t **   
)

Instantiates a module with the provided imports.

This function will instantiate the provided wasm_module_t into the provided wasm_store_t. The imports specified are used to satisfy the imports of the wasm_module_t.

This function must provide exactly the same number of imports as returned by wasm_module_imports or this results in undefined behavior.

Imports provided are expected to be 1:1 matches against the list returned by wasm_module_imports.

Instantiation includes invoking the start function of a wasm module. If that function traps then a trap is returned through the wasm_trap_t type.

This function does not take ownership of any of its arguments, and the returned wasm_instance_t and wasm_trap_t are owned by the caller.

◆ wasm_memory_as_extern()

wasm_extern_t * wasm_memory_as_extern ( wasm_memory_t f)

Converts a wasm_memory_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_memory_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_memory_t argument.

◆ wasm_memory_as_extern_const()

const wasm_extern_t * wasm_memory_as_extern_const ( const wasm_memory_t f)

Converts a wasm_memory_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_memory_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_memory_t argument.

◆ wasm_memory_copy()

wasm_memory_t * wasm_memory_copy ( const wasm_memory_t )

Copies a wasm_memory_t to a new one.

The caller is responsible for deleting the returned wasm_memory_t.

◆ wasm_memory_data()

byte_t * wasm_memory_data ( wasm_memory_t )

Returns the base address, in memory, where this memory is located.

Note that the returned address may change over time when growth happens. The returned pointer is only valid until the memory is next grown (which could happen in wasm itself).

◆ wasm_memory_grow()

bool wasm_memory_grow ( wasm_memory_t ,
wasm_memory_pages_t  delta 
)

Attempts to grow this memory by delta wasm pages.

This function is similar to the memory.grow instruction in wasm itself. It will attempt to grow the memory by delta wasm pages. If growth fails then false is returned, otherwise true is returned.

◆ wasm_memory_type()

wasm_memorytype_t * wasm_memory_type ( const wasm_memory_t )

Returns the type of this memory.

The caller is expected to deallocate the returned wasm_memorytype_t.

◆ wasm_memorytype_as_externtype()

wasm_externtype_t * wasm_memorytype_as_externtype ( wasm_memorytype_t )

Converts a wasm_memorytype_t to a wasm_externtype_t.

The returned value is owned by the wasm_memorytype_t argument and should not be deleted.

◆ wasm_memorytype_as_externtype_const()

const wasm_externtype_t * wasm_memorytype_as_externtype_const ( const wasm_memorytype_t )

Converts a wasm_memorytype_t to a wasm_externtype_t.

The returned value is owned by the wasm_memorytype_t argument and should not be deleted.

◆ wasm_memorytype_copy()

wasm_memorytype_t * wasm_memorytype_copy ( const wasm_memorytype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_memorytype_limits()

const wasm_limits_t * wasm_memorytype_limits ( const wasm_memorytype_t )

Returns the limits of this memory.

The returned wasm_limits_t is owned by the wasm_memorytype_t parameter, the caller should not deallocate it.

For compatibility with memory64 it's recommended to use wasmtime_memorytype_maximum or wasmtime_memorytype_minimum instead.

◆ wasm_memorytype_new()

wasm_memorytype_t * wasm_memorytype_new ( const wasm_limits_t )

Creates a new memory type.

This function takes ownership of the wasm_valtype_t argument, but does not take ownership of the wasm_limits_t.

The caller is responsible for deallocating the returned type.

For compatibility with memory64 it's recommended to use wasmtime_memorytype_new instead.

◆ wasm_memorytype_vec_copy()

void wasm_memorytype_vec_copy ( wasm_memorytype_vec_t out,
const wasm_memorytype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_memorytype_vec_delete()

void wasm_memorytype_vec_delete ( wasm_memorytype_vec_t out)

Deallocates memory for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_memorytype_vec_new()

void wasm_memorytype_vec_new ( wasm_memorytype_vec_t out,
size_t  ,
wasm_memorytype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_memorytype_vec_new_empty()

void wasm_memorytype_vec_new_empty ( wasm_memorytype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_memorytype_vec_new_uninitialized()

void wasm_memorytype_vec_new_uninitialized ( wasm_memorytype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_module_copy()

wasm_module_t * wasm_module_copy ( const wasm_module_t )

Copies a wasm_module_t to a new one.

The caller is responsible for deleting the returned wasm_module_t.

◆ wasm_module_deserialize()

wasm_module_t * wasm_module_deserialize ( wasm_store_t ,
const wasm_byte_vec_t  
)

Deserializes a previously-serialized module.

The input bytes must have been created from a previous call to wasm_module_serialize.

◆ wasm_module_exports()

void wasm_module_exports ( const wasm_module_t ,
wasm_exporttype_vec_t out 
)

Returns the list of exports that this module provides.

The list of exports returned are in the same order as the items returned by wasm_instance_exports.

This function does not take ownership of the provided module but ownership of out is passed to the caller. Note that out is treated as uninitialized when passed to this function.

◆ wasm_module_imports()

void wasm_module_imports ( const wasm_module_t ,
wasm_importtype_vec_t out 
)

Returns the list of imports that this module expects.

The list of imports returned are the types of items expected to be passed to wasm_instance_new. You can use wasm_importtype_type to learn about the expected type of each import.

This function does not take ownership of the provided module but ownership of out is passed to the caller. Note that out is treated as uninitialized when passed to this function.

◆ wasm_module_new()

wasm_module_t * wasm_module_new ( wasm_store_t ,
const wasm_byte_vec_t binary 
)

Compiles a raw WebAssembly binary to a wasm_module_t.

This function will validate and compile the provided binary. The returned wasm_module_t is ready for instantiation after this call returns.

This function does not take ownership of its arguments, but the caller is expected to deallocate the returned wasm_module_t.

This function may fail if the provided binary is not a WebAssembly binary or if it does not pass validation. In these cases this function returns NULL.

◆ wasm_module_obtain()

wasm_module_t * wasm_module_obtain ( wasm_store_t ,
const wasm_shared_module_t  
)

Attempts to create a wasm_module_t from the shareable module.

‍Note that this API is not necessary in Wasmtime because wasm_module_t can be shared across threads. This is implemented for compatibility, however.

This function does not take ownership of its arguments, but the caller is expected to deallocate the returned wasm_module_t.

This function may fail if the engines associated with the wasm_store_t or wasm_shared_module_t are different.

◆ wasm_module_serialize()

void wasm_module_serialize ( const wasm_module_t ,
wasm_byte_vec_t out 
)

Serializes the provided module to a byte vector.

Does not take ownership of the input module but expects the caller will deallocate the out vector. The byte vector can later be deserialized through wasm_module_deserialize.

◆ wasm_module_share()

wasm_shared_module_t * wasm_module_share ( const wasm_module_t )

Creates a shareable module from the provided module.

‍Note that this API is not necessary in Wasmtime because wasm_module_t can be shared across threads. This is implemented for compatibility, however.

This function does not take ownership of the argument, but the caller is expected to deallocate the returned wasm_shared_module_t.

◆ wasm_module_validate()

bool wasm_module_validate ( wasm_store_t ,
const wasm_byte_vec_t binary 
)

Validates whether a provided byte sequence is a valid wasm binary.

This function will perform any internal validation necessary to determine if binary is a valid WebAssembly binary according to the configuration of the wasm_store_t provided.

◆ wasm_ref_same()

bool wasm_ref_same ( const wasm_ref_t ,
const wasm_ref_t  
)

Are the given references pointing to the same externref?

‍Note: Wasmtime does not support checking funcrefs for equality, and this function will always return false for funcrefs.

◆ wasm_store_new()

wasm_store_t * wasm_store_new ( wasm_engine_t )

Creates a new store within the specified engine.

The object returned is owned by the caller and will need to be deleted with wasm_store_delete. This may return NULL if the store could not be allocated.

◆ wasm_table_as_extern()

wasm_extern_t * wasm_table_as_extern ( wasm_table_t f)

Converts a wasm_table_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_table_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_table_t argument.

◆ wasm_table_as_extern_const()

const wasm_extern_t * wasm_table_as_extern_const ( const wasm_table_t f)

Converts a wasm_table_t to wasm_extern_t.

The returned wasm_extern_t is owned by the wasm_table_t argument. Callers should not delete the returned value, and it only lives as long as the wasm_table_t argument.

◆ wasm_table_copy()

wasm_table_t * wasm_table_copy ( const wasm_table_t )

Copies a wasm_table_t to a new one.

The caller is responsible for deleting the returned wasm_table_t.

◆ wasm_table_get()

wasm_ref_t * wasm_table_get ( const wasm_table_t ,
wasm_table_size_t  index 
)

Gets an element from this table.

Attempts to get a value at an index in this table. This function returns NULL if the index is out of bounds.

Gives ownership of the resulting wasm_ref_t*.

◆ wasm_table_grow()

bool wasm_table_grow ( wasm_table_t ,
wasm_table_size_t  delta,
wasm_ref_t init 
)

Attempts to grow this table by delta elements.

This function will grow the table by delta elements, initializing all new elements to the init value provided.

If growth happens successfully, then true is returned. Otherwise false is returned and indicates one possible form of failure:

  • The table's limits do not allow growth by delta.
  • The wasm_ref_t comes from a different store than the table provided.
  • The wasm_ref_t does not have an appropriate type to store in this table.

Does not take ownership of the given init value.

◆ wasm_table_new()

wasm_table_t * wasm_table_new ( wasm_store_t ,
const wasm_tabletype_t ,
wasm_ref_t init 
)

Creates a new WebAssembly table.

Creates a new host-defined table of values. This table has the type provided and is filled with the provided initial value (which can be NULL).

Returns an error if the wasm_ref_t does not match the element type of the table provided or if it comes from a different store than the one provided.

Does not take ownship of the init value.

◆ wasm_table_set()

void wasm_table_set ( wasm_table_t ,
wasm_table_size_t  index,
wasm_ref_t  
)

Sets an element in this table.

Attempts to set a value at an index in this table. This function does nothing in erroneous situations such as:

  • The index is out of bounds.
  • The wasm_ref_t comes from a different store than the table provided.
  • The wasm_ref_t does not have an appropriate type to store in this table.

Does not take ownership of the given wasm_ref_t*.

◆ wasm_table_type()

wasm_tabletype_t * wasm_table_type ( const wasm_table_t )

Returns the type of this table.

The caller is expected to deallocate the returned wasm_tabletype_t.

◆ wasm_tabletype_as_externtype()

wasm_externtype_t * wasm_tabletype_as_externtype ( wasm_tabletype_t )

Converts a wasm_tabletype_t to a wasm_externtype_t.

The returned value is owned by the wasm_tabletype_t argument and should not be deleted.

◆ wasm_tabletype_as_externtype_const()

const wasm_externtype_t * wasm_tabletype_as_externtype_const ( const wasm_tabletype_t )

Converts a wasm_tabletype_t to a wasm_externtype_t.

The returned value is owned by the wasm_tabletype_t argument and should not be deleted.

◆ wasm_tabletype_copy()

wasm_tabletype_t * wasm_tabletype_copy ( const wasm_tabletype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_tabletype_element()

const wasm_valtype_t * wasm_tabletype_element ( const wasm_tabletype_t )

Returns the element type of this table.

The returned wasm_valtype_t is owned by the wasm_tabletype_t parameter, the caller should not deallocate it.

◆ wasm_tabletype_limits()

const wasm_limits_t * wasm_tabletype_limits ( const wasm_tabletype_t )

Returns the limits of this table.

The returned wasm_limits_t is owned by the wasm_tabletype_t parameter, the caller should not deallocate it.

◆ wasm_tabletype_new()

wasm_tabletype_t * wasm_tabletype_new ( wasm_valtype_t ,
const wasm_limits_t  
)

Creates a new table type.

This function takes ownership of the wasm_valtype_t argument, but does not take ownership of the wasm_limits_t.

The caller is responsible for deallocating the returned type.

◆ wasm_tabletype_vec_copy()

void wasm_tabletype_vec_copy ( wasm_tabletype_vec_t out,
const wasm_tabletype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_tabletype_vec_delete()

void wasm_tabletype_vec_delete ( wasm_tabletype_vec_t out)

Deallocates memory for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_tabletype_vec_new()

void wasm_tabletype_vec_new ( wasm_tabletype_vec_t out,
size_t  ,
wasm_tabletype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_tabletype_vec_new_empty()

void wasm_tabletype_vec_new_empty ( wasm_tabletype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_tabletype_vec_new_uninitialized()

void wasm_tabletype_vec_new_uninitialized ( wasm_tabletype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_trap_copy()

wasm_trap_t * wasm_trap_copy ( const wasm_trap_t )

Copies a wasm_trap_t to a new one.

The caller is responsible for deleting the returned wasm_trap_t.

◆ wasm_trap_message()

void wasm_trap_message ( const wasm_trap_t ,
wasm_message_t out 
)

Retrieves the message associated with this trap.

The caller takes ownership of the returned out value and is responsible for calling wasm_byte_vec_delete on it.

◆ wasm_trap_new()

wasm_trap_t * wasm_trap_new ( wasm_store_t store,
const wasm_message_t  
)

Creates a new wasm_trap_t with the provided message.

This function will create a new trap within the given wasm_store_t with the provided message. This will also capture the backtrace, if any, of wasm frames on the stack.

Note that the wasm_message_t argument is expected to have a 0-byte at the end of the message, and the length should include the trailing 0-byte.

This function does not take ownership of either argument.

The caller is responsible for deallocating the trap returned.

◆ wasm_trap_origin()

wasm_frame_t * wasm_trap_origin ( const wasm_trap_t )

Returns the top frame of the wasm stack responsible for this trap.

The caller is responsible for deallocating the returned frame. This function may return NULL, for example, for traps created when there wasn't anything on the wasm stack.

◆ wasm_trap_trace()

void wasm_trap_trace ( const wasm_trap_t ,
wasm_frame_vec_t out 
)

Returns the trace of wasm frames for this trap.

The caller is responsible for deallocating the returned list of frames. Frames are listed in order of increasing depth, with the most recently called function at the front of the list and the base function on the stack at the end.

◆ wasm_val_copy()

void wasm_val_copy ( wasm_val_t out,
const wasm_val_t  
)

Copies a wasm_val_t to a new one.

The second argument to this function is copied to the first. The caller is responsible for calling wasm_val_delete on the first argument after this function. The out parameter is assumed uninitialized by this function and the previous contents will not be deallocated.

◆ wasm_val_delete()

void wasm_val_delete ( wasm_val_t v)

Deletes a type.

This does not delete the memory pointed to by v, so it's safe for v to reside on the stack. Instead this only deletes the memory referenced by v, such as the ref variant of wasm_val_t.

◆ wasm_val_vec_copy()

void wasm_val_vec_copy ( wasm_val_vec_t out,
const wasm_val_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_val_vec_delete()

void wasm_val_vec_delete ( wasm_val_vec_t out)

Deallocates export for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_val_vec_new()

void wasm_val_vec_new ( wasm_val_vec_t out,
size_t  ,
wasm_val_t const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_val_vec_new_empty()

void wasm_val_vec_new_empty ( wasm_val_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_val_vec_new_uninitialized()

void wasm_val_vec_new_uninitialized ( wasm_val_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.

◆ wasm_valtype_copy()

wasm_valtype_t * wasm_valtype_copy ( const wasm_valtype_t )

Creates a new value which matches the provided one.

The caller is responsible for deleting the returned value.

◆ wasm_valtype_new()

wasm_valtype_t * wasm_valtype_new ( wasm_valkind_t  )

Creates a new value type from the specified kind.

The caller is responsible for deleting the returned value.

◆ wasm_valtype_vec_copy()

void wasm_valtype_vec_copy ( wasm_valtype_vec_t out,
const wasm_valtype_vec_t  
)

Copies one vector to another.

See wasm_byte_vec_copy for more information.

◆ wasm_valtype_vec_delete()

void wasm_valtype_vec_delete ( wasm_valtype_vec_t out)

Deallocates memory for a vector.

See wasm_byte_vec_delete for more information.

◆ wasm_valtype_vec_new()

void wasm_valtype_vec_new ( wasm_valtype_vec_t out,
size_t  ,
wasm_valtype_t * const  [] 
)

Creates a vector with the provided contents.

See wasm_byte_vec_new for more information.

◆ wasm_valtype_vec_new_empty()

void wasm_valtype_vec_new_empty ( wasm_valtype_vec_t out)

Creates an empty vector.

See wasm_byte_vec_new_empty for more information.

◆ wasm_valtype_vec_new_uninitialized()

void wasm_valtype_vec_new_uninitialized ( wasm_valtype_vec_t out,
size_t   
)

Creates a vector with the given capacity.

See wasm_byte_vec_new_uninitialized for more information.