Wasmtime
tag.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_TAG_HH
6#define WASMTIME_TAG_HH
7
8#include <wasmtime/error.hh>
9#include <wasmtime/store.hh>
10#include <wasmtime/tag.h>
11#include <wasmtime/types/tag.hh>
12
13namespace wasmtime {
14
26class Tag {
27 friend class Instance;
29
30public:
32 Tag(wasmtime_tag_t tag) : tag(tag) {}
33
40 static Result<Tag> create(Store::Context cx, const TagType &ty) {
42 auto *error = wasmtime_tag_new(cx.ptr, ty.ptr.get(), &tag);
43 if (error != nullptr) {
44 return Error(error);
45 }
46 return Tag(tag);
47 }
48
51 return TagType(wasmtime_tag_type(cx.ptr, &tag));
52 }
53
55 bool eq(Store::Context cx, const Tag &other) const {
56 return wasmtime_tag_eq(cx.ptr, &tag, &other.tag);
57 }
58
60 const wasmtime_tag_t &capi() const { return tag; }
61};
62
63} // namespace wasmtime
64
65#endif // WASMTIME_TAG_HH
Errors coming from Wasmtime.
Definition: error.hh:26
A WebAssembly instance.
Definition: instance.hh:32
Fallible result type used for Wasmtime.
Definition: error.hh:70
An interior pointer into a Store.
Definition: store.hh:69
Type information for a WebAssembly exception tag.
Definition: types/tag.hh:20
A WebAssembly tag.
Definition: tag.hh:26
const wasmtime_tag_t & capi() const
Returns the raw underlying C API tag this is using.
Definition: tag.hh:60
TagType type(Store::Context cx) const
Returns the type of this tag.
Definition: tag.hh:50
static Result< Tag > create(Store::Context cx, const TagType &ty)
Create a new host-defined tag.
Definition: tag.hh:40
Tag(wasmtime_tag_t tag)
Creates a tag from the raw underlying C API representation.
Definition: tag.hh:32
bool eq(Store::Context cx, const Tag &other) const
Tests whether two tags are identical.
Definition: tag.hh:55
Representation of a tag in Wasmtime.
Definition: tag.h:28
Wasmtime APIs for interacting with WebAssembly tags.
WASM_API_EXTERN wasmtime_error_t * wasmtime_tag_new(wasmtime_context_t *store, const wasm_tagtype_t *tt, wasmtime_tag_t *ret)
Creates a new host-defined tag.
WASM_API_EXTERN wasm_tagtype_t * wasmtime_tag_type(const wasmtime_context_t *store, const wasmtime_tag_t *tag)
Returns the type of the given tag.
WASM_API_EXTERN bool wasmtime_tag_eq(const wasmtime_context_t *store, const wasmtime_tag_t *a, const wasmtime_tag_t *b)
Tests whether two tags are identical (same definition).