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
11namespace wasmtime {
12
17
18public:
22 class Ref {
23 friend class ExternType;
24
25 const wasm_exporttype_t *ptr;
26
27 const wasm_externtype_t *raw_type() { return wasm_exporttype_type(ptr); }
28
29 public:
31 Ref(const wasm_exporttype_t *ptr) : ptr(ptr) {}
32
34 std::string_view name() {
35 const auto *name = wasm_exporttype_name(ptr);
36 return std::string_view(name->data, name->size);
37 }
38 };
39
41 class List {
42 friend class Module;
44
45 public:
47 List() : list{} {
48 list.size = 0;
49 list.data = nullptr;
50 }
51 List(const List &other) = delete;
53 List(List &&other) noexcept : list(other.list) { other.list.size = 0; }
54 ~List() {
55 if (list.size > 0) {
57 }
58 }
59
60 List &operator=(const List &other) = delete;
62 List &operator=(List &&other) noexcept {
63 std::swap(list, other.list);
64 return *this;
65 }
66
69 typedef const Ref *iterator;
71 iterator begin() const {
72 return reinterpret_cast<iterator>(&list.data[0]); // NOLINT
73 }
75 iterator end() const {
76 return reinterpret_cast<iterator>(&list.data[list.size]); // NOLINT
77 }
79 size_t size() const { return list.size; }
80 };
81};
82
83}; // namespace wasmtime
84
85#endif // WASMTIME_TYPES_EXPORT_HH
An owned list of ExportType instances.
Definition: export.hh:41
List()
Creates an empty list.
Definition: export.hh:47
iterator begin() const
Returns the start of iteration.
Definition: export.hh:71
const Ref * iterator
Definition: export.hh:69
size_t size() const
Returns the size of this list.
Definition: export.hh:79
iterator end() const
Returns the end of iteration.
Definition: export.hh:75
List & operator=(List &&other) noexcept
Moves another list into this one.
Definition: export.hh:62
List(List &&other) noexcept
Moves another list into this one.
Definition: export.hh:53
Non-owning reference to an ExportType.
Definition: export.hh:22
Ref(const wasm_exporttype_t *ptr)
Creates a new reference from the raw underlying C API representation.
Definition: export.hh:31
std::string_view name()
Returns the name of this export.
Definition: export.hh:34
Type information about a WebAssembly export.
Definition: export.hh:16
Generic type of a WebAssembly item.
Definition: types/extern.hh:22
Representation of a compiled WebAssembly module.
Definition: module.hh:27
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.