github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/export.go (about) 1 package wavm 2 3 // #include <stdlib.h> 4 // #include "wavm-c.h" 5 import "C" 6 import ( 7 "reflect" 8 "unsafe" 9 ) 10 11 type ( 12 /* 13 typedef struct wasm_export_t 14 { 15 const char* name; 16 size_t num_name_bytes; 17 wasm_externtype_t* type; 18 } wasm_export_t; 19 */ 20 Export struct { 21 name *C.char 22 num_name_bytes C.size_t 23 _type *C.wasm_externtype_t 24 } 25 ) 26 27 func (w *Export) NameUnsafe() string { 28 return *(*string)(unsafe.Pointer(&reflect.StringHeader{ 29 Data: uintptr(unsafe.Pointer(w.name)), 30 Len: int(w.num_name_bytes), 31 })) 32 }