Wasmtime
_exnref_class.hh
1#ifndef WASMTIME_EXNREF_CLASS_HH
2#define WASMTIME_EXNREF_CLASS_HH
3
4#include <wasmtime/conf.h>
5
6#ifdef WASMTIME_FEATURE_GC
7
8#include <vector>
9#include <wasmtime/_store_class.hh>
10#include <wasmtime/error.hh>
11#include <wasmtime/exnref.h>
12#include <wasmtime/helpers.hh>
13#include <wasmtime/tag.hh>
15
16namespace wasmtime {
17
18class Val;
19
29class ExnRef {
30 WASMTIME_TOP_REF_WRAPPER(ExnRef, wasmtime_exnref);
31
39 static Result<ExnRef> create(Store::Context cx, const Tag &tag,
40 const std::vector<Val> &fields);
41
43 Result<Tag> tag(Store::Context cx) const {
45 auto *error = wasmtime_exnref_tag(cx.capi(), &raw, &tag);
46 if (error != nullptr) {
47 return Error(error);
48 }
49 return Tag(tag);
50 }
51
53 size_t field_count(Store::Context cx) const {
54 return wasmtime_exnref_field_count(cx.capi(), &raw);
55 }
56
58 Result<Val> field(Store::Context cx, size_t index) const;
59
61 ExnType ty(Store::Context cx) const {
62 auto *ret = wasmtime_exnref_type(cx.capi(), &raw);
63 return ExnType(ret);
64 }
65};
66
67} // namespace wasmtime
68
69#endif // WASMTIME_FEATURE_GC
70
71#endif // WASMTIME_EXNREF_CLASS_HH
Errors coming from Wasmtime.
Definition: error.hh:26
A WebAssembly exception object.
Definition: _exnref_class.hh:29
Owned handle to a WebAssembly exception type definition.
Definition: types/exnref.hh:22
Fallible result type used for Wasmtime.
Definition: error.hh:70
An interior pointer into a Store.
Definition: _store_class.hh:65
const wasmtime_context_t * capi() const
Returns the underlying C API pointer.
Definition: _store_class.hh:183
A WebAssembly tag.
Definition: tag.hh:26
Build-time defines for how the C API was built.
WASM_API_EXTERN wasmtime_error_t * wasmtime_exnref_tag(wasmtime_context_t *store, const wasmtime_exnref_t *exn, wasmtime_tag_t *tag_ret)
Returns the tag associated with this exception.
WASM_API_EXTERN wasmtime_exn_type_t * wasmtime_exnref_type(wasmtime_context_t *context, const wasmtime_exnref_t *exnref)
Returns the type of the specified exnref.
WASM_API_EXTERN size_t wasmtime_exnref_field_count(wasmtime_context_t *store, const wasmtime_exnref_t *exn)
Returns the number of fields in this exception.
A WebAssembly exception reference value.
Definition: val.h:103
Representation of a tag in Wasmtime.
Definition: tag.h:28