Wasmtime
anyref.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_ANYREF_HH
6#define WASMTIME_ANYREF_HH
7
8#include <wasmtime/_anyref_class.hh>
9
10#ifdef WASMTIME_FEATURE_GC
11
12#include <wasmtime/_arrayref_class.hh>
13#include <wasmtime/_eqref_class.hh>
14#include <wasmtime/_structref_class.hh>
15
16namespace wasmtime {
17
18// AnyRef downcast method definitions (declared in val.hh)
19inline bool AnyRef::is_eqref(Store::Context cx) const {
20 return wasmtime_anyref_is_eqref(cx.capi(), &raw);
21}
22inline bool AnyRef::is_struct(Store::Context cx) const {
23 return wasmtime_anyref_is_struct(cx.capi(), &raw);
24}
25inline bool AnyRef::is_array(Store::Context cx) const {
26 return wasmtime_anyref_is_array(cx.capi(), &raw);
27}
28inline std::optional<EqRef> AnyRef::as_eqref(Store::Context cx) const {
30 if (wasmtime_anyref_as_eqref(cx.capi(), &raw, &out))
31 return EqRef(out);
32 return std::nullopt;
33}
34inline std::optional<StructRef> AnyRef::as_struct(Store::Context cx) const {
36 if (wasmtime_anyref_as_struct(cx.capi(), &raw, &out))
37 return StructRef(out);
38 return std::nullopt;
39}
40inline std::optional<ArrayRef> AnyRef::as_array(Store::Context cx) const {
42 if (wasmtime_anyref_as_array(cx.capi(), &raw, &out))
43 return ArrayRef(out);
44 return std::nullopt;
45}
46
47} // namespace wasmtime
48
49#endif // WASMTIME_FEATURE_GC
50
51#endif // WASMTIME_ANYREF_HH
A WebAssembly arrayref value.
Definition: val.h:210
A WebAssembly eqref value.
Definition: val.h:163
A WebAssembly structref value.
Definition: val.h:187