github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/extern.go (about)

     1  package wavm
     2  
     3  // #include <stdlib.h>
     4  // #include "wavm-c.h"
     5  import "C"
     6  
     7  type Extern C.wasm_extern_t
     8  
     9  func (e *Extern) Delete() {
    10  	C.wasm_extern_delete((*C.wasm_extern_t)(e))
    11  }
    12  
    13  func (e *Extern) Close() error {
    14  	e.Delete()
    15  	return nil
    16  }
    17  
    18  func (f *Func) AsExtern() *Extern {
    19  	return (*Extern)(C.wasm_func_as_extern((*C.wasm_func_t)(f)))
    20  }
    21  
    22  func (g *Global) AsExtern() *Extern {
    23  	return (*Extern)(C.wasm_global_as_extern((*C.wasm_global_t)(g)))
    24  }
    25  
    26  func (t *Table) AsExtern() *Extern {
    27  	return (*Extern)(C.wasm_table_as_extern((*C.wasm_table_t)(t)))
    28  }
    29  
    30  func (m *Memory) AsExtern() *Extern {
    31  	return (*Extern)(C.wasm_memory_as_extern((*C.wasm_memory_t)(m)))
    32  }
    33  
    34  func (e *Extern) AsFunc() *Func {
    35  	return (*Func)(C.wasm_extern_as_func((*C.wasm_extern_t)(e)))
    36  }
    37  
    38  func (e *Extern) AsGlobal() *Global {
    39  	return (*Global)(C.wasm_extern_as_global((*C.wasm_extern_t)(e)))
    40  }
    41  func (e *Extern) AsTable() *Table {
    42  	return (*Table)(C.wasm_extern_as_table((*C.wasm_extern_t)(e)))
    43  }
    44  func (e *Extern) AsMemory() *Memory {
    45  	return (*Memory)(C.wasm_extern_as_memory((*C.wasm_extern_t)(e)))
    46  }