NewTable creates a new `Table` in the given `Store` with the specified `ty`. The `ty` must be a reference type (`funref` or `externref`) and `init` is the initial value for all table slots and must have the type specified by `ty`.
(store Storelike, ty *TableType, init Val)
| 22 | // is the initial value for all table slots and must have the type specified by |
| 23 | // `ty`. |
| 24 | func NewTable(store Storelike, ty *TableType, init Val) (*Table, error) { |
| 25 | var ret C.wasmtime_table_t |
| 26 | var raw_val C.wasmtime_val_t |
| 27 | init.initialize(store, &raw_val) |
| 28 | err := C.wasmtime_table_new(store.Context(), ty.ptr(), &raw_val, &ret) |
| 29 | C.wasmtime_val_unroot(&raw_val) |
| 30 | runtime.KeepAlive(store) |
| 31 | runtime.KeepAlive(ty) |
| 32 | if err != nil { |
| 33 | return nil, mkError(err) |
| 34 | } |
| 35 | return mkTable(ret), nil |
| 36 | } |
| 37 | |
| 38 | func mkTable(val C.wasmtime_table_t) *Table { |
| 39 | return &Table{val} |
searching dependent graphs…