Wasmtime
eqref.h File Reference
#include <wasmtime/conf.h>
#include <wasmtime/val.h>

Go to the source code of this file.

Functions

WASM_API_EXTERN void wasmtime_eqref_clone (const wasmtime_eqref_t *eqref, wasmtime_eqref_t *out)
 Clone an eqref, creating a new root. More...
 
WASM_API_EXTERN void wasmtime_eqref_unroot (wasmtime_eqref_t *ref)
 Unroot an eqref to allow garbage collection. More...
 
WASM_API_EXTERN void wasmtime_eqref_to_anyref (const wasmtime_eqref_t *eqref, wasmtime_anyref_t *out)
 Upcast an eqref to an anyref. More...
 
WASM_API_EXTERN void wasmtime_eqref_from_i31 (wasmtime_context_t *context, uint32_t i31val, wasmtime_eqref_t *out)
 Create a new i31ref value. More...
 
WASM_API_EXTERN bool wasmtime_eqref_is_i31 (wasmtime_context_t *context, const wasmtime_eqref_t *eqref)
 Test whether this eqref is an i31ref. More...
 
WASM_API_EXTERN bool wasmtime_eqref_i31_get_u (wasmtime_context_t *context, const wasmtime_eqref_t *eqref, uint32_t *dst)
 Get the eqref's underlying i31ref value, zero extended. More...
 
WASM_API_EXTERN bool wasmtime_eqref_i31_get_s (wasmtime_context_t *context, const wasmtime_eqref_t *eqref, int32_t *dst)
 Get the eqref's underlying i31ref value, sign extended. More...
 
WASM_API_EXTERN bool wasmtime_eqref_is_array (wasmtime_context_t *context, const wasmtime_eqref_t *eqref)
 Test whether an eqref is an arrayref. More...
 
WASM_API_EXTERN bool wasmtime_eqref_as_array (wasmtime_context_t *context, const wasmtime_eqref_t *eqref, wasmtime_arrayref_t *out)
 Downcast an eqref to an arrayref. More...
 
WASM_API_EXTERN bool wasmtime_eqref_is_struct (wasmtime_context_t *context, const wasmtime_eqref_t *eqref)
 Test whether an eqref is a structref. More...
 
WASM_API_EXTERN bool wasmtime_eqref_as_struct (wasmtime_context_t *context, const wasmtime_eqref_t *eqref, wasmtime_structref_t *out)
 Downcast an eqref to a structref. More...
 

Detailed Description

APIs for interacting with WebAssembly eqref type in Wasmtime.

Function Documentation

◆ wasmtime_eqref_as_array()

WASM_API_EXTERN bool wasmtime_eqref_as_array ( wasmtime_context_t context,
const wasmtime_eqref_t eqref,
wasmtime_arrayref_t out 
)

Downcast an eqref to an arrayref.

If the given eqref is an arrayref, a new root for it is stored in out and true is returned. Otherwise false is returned and out is set to null.

◆ wasmtime_eqref_as_struct()

WASM_API_EXTERN bool wasmtime_eqref_as_struct ( wasmtime_context_t context,
const wasmtime_eqref_t eqref,
wasmtime_structref_t out 
)

Downcast an eqref to a structref.

If the given eqref is a structref, a new root for it is stored in out and true is returned. Otherwise false is returned and out is set to null.

◆ wasmtime_eqref_clone()

WASM_API_EXTERN void wasmtime_eqref_clone ( const wasmtime_eqref_t eqref,
wasmtime_eqref_t out 
)

Clone an eqref, creating a new root.

The cloned reference is stored in out.

◆ wasmtime_eqref_from_i31()

WASM_API_EXTERN void wasmtime_eqref_from_i31 ( wasmtime_context_t context,
uint32_t  i31val,
wasmtime_eqref_t out 
)

Create a new i31ref value.

Creates a new i31ref value (which is a subtype of eqref) and returns a pointer to it.

If i31val does not fit in 31 bits, it is wrapped.

◆ wasmtime_eqref_i31_get_s()

WASM_API_EXTERN bool wasmtime_eqref_i31_get_s ( wasmtime_context_t context,
const wasmtime_eqref_t eqref,
int32_t *  dst 
)

Get the eqref's underlying i31ref value, sign extended.

If the given eqref is an instance of i31ref, then its value is sign extended to 32 bits, written to dst, and true is returned.

If the given eqref is not an instance of i31ref, then false is returned and dst is left unmodified.

◆ wasmtime_eqref_i31_get_u()

WASM_API_EXTERN bool wasmtime_eqref_i31_get_u ( wasmtime_context_t context,
const wasmtime_eqref_t eqref,
uint32_t *  dst 
)

Get the eqref's underlying i31ref value, zero extended.

If the given eqref is an instance of i31ref, then its value is zero extended to 32 bits, written to dst, and true is returned.

If the given eqref is not an instance of i31ref, then false is returned and dst is left unmodified.

◆ wasmtime_eqref_is_array()

WASM_API_EXTERN bool wasmtime_eqref_is_array ( wasmtime_context_t context,
const wasmtime_eqref_t eqref 
)

Test whether an eqref is an arrayref.

Returns false for null references.

◆ wasmtime_eqref_is_i31()

WASM_API_EXTERN bool wasmtime_eqref_is_i31 ( wasmtime_context_t context,
const wasmtime_eqref_t eqref 
)

Test whether this eqref is an i31ref.

Returns true if the given eqref is an i31ref, false otherwise. Returns false for null references.

◆ wasmtime_eqref_is_struct()

WASM_API_EXTERN bool wasmtime_eqref_is_struct ( wasmtime_context_t context,
const wasmtime_eqref_t eqref 
)

Test whether an eqref is a structref.

Returns false for null references.

◆ wasmtime_eqref_to_anyref()

WASM_API_EXTERN void wasmtime_eqref_to_anyref ( const wasmtime_eqref_t eqref,
wasmtime_anyref_t out 
)

Upcast an eqref to an anyref.

The original eqref is not consumed; out receives a new cloned root pointing to the same GC object as anyref.

◆ wasmtime_eqref_unroot()

WASM_API_EXTERN void wasmtime_eqref_unroot ( wasmtime_eqref_t ref)

Unroot an eqref to allow garbage collection.

After calling this, ref is left in an undefined state and should not be used again.