#ifndef WASMTIME_ARRAYREF_CLASS_HH
#define WASMTIME_ARRAYREF_CLASS_HH
#include <wasmtime/conf.h>
#ifdef WASMTIME_FEATURE_GC
#include <wasmtime/_store_class.hh>
#include <wasmtime/arrayref.h>
#include <wasmtime/types/arrayref.hh>
namespace wasmtime {
class Val;
class AnyRef;
class EqRef;
class ArrayRefPre {
friend class ArrayRef;
WASMTIME_OWN_WRAPPER(ArrayRefPre, wasmtime_array_ref_pre)
public:
static ArrayRefPre create(Store::Context cx, const ArrayType &ty) {
auto *raw = wasmtime_array_ref_pre_new(cx.capi(), ty.capi());
ArrayRefPre pre(raw);
return pre;
}
};
class ArrayRef {
WASMTIME_REF_WRAPPER(ArrayRef, wasmtime_arrayref)
public:
static Result<ArrayRef> create(Store::Context cx, const ArrayRefPre &pre,
const Val &elem, uint32_t len);
Result<uint32_t> len(Store::Context cx) const {
uint32_t out;
auto *err = wasmtime_arrayref_len(cx.capi(), &raw, &out);
if (err)
return Result<uint32_t>(Error(err));
return Result<uint32_t>(out);
}
Result<Val> get(Store::Context cx, uint32_t index) const;
Result<std::monostate> set(Store::Context cx, uint32_t index,
const Val &value) const;
AnyRef to_anyref() const;
EqRef to_eqref() const;
};
}
#endif
#endif