github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/extern_type.go (about) 1 package wavm 2 3 // #include <stdlib.h> 4 // #include "wavm-c.h" 5 import "C" 6 7 type ( 8 ExternType C.wasm_externtype_t 9 ExternKind uint8 10 ) 11 12 const ( 13 ExternFunc = ExternKind(C.WASM_EXTERN_FUNC) 14 ExternTable = ExternKind(C.WASM_EXTERN_TABLE) 15 ExternMemory = ExternKind(C.WASM_EXTERN_MEMORY) 16 ExternGlobal = ExternKind(C.WASM_EXTERN_GLOBAL) 17 ) 18 19 func WASMExternKind(extern *Extern) ExternKind { 20 return ExternKind(C.wasm_extern_kind((*C.wasm_extern_t)(extern))) 21 } 22 23 func (e *Extern) AsKind() ExternKind { 24 return WASMExternKind(e) 25 } 26 27 func WASMExternType(extern *Extern) *ExternType { 28 return (*ExternType)(C.wasm_extern_type((*C.wasm_extern_t)(extern))) 29 } 30 31 func FuncTypeAsExternType(t *FuncType) *ExternType { 32 return (*ExternType)(C.wasm_functype_as_externtype((*C.wasm_functype_t)(t))) 33 } 34 35 func GlobalTypeAsExternType(t *GlobalType) *ExternType { 36 return (*ExternType)(C.wasm_globaltype_as_externtype((*C.wasm_globaltype_t)(t))) 37 } 38 39 func TableTypeAsExternType(t *TableType) *ExternType { 40 return (*ExternType)(C.wasm_tabletype_as_externtype((*C.wasm_tabletype_t)(t))) 41 } 42 43 func MemoryTypeAsExternType(t *MemoryType) *ExternType { 44 return (*ExternType)(C.wasm_memorytype_as_externtype((*C.wasm_memorytype_t)(t))) 45 } 46 47 func ExternTypeAsFuncType(t *ExternType) *FuncType { 48 return (*FuncType)(C.wasm_externtype_as_functype((*C.wasm_externtype_t)(t))) 49 } 50 51 func ExternTypeAsGlobalType(t *ExternType) *GlobalType { 52 return (*GlobalType)(C.wasm_externtype_as_globaltype((*C.wasm_externtype_t)(t))) 53 } 54 55 func ExternTypeAsTableType(t *ExternType) *TableType { 56 return (*TableType)(C.wasm_externtype_as_tabletype((*C.wasm_externtype_t)(t))) 57 } 58 59 func ExternTypeAsMemoryType(t *ExternType) *MemoryType { 60 return (*MemoryType)(C.wasm_externtype_as_memorytype((*C.wasm_externtype_t)(t))) 61 } 62 63 //func WASMExternType(extern *Extern) *ExternType { 64 // return (*ExternType)(C.wasm_extern_type_const((*C.wasm_extern_t)(extern))) 65 //} 66 67 func FuncTypeAsExternTypeConst(t *FuncType) *ExternType { 68 return (*ExternType)(C.wasm_functype_as_externtype_const((*C.wasm_functype_t)(t))) 69 } 70 71 func GlobalTypeAsExternTypeConst(t *GlobalType) *ExternType { 72 return (*ExternType)(C.wasm_globaltype_as_externtype_const((*C.wasm_globaltype_t)(t))) 73 } 74 75 func TableTypeAsExternTypeConst(t *TableType) *ExternType { 76 return (*ExternType)(C.wasm_tabletype_as_externtype_const((*C.wasm_tabletype_t)(t))) 77 } 78 79 func MemoryTypeAsExternTypeConst(t *MemoryType) *ExternType { 80 return (*ExternType)(C.wasm_memorytype_as_externtype_const((*C.wasm_memorytype_t)(t))) 81 } 82 83 func ExternTypeAsFuncTypeConst(t *ExternType) *FuncType { 84 return (*FuncType)(C.wasm_externtype_as_functype_const((*C.wasm_externtype_t)(t))) 85 } 86 87 func ExternTypeAsGlobalTypeConst(t *ExternType) *GlobalType { 88 return (*GlobalType)(C.wasm_externtype_as_globaltype_const((*C.wasm_externtype_t)(t))) 89 } 90 91 func ExternTypeAsTableTypeConst(t *ExternType) *TableType { 92 return (*TableType)(C.wasm_externtype_as_tabletype_const((*C.wasm_externtype_t)(t))) 93 } 94 95 func ExternTypeAsMemoryTypeConst(t *ExternType) *MemoryType { 96 return (*MemoryType)(C.wasm_externtype_as_memorytype_const((*C.wasm_externtype_t)(t))) 97 } 98 99 //func WASMFuncAsExternConst(fn *Func) *Extern { 100 // return (*Extern)(C.wasm_func_as_extern_const((*C.wasm_func_t)(fn))) 101 //} 102 //func WASMGlobalAsExternConst(global *Global) *Extern { 103 // return (*Extern)(C.wasm_global_as_extern_const((*C.wasm_global_t)(global))) 104 //} 105 //func WASMTableAsExternConst(table *Table) *Extern { 106 // return (*Extern)(C.wasm_table_as_extern_const((*C.wasm_table_t)(table))) 107 //} 108 //func WASMMemoryAsExternConst(memory *Memory) *Extern { 109 // return (*Extern)(C.wasm_memory_as_extern_const((*C.wasm_memory_t)(memory))) 110 //} 111 //func WASMExternAsFuncConst(extern *Extern) *Func { 112 // return (*Func)(C.wasm_extern_as_func_const((*C.wasm_extern_t)(extern))) 113 //} 114 //func WASMExternAsGlobalConst(extern *Extern) *Global { 115 // return (*Global)(C.wasm_extern_as_global_const((*C.wasm_extern_t)(extern))) 116 //} 117 //func WASMExternAsTableConst(extern *Extern) *Table { 118 // return (*Table)(C.wasm_extern_as_table_const((*C.wasm_extern_t)(extern))) 119 //} 120 //func WASMExternAsMemoryConst(extern *Extern) *Memory { 121 // return (*Memory)(C.wasm_extern_as_memory_const((*C.wasm_extern_t)(extern))) 122 //}