#ifndef WASMTIME_ANYREF_CLASS_HH
#define WASMTIME_ANYREF_CLASS_HH
#include <wasmtime/conf.h>
#ifdef WASMTIME_FEATURE_GC
#include <wasmtime/_store_class.hh>
#include <wasmtime/anyref.h>
#include <wasmtime/helpers.hh>
namespace wasmtime {
class ArrayRef;
class EqRef;
class StructRef;
class AnyRef {
WASMTIME_TOP_REF_WRAPPER(AnyRef, wasmtime_anyref);
static AnyRef i31(Store::Context cx, uint32_t value) {
wasmtime_anyref_t other;
wasmtime_anyref_from_i31(cx.capi(), value, &other);
return AnyRef(other);
}
std::optional<uint32_t> u31(Store::Context cx) const {
uint32_t ret = 0;
if (wasmtime_anyref_i31_get_u(cx.capi(), &raw, &ret))
return ret;
return std::nullopt;
}
std::optional<int32_t> i31(Store::Context cx) const {
int32_t ret = 0;
if (wasmtime_anyref_i31_get_s(cx.capi(), &raw, &ret))
return ret;
return std::nullopt;
}
bool is_i31(Store::Context cx) const {
return wasmtime_anyref_is_i31(cx.capi(), &raw);
}
inline bool is_eqref(Store::Context cx) const;
inline bool is_struct(Store::Context cx) const;
inline bool is_array(Store::Context cx) const;
inline std::optional<EqRef> as_eqref(Store::Context cx) const;
inline std::optional<StructRef> as_struct(Store::Context cx) const;
inline std::optional<ArrayRef> as_array(Store::Context cx) const;
};
}
#endif
#endif