8#include <wasmtime/_anyref_class.hh>
9#include <wasmtime/_exnref_class.hh>
10#include <wasmtime/_externref_class.hh>
11#include <wasmtime/_func_class.hh>
12#include <wasmtime/_val_class.hh>
16inline Val::Val(std::optional<Func> func) : val{} {
21 wasmtime_funcref_set_null(&val.
of.
funcref);
25inline Val::Val(
Func func) :
Val(std::optional(func)) {}
37#ifdef WASMTIME_FEATURE_GC
39inline Val::Val(std::optional<AnyRef> ptr) : val{} {
43 wasmtime_anyref_set_null(ptr->capi());
45 wasmtime_anyref_set_null(&val.
of.
anyref);
49inline Val::Val(AnyRef ptr) : Val(std::optional(ptr)) {}
51inline std::optional<AnyRef> Val::anyref()
const {
55 if (wasmtime_anyref_is_null(&val.
of.
anyref)) {
59 wasmtime_anyref_clone(&val.
of.
anyref, &other);
63inline Val::Val(std::optional<ExternRef> ptr) : val{} {
67 wasmtime_externref_set_null(ptr->capi());
73inline Val::Val(ExternRef ptr) : Val(std::optional(ptr)) {}
75inline std::optional<ExternRef> Val::externref()
const {
79 if (wasmtime_externref_is_null(&val.
of.
externref)) {
84 return ExternRef(other);
87inline Val::Val(std::optional<ExnRef> ptr) : val{} {
91 wasmtime_exnref_set_null(ptr->capi());
93 wasmtime_exnref_set_null(&val.
of.
exnref);
97inline Val::Val(ExnRef ptr) : Val(std::optional(ptr)) {}
99inline std::optional<ExnRef> Val::exnref()
const {
103 if (wasmtime_exnref_is_null(&val.
of.
exnref)) {
108 return ExnRef(other);
114template <>
struct detail::WasmType<V128> {
115 static const bool valid =
true;
Representation of a WebAssembly function.
Definition: _func_class.hh:108
static ValType v128()
Convenience constructor for the v128 value type.
Definition: types/_val_class.hh:130
Representation of a generic WebAssembly value.
Definition: _val_class.hh:54
std::optional< Func > funcref() const
Definition: val.hh:27
WASM_API_EXTERN void wasmtime_exnref_clone(const wasmtime_exnref_t *ref, wasmtime_exnref_t *out)
Creates a new reference pointing to the same exception that ref points to.
WASM_API_EXTERN void wasmtime_externref_clone(const wasmtime_externref_t *ref, wasmtime_externref_t *out)
Creates a new reference pointing to the same data that ref points to (depending on the configured col...
A WebAssembly value in the any hierarchy of GC types.
Definition: val.h:77
A WebAssembly exception reference value.
Definition: val.h:103
A host-defined un-forgeable reference to pass into WebAssembly.
Definition: val.h:136
uint64_t store_id
Definition: extern.h:32
wasmtime_valkind_t kind
Discriminant of which field of of is valid.
Definition: val.h:378
wasmtime_valunion_t of
Container for the extern item's value.
Definition: val.h:380
Container for possible wasm values.
Definition: val.h:290
wasmtime_v128 v128
Definition: val.h:310
wasmtime_func_t funcref
Definition: val.h:254
wasmtime_exnref_t exnref
Field used if wasmtime_val_t::kind is WASMTIME_EXNREF.
Definition: val.h:248
wasmtime_anyref_t anyref
Field used if wasmtime_val_t::kind is WASMTIME_ANYREF.
Definition: val.h:244
wasmtime_externref_t externref
Field used if wasmtime_val_t::kind is WASMTIME_EXTERNREF.
Definition: val.h:246
#define WASMTIME_EXTERNREF
Value of wasmtime_valkind_t meaning that wasmtime_val_t is an externref.
Definition: val.h:38
#define WASMTIME_ANYREF
Value of wasmtime_valkind_t meaning that wasmtime_val_t is an anyref.
Definition: val.h:41
uint8_t wasmtime_v128[16]
A 128-bit value representing the WebAssembly v128 type. Bytes are stored in little-endian order.
Definition: val.h:49
#define WASMTIME_FUNCREF
Value of wasmtime_valkind_t meaning that wasmtime_val_t is a funcref.
Definition: val.h:33
#define WASMTIME_EXNREF
Value of wasmtime_valkind_t meaning that wasmtime_val_t is an exnref.
Definition: val.h:44