Wasmtime
types/exnref.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_TYPES_EXNREF_HH
6#define WASMTIME_TYPES_EXNREF_HH
7
8#include <initializer_list>
9#include <memory>
10#include <vector>
11#include <wasmtime/engine.hh>
12#include <wasmtime/error.hh>
13#include <wasmtime/types/_val_class.hh>
15#include <wasmtime/types/tag.hh>
16
17namespace wasmtime {
18
22class ExnType {
24#define wasmtime_exn_type_clone wasmtime_exn_type_copy
25 WASMTIME_CLONE_WRAPPER(ExnType, wasmtime_exn_type)
26#undef wasmtime_exn_type_clone
27
28public:
30 static Result<ExnType> create(const Engine &engine,
31 const std::initializer_list<ValType> &params) {
32 std::vector<const wasm_valtype_t *> tmp;
33 for (const auto &param : params)
34 tmp.push_back(param.capi());
35 wasm_valtype_vec_t params_vec;
36 params_vec.data = const_cast<wasm_valtype_t **>(tmp.data());
37 params_vec.size = tmp.size();
38 wasmtime_exn_type_t *result = nullptr;
39 auto error = wasmtime_exn_type_new(engine.capi(), &params_vec, &result);
40 if (error)
41 return Error(error);
42 return ExnType(result);
43 }
44
46 TagType tag_type() const {
48 auto result = TagType(TagType::Ref(raw));
50 return result;
51 }
52};
53
54} // namespace wasmtime
55
56#endif // WASMTIME_TYPES_EXNREF_HH
Global compilation state in Wasmtime.
Definition: engine.hh:22
Errors coming from Wasmtime.
Definition: error.hh:26
Owned handle to a WebAssembly exception type definition.
Definition: types/exnref.hh:22
TagType tag_type() const
Returns the tag type associated with this exception type.
Definition: types/exnref.hh:46
static Result< ExnType > create(const Engine &engine, const std::initializer_list< ValType > &params)
Creates a new exception type with the given parameter types.
Definition: types/exnref.hh:30
Fallible result type used for Wasmtime.
Definition: error.hh:70
Definition: types/tag.hh:32
Type information for a WebAssembly exception tag.
Definition: types/tag.hh:20
An opaque object representing the type of a tag.
An object representing the type of a value.
A list of wasm_valtype_t values.
Definition: wasm.h:183
wasm_valtype_t ** data
Pointer to the base of this vector.
Definition: wasm.h:183
size_t size
Length of this vector.
Definition: wasm.h:183
WASM_API_EXTERN wasmtime_error_t * wasmtime_exn_type_new(const wasm_engine_t *engine, const wasm_valtype_vec_t *params, wasmtime_exn_type_t **out)
Creates a new exception type with the given parameter types.
struct wasmtime_exn_type wasmtime_exn_type_t
A type of a WebAssembly exception.
Definition: types/exnref.h:16
WASM_API_EXTERN wasm_tagtype_t * wasmtime_exn_type_tag_type(const wasmtime_exn_type_t *ty)
Returns tag type associated with this exception type.
void wasm_tagtype_delete(wasm_tagtype_t *)
Deletes a type.