MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / NewTable

Function NewTable

table.go:24–36  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

22// is the initial value for all table slots and must have the type specified by
23// `ty`.
24func 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
38func mkTable(val C.wasmtime_table_t) *Table {
39 return &Table{val}

Callers 2

TestTableFunction · 0.85
TestRefTypesTableFunction · 0.85

Calls 5

mkErrorFunction · 0.85
mkTableFunction · 0.85
initializeMethod · 0.80
ContextMethod · 0.65
ptrMethod · 0.45

Tested by 2

TestTableFunction · 0.68
TestRefTypesTableFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…