Wasmtime
structref.h
Go to the documentation of this file.
1
7#ifndef WASMTIME_STRUCTREF_H
8#define WASMTIME_STRUCTREF_H
9
10#include <wasmtime/conf.h>
11
12#ifdef WASMTIME_FEATURE_GC
13
15#include <wasmtime/val.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
30typedef struct wasmtime_struct_ref_pre wasmtime_struct_ref_pre_t;
31
40WASM_API_EXTERN wasmtime_struct_ref_pre_t *
42 const wasmtime_struct_type_t *ty);
43
47WASM_API_EXTERN void
49
51static inline void wasmtime_structref_set_null(wasmtime_structref_t *ref) {
52 ref->store_id = 0;
53}
54
56static inline bool wasmtime_structref_is_null(const wasmtime_structref_t *ref) {
57 return ref->store_id == 0;
58}
59
73 const wasmtime_val_t *fields, size_t nfields, wasmtime_structref_t *out);
74
78WASM_API_EXTERN void
81
86
90WASM_API_EXTERN void
93
97WASM_API_EXTERN void
99 wasmtime_eqref_t *out);
100
111WASM_API_EXTERN wasmtime_error_t *
113 const wasmtime_structref_t *structref, size_t index,
114 wasmtime_val_t *out);
115
127WASM_API_EXTERN wasmtime_error_t *
129 const wasmtime_structref_t *structref,
130 size_t index, const wasmtime_val_t *val);
131
132#ifdef __cplusplus
133} // extern "C"
134#endif
135
136#endif // WASMTIME_FEATURE_GC
137
138#endif // WASMTIME_STRUCTREF_H
Build-time defines for how the C API was built.
WASM_API_EXTERN wasmtime_error_t * wasmtime_structref_set_field(wasmtime_context_t *context, const wasmtime_structref_t *structref, size_t index, const wasmtime_val_t *val)
Set a field of a struct.
WASM_API_EXTERN void wasmtime_structref_clone(const wasmtime_structref_t *structref, wasmtime_structref_t *out)
Clone a structref, creating a new root.
WASM_API_EXTERN void wasmtime_structref_unroot(wasmtime_structref_t *ref)
Unroot a structref to allow garbage collection.
WASM_API_EXTERN void wasmtime_structref_to_eqref(const wasmtime_structref_t *structref, wasmtime_eqref_t *out)
Upcast a structref to an eqref.
struct wasmtime_struct_ref_pre wasmtime_struct_ref_pre_t
An opaque, pre-allocated, and registered struct layout for faster allocation.
Definition: structref.h:30
WASM_API_EXTERN wasmtime_error_t * wasmtime_structref_field(wasmtime_context_t *context, const wasmtime_structref_t *structref, size_t index, wasmtime_val_t *out)
Read a field from a struct.
WASM_API_EXTERN void wasmtime_struct_ref_pre_delete(wasmtime_struct_ref_pre_t *pre)
Delete a struct pre-allocator.
WASM_API_EXTERN wasmtime_error_t * wasmtime_structref_new(wasmtime_context_t *context, const wasmtime_struct_ref_pre_t *pre, const wasmtime_val_t *fields, size_t nfields, wasmtime_structref_t *out)
Allocate a new struct instance.
WASM_API_EXTERN void wasmtime_structref_to_anyref(const wasmtime_structref_t *structref, wasmtime_anyref_t *out)
Upcast a structref to an anyref.
WASM_API_EXTERN wasmtime_struct_ref_pre_t * wasmtime_struct_ref_pre_new(wasmtime_context_t *context, const wasmtime_struct_type_t *ty)
Create a new struct pre-allocator.
A WebAssembly value in the any hierarchy of GC types.
Definition: val.h:77
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
A WebAssembly eqref value.
Definition: val.h:163
Errors generated by Wasmtime.
A WebAssembly structref value.
Definition: val.h:187
uint64_t store_id
Internal metadata.
Definition: val.h:189
Container for different kinds of wasm values.
Definition: val.h:376
struct wasmtime_struct_type wasmtime_struct_type_t
An opaque handle to a WebAssembly struct type definition.
Definition: types/structref.h:58