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>
14
15namespace wasmtime {
16
17class Val;
18
28class ExnRef {
29 WASMTIME_TOP_REF_WRAPPER(ExnRef, wasmtime_exnref);
30
38 static Result<ExnRef> create(Store::Context cx, const Tag &tag,
39 const std::vector<Val> &fields);
40
42 Result<Tag> tag(Store::Context cx) const {
44 auto *error = wasmtime_exnref_tag(cx.capi(), &raw, &tag);
45 if (error != nullptr) {
46 return Error(error);
47 }
48 return Tag(tag);
49 }
50
52 size_t field_count(Store::Context cx) const {
53 return wasmtime_exnref_field_count(cx.capi(), &raw);
54 }
55
57 Result<Val> field(Store::Context cx, size_t index) const;
58};
59
60} // namespace wasmtime
61
62#endif // WASMTIME_FEATURE_GC
63
64#endif // WASMTIME_EXNREF_CLASS_HH
Errors coming from Wasmtime.
Definition: error.hh:26
A WebAssembly exception object.
Definition: _exnref_class.hh:28
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 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