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() const {
32 return wasm_exporttype_type(ptr);
33 }
34
35 public:
37 Ref(const wasm_exporttype_t *ptr) : ptr(ptr) {}
38
40 std::string_view name() const {
41 const auto *name = wasm_exporttype_name(ptr);
42 return std::string_view(name->data, name->size);
43 }
44 };
45
47 Ref ref() const { return Ref(ptr.get()); }
48
50 class List {
51 friend class Module;
53
54 public:
56 List() : list{} {
57 list.size = 0;
58 list.data = nullptr;
59 }
60 List(const List &other) = delete;
62 List(List &&other) noexcept : list(other.list) { other.list.size = 0; }
63 ~List() {
64 if (list.size > 0) {
66 }
67 }
68
69 List &operator=(const List &other) = delete;
71 List &operator=(List &&other) noexcept {
72 std::swap(list, other.list);
73 return *this;
74 }
75
78 typedef const Ref *iterator;
80 iterator begin() const {
81 return reinterpret_cast<iterator>(&list.data[0]); // NOLINT
82 }
84 iterator end() const {
85 return reinterpret_cast<iterator>(&list.data[list.size]); // NOLINT
86 }
88 size_t size() const { return list.size; }
89 };
90};
91
92}; // namespace wasmtime
93
94#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:319
size_t size
Length of this vector.
Definition: wasm.h:319
wasm_exporttype_t ** data
Pointer to the base of this vector.
Definition: wasm.h:319
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.