Wasmtime
types/structref.h File Reference
#include <wasm.h>

Go to the source code of this file.

Data Structures

struct  wasmtime_storage_type
 A storage type descriptor for struct/array fields. More...
 
struct  wasmtime_field_type
 Describes the type and mutability of a struct field or array element. More...
 

Macros

#define WASMTIME_STORAGE_TYPE_KIND_I8   0
 An 8-bit packed integer.
 
#define WASMTIME_STORAGE_TYPE_KIND_I16   1
 A 16-bit packed integer.
 
#define WASMTIME_STORAGE_TYPE_KIND_VALTYPE   2
 A regular value type (i32, f64, funcref, etc).
 

Typedefs

typedef uint8_t wasmtime_storage_type_kind_t
 Discriminant for storage types in struct/array field types.
 
typedef struct wasmtime_storage_type wasmtime_storage_type_t
 A storage type descriptor for struct/array fields.
 
typedef struct wasmtime_field_type wasmtime_field_type_t
 Convenience alias for wasmtime_field_type.
 
typedef struct wasmtime_struct_type wasmtime_struct_type_t
 An opaque handle to a WebAssembly struct type definition. More...
 

Functions

WASM_API_EXTERN void wasmtime_storage_type_clone (const wasmtime_storage_type_t *storage, wasmtime_storage_type_t *out)
 Clone a storage type into out.
 
WASM_API_EXTERN void wasmtime_storage_type_delete (wasmtime_storage_type_t *storage)
 Delete a storage type. More...
 
WASM_API_EXTERN void wasmtime_field_type_clone (const wasmtime_field_type_t *field, wasmtime_field_type_t *out)
 Clone a field type into out.
 
WASM_API_EXTERN void wasmtime_field_type_delete (wasmtime_field_type_t *field)
 Delete a field type.
 
WASM_API_EXTERN wasmtime_struct_type_twasmtime_struct_type_new (const wasm_engine_t *engine, const wasmtime_field_type_t *fields, size_t nfields)
 Create a new struct type. More...
 
WASM_API_EXTERN wasmtime_struct_type_twasmtime_struct_type_copy (const wasmtime_struct_type_t *ty)
 Clone a struct type.
 
WASM_API_EXTERN void wasmtime_struct_type_delete (wasmtime_struct_type_t *ty)
 Delete a struct type.
 
WASM_API_EXTERN size_t wasmtime_struct_type_num_fields (const wasmtime_struct_type_t *ty)
 Get the number of fields in a struct type.
 
WASM_API_EXTERN bool wasmtime_struct_type_field (const wasmtime_struct_type_t *ty, size_t index, wasmtime_field_type_t *out)
 Get the field type of a struct type's field by index. More...
 

Detailed Description

APIs for interacting with WebAssembly GC structref type in Wasmtime.

Typedef Documentation

◆ wasmtime_struct_type_t

typedef struct wasmtime_struct_type wasmtime_struct_type_t

An opaque handle to a WebAssembly struct type definition.

A struct type describes the fields of a struct. It is used to create a wasmtime_struct_ref_pre_t, which can then allocate struct instances.

Owned. Must be deleted with wasmtime_struct_type_delete.

Function Documentation

◆ wasmtime_storage_type_delete()

WASM_API_EXTERN void wasmtime_storage_type_delete ( wasmtime_storage_type_t storage)

Delete a storage type.

Only necessary for WASMTIME_STORAGE_TYPE_KIND_VALTYPE when the value type is a concrete reference type.

◆ wasmtime_struct_type_field()

WASM_API_EXTERN bool wasmtime_struct_type_field ( const wasmtime_struct_type_t ty,
size_t  index,
wasmtime_field_type_t out 
)

Get the field type of a struct type's field by index.

Returns true if index is in-bounds and out is filled in. Returns false if index is out-of-bounds and out is not modified.

◆ wasmtime_struct_type_new()

WASM_API_EXTERN wasmtime_struct_type_t * wasmtime_struct_type_new ( const wasm_engine_t engine,
const wasmtime_field_type_t fields,
size_t  nfields 
)

Create a new struct type.

Parameters
engineThe engine to register the type with.
fieldsPointer to an array of field type descriptors.
nfieldsNumber of fields.
Returns
Returns a new struct type, or NULL on error (e.g. invalid field types).