github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/memory_type.go (about) 1 package wavm 2 3 // #include <stdlib.h> 4 // #include "wavm-c.h" 5 import "C" 6 import "unsafe" 7 8 type MemoryType C.wasm_memorytype_t 9 10 type Shared uint8 11 12 const ( 13 NOTSHARED = Shared(C.WASM_NOTSHARED) 14 SHARED = Shared(C.WASM_SHARED) 15 ) 16 17 type Index uint8 18 19 const ( 20 INDEX_I32 = Index(C.WASM_INDEX_I32) 21 INDEX_I64 = Index(C.WASM_INDEX_I64) 22 ) 23 24 func NewMemoryType(limits *Limits, shared Shared, index int) *MemoryType { 25 return (*MemoryType)(C.wasm_memorytype_new((*C.wasm_limits_t)(unsafe.Pointer(limits)), (C.wasm_shared_t)(shared), (C.wasm_index_t)(index))) 26 } 27 28 func (m *MemoryType) Close() error { 29 m.Delete() 30 return nil 31 } 32 33 func (m *MemoryType) Delete() { 34 C.wasm_memorytype_delete((*C.wasm_memorytype_t)(m)) 35 } 36 37 func (m *MemoryType) Limits() *Limits { 38 return (*Limits)(unsafe.Pointer(C.wasm_memorytype_limits((*C.wasm_memorytype_t)(m)))) 39 } 40 41 func (m *MemoryType) Shared() Shared { 42 return (Shared)(C.wasm_memorytype_shared((*C.wasm_memorytype_t)(m))) 43 }