Wasmtime
global.h File Reference
#include <wasm.h>
#include <wasmtime/extern.h>
#include <wasmtime/store.h>
#include <wasmtime/val.h>

Go to the source code of this file.

Functions

wasmtime_error_twasmtime_global_new (wasmtime_context_t *store, const wasm_globaltype_t *type, const wasmtime_val_t *val, wasmtime_global_t *ret)
 Creates a new global value. More...
 
wasm_globaltype_twasmtime_global_type (const wasmtime_context_t *store, const wasmtime_global_t *global)
 Returns the wasm type of the specified global. More...
 
void wasmtime_global_get (wasmtime_context_t *store, const wasmtime_global_t *global, wasmtime_val_t *out)
 Get the value of the specified global. More...
 
wasmtime_error_twasmtime_global_set (wasmtime_context_t *store, const wasmtime_global_t *global, const wasmtime_val_t *val)
 Sets a global to a new value. More...
 

Detailed Description

Wasmtime APIs for interacting with WebAssembly globals.

Function Documentation

◆ wasmtime_global_get()

void wasmtime_global_get ( wasmtime_context_t store,
const wasmtime_global_t global,
wasmtime_val_t out 
)

Get the value of the specified global.

Parameters
storethe store that owns global
globalthe global to get
outwhere to store the value in this global.

This function returns ownership of the contents of out, so wasmtime_val_delete may need to be called on the value.

◆ wasmtime_global_new()

wasmtime_error_t * wasmtime_global_new ( wasmtime_context_t store,
const wasm_globaltype_t type,
const wasmtime_val_t val,
wasmtime_global_t ret 
)

Creates a new global value.

Creates a new host-defined global value within the provided store

Parameters
storethe store in which to create the global
typethe wasm type of the global being created
valthe initial value of the global
reta return pointer for the created global.

This function may return an error if the val argument does not match the specified type of the global, or if val comes from a different store than the one provided.

This function does not take ownership of any of its arguments but error is owned by the caller.

◆ wasmtime_global_set()

wasmtime_error_t * wasmtime_global_set ( wasmtime_context_t store,
const wasmtime_global_t global,
const wasmtime_val_t val 
)

Sets a global to a new value.

Parameters
storethe store that owns global
globalthe global to set
valthe value to store in the global

This function may return an error if global is not mutable or if val has the wrong type for global.

THis does not take ownership of any argument but returns ownership of the error.

◆ wasmtime_global_type()

wasm_globaltype_t * wasmtime_global_type ( const wasmtime_context_t store,
const wasmtime_global_t global 
)

Returns the wasm type of the specified global.

The returned wasm_globaltype_t is owned by the caller.