github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/store.go (about) 1 package wavm 2 3 // #include <stdlib.h> 4 // #include "wavm-c.h" 5 import "C" 6 import "unsafe" 7 8 type Store C.wasm_store_t 9 10 func NewStore(compartment *Compartment, debugName string) *Store { 11 var name *C.char 12 if debugName == "" { 13 name = EMPTY 14 } else { 15 name = C.CString(debugName) 16 defer C.free(unsafe.Pointer(name)) 17 } 18 return (*Store)(C.wasm_store_new((*C.wasm_compartment_t)(compartment), name)) 19 } 20 21 func (s *Store) Close() error { 22 s.Delete() 23 return nil 24 } 25 26 func (s *Store) Delete() { 27 C.wasm_store_delete((*C.wasm_store_t)(s)) 28 } 29 30 func (s *Store) Call(fn *Func, args *Val, results *Val) *Trap { 31 return fn.Call(s, args, results) 32 }