5#ifndef WASMTIME_TYPES_MEMORY_HH
6#define WASMTIME_TYPES_MEMORY_HH
29 std::unique_ptr<wasm_memorytype_t, deleter> ptr;
40 Ref() : ptr(
nullptr) {}
53 std::optional<uint64_t>
max()
const {
88 assert(err ==
nullptr);
99 assert(err ==
nullptr);
100 assert(p !=
nullptr);
109 assert(err ==
nullptr);
110 assert(ptr !=
nullptr);
118 assert(err ==
nullptr);
119 assert(ptr !=
nullptr);
150 std::optional<uint64_t> _max;
153 uint8_t _page_size_log2;
158 : _min(0), _memory64(false), _shared(false), _page_size_log2(16) {}
204 _min, _max.has_value(), _max.has_value() ? *_max : 0, _memory64,
205 _shared, _page_size_log2, &p);
206 if (err !=
nullptr) {
209 assert(p !=
nullptr);
Errors coming from Wasmtime.
Definition: error.hh:26
Helper class to build a MemoryType.
Definition: types/memory.hh:148
Builder & max(std::optional< uint64_t > max)
Configure the maximal size, in pages, of linear memory.
Definition: types/memory.hh:167
Builder & page_size_log2(uint8_t page_size_log2)
Configure the page size (in bytes) of this memory type, via its log2 value.
Definition: types/memory.hh:195
Result< MemoryType > build() const
Construct the final MemoryType value.
Definition: types/memory.hh:201
Builder & memory64(bool enable)
Configure whether this is a 64-bit linear memory.
Definition: types/memory.hh:173
Builder & min(uint64_t min)
Configure the minimum size, in pages, of linear memory.
Definition: types/memory.hh:161
Builder()
Default constructor for a memory type with 0 initial size.
Definition: types/memory.hh:157
Builder & shared(bool enable)
Configure whether this is a shared linear memory.
Definition: types/memory.hh:179
Non-owning reference to a MemoryType, must not be used after the original owner has been deleted.
Definition: types/memory.hh:34
Ref(const wasm_memorytype_t *ptr)
Creates a reference from the raw C API representation.
Definition: types/memory.hh:44
bool is_64() const
Returns whether or not this is a 64-bit memory type.
Definition: types/memory.hh:63
bool is_shared() const
Returns whether or not this is a shared memory type.
Definition: types/memory.hh:66
std::optional< uint64_t > max() const
Definition: types/memory.hh:53
uint64_t page_size() const
Returns the memory's page size, in bytes.
Definition: types/memory.hh:69
uint64_t min() const
Returns the minimum size, in WebAssembly pages, of this memory.
Definition: types/memory.hh:49
Ref(const MemoryType &ty)
Creates a reference from an original MemoryType.
Definition: types/memory.hh:46
uint8_t page_size_log2() const
Returns the log2 of the memory's page size, in bytes.
Definition: types/memory.hh:72
Type information about a WebAssembly linear memory.
Definition: types/memory.hh:19
Ref * operator*()
Returns the underlying Ref, a non-owning reference pointing to this instance.
Definition: types/memory.hh:145
MemoryType & operator=(const MemoryType &other)
Copies the provided type into a new type.
Definition: types/memory.hh:130
MemoryType(const MemoryType &other)
Copies the provided type into a new type.
Definition: types/memory.hh:127
MemoryType(Ref other)
Definition: types/memory.hh:125
static MemoryType New64(uint64_t min, uint64_t max)
Same as the MemoryType constructor, except creates a 64-bit memory.
Definition: types/memory.hh:115
static MemoryType New64(uint64_t min)
Same as the MemoryType constructor, except creates a 64-bit memory.
Definition: types/memory.hh:106
MemoryType & operator=(MemoryType &&other)=default
Moves the type information from another type into this one.
MemoryType(MemoryType &&other)=default
Moves the type information from another type into this one.
MemoryType(uint32_t min, uint32_t max)
Definition: types/memory.hh:96
Ref * operator->()
Returns the underlying Ref, a non-owning reference pointing to this instance.
Definition: types/memory.hh:142
MemoryType(uint32_t min)
Definition: types/memory.hh:85
A WebAssembly linear memory.
Definition: memory.hh:27
Fallible result type used for Wasmtime.
Definition: error.hh:70
WASM_API_EXTERN bool wasmtime_memorytype_maximum(const wasm_memorytype_t *ty, uint64_t *max)
Returns the maximum size, in pages, of the specified memory type.
WASM_API_EXTERN uint64_t wasmtime_memorytype_minimum(const wasm_memorytype_t *ty)
Returns the minimum size, in pages, of the specified memory type.
WASM_API_EXTERN wasmtime_error_t * wasmtime_memorytype_new(uint64_t min, bool max_present, uint64_t max, bool is_64, bool shared, uint8_t page_size_log2, wasm_memorytype_t **ret)
Creates a new memory type from the specified parameters.
WASM_API_EXTERN bool wasmtime_memorytype_is64(const wasm_memorytype_t *ty)
Returns whether this type of memory represents a 64-bit memory.
WASM_API_EXTERN bool wasmtime_memorytype_isshared(const wasm_memorytype_t *ty)
Returns whether this type of memory represents a shared memory.
WASM_API_EXTERN uint64_t wasmtime_memorytype_page_size(const wasm_memorytype_t *ty)
Returns the page size, in bytes, of this memory type.
WASM_API_EXTERN uint8_t wasmtime_memorytype_page_size_log2(const wasm_memorytype_t *ty)
Returns the log2 of this memory type's page size, in bytes.
An opaque object representing the type of a memory.
void wasm_memorytype_delete(wasm_memorytype_t *)
Deletes a type.
wasm_memorytype_t * wasm_memorytype_copy(const wasm_memorytype_t *)
Creates a new value which matches the provided one.