Wasmtime
_structref_class.hh
1#ifndef WASMTIME_STRUCTREF_CLASS_HH
2#define WASMTIME_STRUCTREF_CLASS_HH
3
4#include <wasmtime/conf.h>
5
6#ifdef WASMTIME_FEATURE_GC
7
8#include <wasmtime/_anyref_class.hh>
9#include <wasmtime/_eqref_class.hh>
10#include <wasmtime/_store_class.hh>
11#include <wasmtime/helpers.hh>
12#include <wasmtime/structref.h>
14
15namespace wasmtime {
16
17class Val;
18
26 WASMTIME_OWN_WRAPPER(StructRefPre, wasmtime_struct_ref_pre)
27
28
29 static StructRefPre create(Store::Context cx, const StructType &ty) {
30 return StructRefPre(wasmtime_struct_ref_pre_new(cx.capi(), ty.capi()));
31 }
32};
33
40class StructRef {
41 WASMTIME_REF_WRAPPER(StructRef, wasmtime_structref);
42
44 static Result<StructRef> create(Store::Context cx, const StructRefPre &pre,
45 const std::vector<Val> &fields);
46
48 Result<Val> field(Store::Context cx, size_t index) const;
49
51 Result<std::monostate> set_field(Store::Context cx, size_t index,
52 const Val &value) const;
53
55 AnyRef to_anyref() const;
56
58 EqRef to_eqref() const;
59};
60
61} // namespace wasmtime
62
63#endif // WASMTIME_FEATURE_GC
64
65#endif // WASMTIME_STRUCTREF_CLASS_HH
Representation of a WebAssembly anyref value.
Definition: _anyref_class.hh:21
Representation of a WebAssembly eqref value.
Definition: _eqref_class.hh:28
Fallible result type used for Wasmtime.
Definition: error.hh:70
An interior pointer into a Store.
Definition: _store_class.hh:65
const wasmtime_context_t * capi() const
Returns the underlying C API pointer.
Definition: _store_class.hh:183
Pre-allocated struct layout for fast allocation of struct instances.
Definition: _structref_class.hh:25
Representation of a WebAssembly structref value.
Definition: _structref_class.hh:40
Owned handle to a WebAssembly struct type definition.
Definition: types/_structref_class.hh:144
Representation of a generic WebAssembly value.
Definition: _val_class.hh:53
Build-time defines for how the C API was built.
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 structref value.
Definition: val.h:187