github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/config.go (about) 1 package wavm 2 3 /* 4 #include "wavm-c.h" 5 6 void wasm_config_enable_all(wasm_config_t* c) { 7 wasm_config_feature_set_import_export_mutable_globals(c, true); 8 wasm_config_feature_set_nontrapping_float_to_int(c, true); 9 wasm_config_feature_set_sign_extension(c, true); 10 wasm_config_feature_set_bulk_memory_ops(c, true); 11 wasm_config_feature_set_simd(c, true); 12 wasm_config_feature_set_atomics(c, true); 13 wasm_config_feature_set_exception_handling(c, true); 14 wasm_config_feature_set_multivalue(c, true); 15 wasm_config_feature_set_reference_types(c, true); 16 wasm_config_feature_set_extended_name_section(c, true); 17 wasm_config_feature_set_multimemory(c, true); 18 wasm_config_feature_set_shared_tables(c, true); 19 } 20 21 wasm_config_t* wasm_config_new_enable_all() { 22 wasm_config_t* c = wasm_config_new(); 23 wasm_config_enable_all(c); 24 return c; 25 } 26 27 */ 28 import "C" 29 30 type Config C.wasm_config_t 31 32 func NewConfig() *Config { 33 return (*Config)(C.wasm_config_new()) 34 } 35 36 func NewConfigAll() *Config { 37 return (*Config)(C.wasm_config_new_enable_all()) 38 } 39 40 func (c *Config) Close() error { 41 c.Delete() 42 return nil 43 } 44 45 func (c *Config) Delete() { 46 C.wasm_config_delete((*C.wasm_config_t)(c)) 47 } 48 49 func (c *Config) EnableAll() *Config { 50 C.wasm_config_enable_all((*C.wasm_config_t)(c)) 51 return c 52 } 53 54 func (c *Config) SetImportExportMutableGlobals(enable bool) *Config { 55 C.wasm_config_feature_set_import_export_mutable_globals((*C.wasm_config_t)(c), (C.bool)(enable)) 56 return c 57 } 58 59 func (c *Config) SetNonTrappingFloatToInt(enable bool) *Config { 60 C.wasm_config_feature_set_nontrapping_float_to_int((*C.wasm_config_t)(c), (C.bool)(enable)) 61 return c 62 } 63 64 func (c *Config) SetSignExtension(enable bool) *Config { 65 C.wasm_config_feature_set_sign_extension((*C.wasm_config_t)(c), (C.bool)(enable)) 66 return c 67 } 68 69 func (c *Config) SetBulkMemoryOps(enable bool) *Config { 70 C.wasm_config_feature_set_bulk_memory_ops((*C.wasm_config_t)(c), (C.bool)(enable)) 71 return c 72 } 73 74 func (c *Config) SetSIMD(enable bool) *Config { 75 C.wasm_config_feature_set_simd((*C.wasm_config_t)(c), (C.bool)(enable)) 76 return c 77 } 78 79 func (c *Config) SetAtomics(enable bool) *Config { 80 C.wasm_config_feature_set_atomics((*C.wasm_config_t)(c), (C.bool)(enable)) 81 return c 82 } 83 84 func (c *Config) SetExceptionHandling(enable bool) *Config { 85 C.wasm_config_feature_set_exception_handling((*C.wasm_config_t)(c), (C.bool)(enable)) 86 return c 87 } 88 89 func (c *Config) SetMultiValue(enable bool) *Config { 90 C.wasm_config_feature_set_multivalue((*C.wasm_config_t)(c), (C.bool)(enable)) 91 return c 92 } 93 94 func (c *Config) SetReferenceTypes(enable bool) *Config { 95 C.wasm_config_feature_set_reference_types((*C.wasm_config_t)(c), (C.bool)(enable)) 96 return c 97 } 98 99 func (c *Config) SetExtendedNameSection(enable bool) *Config { 100 C.wasm_config_feature_set_extended_name_section((*C.wasm_config_t)(c), (C.bool)(enable)) 101 return c 102 } 103 104 func (c *Config) SetMultiMemory(enable bool) *Config { 105 C.wasm_config_feature_set_multimemory((*C.wasm_config_t)(c), (C.bool)(enable)) 106 return c 107 }