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
14#include <wasmtime/val.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
34WASM_API_EXTERN wasmtime_error_t *
36 const wasmtime_val_t *fields, size_t nfields,
37 wasmtime_exnref_t *exn_ret);
38
41static inline void wasmtime_exnref_set_null(wasmtime_exnref_t *ref) {
42 ref->store_id = 0;
43}
44
47static inline bool wasmtime_exnref_is_null(const wasmtime_exnref_t *ref) {
48 return ref->store_id == 0;
49}
50
57WASM_API_EXTERN void wasmtime_exnref_clone(const wasmtime_exnref_t *ref,
59
65WASM_API_EXTERN void wasmtime_exnref_unroot(wasmtime_exnref_t *ref);
66
74WASM_API_EXTERN void wasmtime_exnref_from_raw(wasmtime_context_t *context,
75 uint32_t raw,
77
88WASM_API_EXTERN uint32_t wasmtime_exnref_to_raw(wasmtime_context_t *context,
89 const wasmtime_exnref_t *ref);
90
100WASM_API_EXTERN wasmtime_error_t *
102 wasmtime_tag_t *tag_ret);
103
110WASM_API_EXTERN size_t wasmtime_exnref_field_count(
111 wasmtime_context_t *store, const wasmtime_exnref_t *exn);
112
124WASM_API_EXTERN wasmtime_error_t *
126 size_t index, wasmtime_val_t *val_ret);
127
139WASM_API_EXTERN wasm_trap_t *
141 const wasmtime_exnref_t *exn);
142
155WASM_API_EXTERN bool
157 wasmtime_exnref_t *exn_ret);
158
167
168#ifdef __cplusplus
169} // extern "C"
170#endif
171
172#endif // WASMTIME_FEATURE_GC
173#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 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