|
Wasmtime
|
A WebAssembly table. More...
#include <table.hh>
Public Member Functions | |
| Table (wasmtime_table_t table) | |
| Creates a new table from the raw underlying C API representation. | |
| TableType | type (Store::Context cx) const |
| Returns the type of this table. | |
| uint64_t | size (Store::Context cx) const |
| Returns the size, in elements, that the table currently has. | |
| std::optional< Val > | get (Store::Context cx, uint64_t idx) const |
| Result< std::monostate > | set (Store::Context cx, uint64_t idx, const Val &val) const |
| Result< uint64_t > | grow (Store::Context cx, uint64_t delta, const Val &init) const |
| const wasmtime_table_t & | capi () const |
| Returns the raw underlying C API table this is using. | |
Static Public Member Functions | |
| static Result< Table > | create (Store::Context cx, const TableType &ty, const Val &init) |
| Creates a new host-defined table. More... | |
Friends | |
| class | Instance |
A WebAssembly table.
This class represents a WebAssembly table, either created through instantiating a module or a host table. Tables are contiguous vectors of WebAssembly reference types, currently either externref or funcref.
Note that this type does not itself own any resources. It points to resources owned within a Store and the Store must be passed in as the first argument to the functions defined on Table. Note that if the wrong Store is passed in then the process will be aborted.
|
inlinestatic |
Creates a new host-defined table.
| cx | the store in which to create the table. |
| ty | the type of the table to be created |
| init | the initial value for all table slots. |
Returns an error if init has the wrong value for the ty specified.
|
inline |
Loads a value from the specified index in this table.
Returns std::nullopt if idx is out of bounds.
|
inline |
Grow this table.
| cx | the store that owns this table. |
| delta | the number of new elements to be added to this table. |
| init | the initial value of all new elements in this table. |
Returns an error if init has the wrong type for this table. Otherwise returns the previous size of the table before growth.
|
inline |
Stores a value into the specified index in this table.
Returns an error if idx is out of bounds or if val has the wrong type.