Wasmtime
eqref.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_EQREF_HH
6#define WASMTIME_EQREF_HH
7
8#include <wasmtime/_eqref_class.hh>
9
10#ifdef WASMTIME_FEATURE_GC
11
12#include <wasmtime/_anyref_class.hh>
13#include <wasmtime/_arrayref_class.hh>
14#include <wasmtime/_structref_class.hh>
15
16namespace wasmtime {
17
18inline std::optional<StructRef> EqRef::as_struct(Store::Context cx) const {
20 if (wasmtime_eqref_as_struct(cx.capi(), &raw, &out))
21 return StructRef(out);
22 return std::nullopt;
23}
24
25inline std::optional<ArrayRef> EqRef::as_array(Store::Context cx) const {
27 if (wasmtime_eqref_as_array(cx.capi(), &raw, &out))
28 return ArrayRef(out);
29 return std::nullopt;
30}
31
32inline AnyRef EqRef::to_anyref() const {
34 wasmtime_eqref_to_anyref(&raw, &out);
35 return AnyRef(out);
36}
37
38} // namespace wasmtime
39
40#endif // WASMTIME_FEATURE_GC
41
42#endif // WASMTIME_EQREF_HH
std::optional< ArrayRef > as_array(Store::Context cx) const
Downcast this eqref into an arrayref.
std::optional< StructRef > as_struct(Store::Context cx) const
Downcast this eqref into a structref.
AnyRef to_anyref() const
Upcast this eqref to an anyref.
WASM_API_EXTERN void wasmtime_eqref_to_anyref(const wasmtime_eqref_t *eqref, wasmtime_anyref_t *out)
Upcast an eqref to an anyref.
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.
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.
A WebAssembly value in the any hierarchy of GC types.
Definition: val.h:77
A WebAssembly arrayref value.
Definition: val.h:210
A WebAssembly structref value.
Definition: val.h:187