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

     1  package wavm
     2  
     3  // #include <stdlib.h>
     4  // #include "wavm-c.h"
     5  import "C"
     6  
     7  type Mutability uint8
     8  
     9  const (
    10  	CONST = Mutability(C.WASM_CONST)
    11  	VAR   = Mutability(C.WASM_VAR)
    12  )
    13  
    14  type GlobalType C.wasm_globaltype_t
    15  
    16  func NewGlobalType(valType *ValType, mutability Mutability) *GlobalType {
    17  	return (*GlobalType)(C.wasm_globaltype_new(
    18  		(*C.wasm_valtype_t)(valType),
    19  		(C.wasm_mutability_t)(mutability),
    20  	))
    21  }
    22  
    23  func (g *GlobalType) Close() error {
    24  	if g == nil {
    25  		return nil
    26  	}
    27  	g.Delete()
    28  	return nil
    29  }
    30  
    31  func (g *GlobalType) Delete() {
    32  	C.wasm_globaltype_delete((*C.wasm_globaltype_t)(g))
    33  }
    34  
    35  func (g *GlobalType) Content() *ValType {
    36  	return (*ValType)(C.wasm_globaltype_content((*C.wasm_globaltype_t)(g)))
    37  }
    38  
    39  func (g *GlobalType) Mutability() Mutability {
    40  	return (Mutability)(C.wasm_globaltype_mutability((*C.wasm_globaltype_t)(g)))
    41  }