Wasmtime
exnref.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_EXNREF_HH
6#define WASMTIME_EXNREF_HH
7
8#include <wasmtime/_exnref_class.hh>
9
10#ifdef WASMTIME_FEATURE_GC
11
12#include <wasmtime/_val_class.hh>
13
14namespace wasmtime {
15
16inline Result<ExnRef> ExnRef::create(Store::Context cx, const Tag &tag,
17 const std::vector<Val> &fields) {
19 auto *error = wasmtime_exnref_new(
20 cx.capi(), &tag.capi(),
21 reinterpret_cast<const wasmtime_val_t *>(fields.data()), fields.size(),
22 &exn);
23 if (error != nullptr) {
24 return Error(error);
25 }
26 return ExnRef(exn);
27}
28
30inline Result<Val> ExnRef::field(Store::Context cx, size_t index) const {
32 auto *error = wasmtime_exnref_field(cx.capi(), &raw, index, &val);
33 if (error != nullptr) {
34 return Error(error);
35 }
36 return Val(val);
37}
38
39} // namespace wasmtime
40
41#endif // WASMTIME_FEATURE_GC
42
43#endif // WASMTIME_EXNREF_HH
WASM_API_EXTERN wasmtime_error_t * wasmtime_exnref_new(wasmtime_context_t *store, const wasmtime_tag_t *tag, const wasmtime_val_t *fields, size_t nfields, wasmtime_exnref_t *exn_ret)
Creates a new exception object.
WASM_API_EXTERN wasmtime_error_t * wasmtime_exnref_field(wasmtime_context_t *store, const wasmtime_exnref_t *exn, size_t index, wasmtime_val_t *val_ret)
Reads a field value from this exception by index.
A WebAssembly exception reference value.
Definition: val.h:103
Container for different kinds of wasm values.
Definition: val.h:376