Wasmtime
exnref.h
Go to the documentation of this file.
1
7#ifndef WASMTIME_EXNREF_H
8#define WASMTIME_EXNREF_H
9
10#include <wasmtime/conf.h>
11
12#ifdef WASMTIME_FEATURE_GC
13
15#include <wasmtime/val.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
35WASM_API_EXTERN wasmtime_error_t *
37 const wasmtime_val_t *fields, size_t nfields,
38 wasmtime_exnref_t *exn_ret);
39
42static inline void wasmtime_exnref_set_null(wasmtime_exnref_t *ref) {
43 ref->store_id = 0;
44}
45
48static inline bool wasmtime_exnref_is_null(const wasmtime_exnref_t *ref) {
49 return ref->store_id == 0;
50}
51
58WASM_API_EXTERN void wasmtime_exnref_clone(const wasmtime_exnref_t *ref,
60
66WASM_API_EXTERN void wasmtime_exnref_unroot(wasmtime_exnref_t *ref);
67
75WASM_API_EXTERN void wasmtime_exnref_from_raw(wasmtime_context_t *context,
76 uint32_t raw,
78
89WASM_API_EXTERN uint32_t wasmtime_exnref_to_raw(wasmtime_context_t *context,
90 const wasmtime_exnref_t *ref);
91
101WASM_API_EXTERN wasmtime_error_t *
103 wasmtime_tag_t *tag_ret);
104
111WASM_API_EXTERN size_t wasmtime_exnref_field_count(
112 wasmtime_context_t *store, const wasmtime_exnref_t *exn);
113
125WASM_API_EXTERN wasmtime_error_t *
127 size_t index, wasmtime_val_t *val_ret);
128
140WASM_API_EXTERN wasm_trap_t *
142 const wasmtime_exnref_t *exn);
143
156WASM_API_EXTERN bool
158 wasmtime_exnref_t *exn_ret);
159
168
176WASM_API_EXTERN wasmtime_exn_type_t *
178 const wasmtime_exnref_t *exnref);
179
180#ifdef __cplusplus
181} // extern "C"
182#endif
183
184#endif // WASMTIME_FEATURE_GC
185#endif // WASMTIME_EXNREF_H
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 void wasmtime_exnref_from_raw(wasmtime_context_t *context, uint32_t raw, wasmtime_exnref_t *out)
Converts a raw exnref value coming from wasmtime_val_raw_t into a wasmtime_exnref_t.
WASM_API_EXTERN wasm_trap_t * wasmtime_context_set_exception(wasmtime_context_t *store, const wasmtime_exnref_t *exn)
Sets the pending exception on the store and returns a trap.
WASM_API_EXTERN void wasmtime_exnref_clone(const wasmtime_exnref_t *ref, wasmtime_exnref_t *out)
Creates a new reference pointing to the same exception that ref points to.
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.
WASM_API_EXTERN uint32_t wasmtime_exnref_to_raw(wasmtime_context_t *context, const wasmtime_exnref_t *ref)
Converts a wasmtime_exnref_t to a raw value suitable for storing into a wasmtime_val_raw_t.
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 bool wasmtime_context_has_exception(wasmtime_context_t *store)
Tests whether there is a pending exception on the store.
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.
WASM_API_EXTERN void wasmtime_exnref_unroot(wasmtime_exnref_t *ref)
Unroots the ref provided, enabling future garbage collection.
WASM_API_EXTERN bool wasmtime_context_take_exception(wasmtime_context_t *store, wasmtime_exnref_t *exn_ret)
Takes the pending exception from the store, if any.
Opaque struct representing a wasm trap.
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
Errors generated by Wasmtime.
A WebAssembly exception reference value.
Definition: val.h:103
uint64_t store_id
Definition: val.h:106
Representation of a tag in Wasmtime.
Definition: tag.h:28
Container for different kinds of wasm values.
Definition: val.h:376
struct wasmtime_exn_type wasmtime_exn_type_t
A type of a WebAssembly exception.
Definition: types/exnref.h:16