Wasmtime
export.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_TYPES_EXPORT_HH
6#define WASMTIME_TYPES_EXPORT_HH
7
8#include <string_view>
9#include <wasm.h>
10#include <wasmtime/helpers.hh>
11
12namespace wasmtime {
13
19#define wasm_exporttype_clone wasm_exporttype_copy
20 WASMTIME_CLONE_WRAPPER(ExportType, wasm_exporttype);
21#undef wasm_exporttype_clone
22
26 class Ref {
27 friend class ExternType;
28
29 const wasm_exporttype_t *ptr;
30
31 const wasm_externtype_t *raw_type() { return wasm_exporttype_type(ptr); }
32
33 public:
35 Ref(const wasm_exporttype_t *ptr) : ptr(ptr) {}
36
38 std::string_view name() {
39 const auto *name = wasm_exporttype_name(ptr);
40 return std::string_view(name->data, name->size);
41 }
42 };
43
45 Ref ref() const { return Ref(ptr.get()); }
46
48 class List {
49 friend class Module;
51
52 public:
54 List() : list{} {
55 list.size = 0;
56 list.data = nullptr;
57 }
58 List(const List &other) = delete;
60 List(List &&other) noexcept : list(other.list) { other.list.size = 0; }
61 ~List() {
62 if (list.size > 0) {
64 }
65 }
66
67 List &operator=(const List &other) = delete;
69 List &operator=(List &&other) noexcept {
70 std::swap(list, other.list);
71 return *this;
72 }
73
76 typedef const Ref *iterator;
78 iterator begin() const {
79 return reinterpret_cast<iterator>(&list.data[0]); // NOLINT
80 }
82 iterator end() const {
83 return reinterpret_cast<iterator>(&list.data[list.size]); // NOLINT
84 }
86 size_t size() const { return list.size; }
87 };
88};
89
90}; // namespace wasmtime
91
92#endif // WASMTIME_TYPES_EXPORT_HH
Type information about a WebAssembly export.
Definition: export.hh:17
An opaque object representing the type of an export.
A list of wasm_exporttype_t values.
Definition: wasm.h:305
size_t size
Length of this vector.
Definition: wasm.h:305
wasm_exporttype_t ** data
Pointer to the base of this vector.
Definition: wasm.h:305
An opaque object representing the type of a external value. Can be seen as a superclass of wasm_funct...
const wasm_name_t * wasm_exporttype_name(const wasm_exporttype_t *)
Returns the name of this export.
const wasm_externtype_t * wasm_exporttype_type(const wasm_exporttype_t *)
Returns the type of this export.
void wasm_exporttype_vec_delete(wasm_exporttype_vec_t *)
Deallocates export for a vector.