github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/exttinygo/internal/impl_tinygo.go (about) 1 //go:build tinygo 2 3 /* 4 * Copyright (c) 2023-present unTill Pro, Ltd. 5 * @author Michael Saigachenko 6 */ 7 8 package internal 9 10 import ( 11 "runtime" 12 13 isafeapi "github.com/voedger/voedger/pkg/state/isafestateapi" 14 ) 15 16 type extint = uintptr 17 18 //export hostPanic 19 func HostPanic(msgPtr, msgSize uint32) 20 21 //export hostRowWriterPutString 22 func hostRowWriterPutString(id uint64, typ uint32, namePtr, nameSize, valuePtr, valueSize uint32) 23 24 //export hostRowWriterPutBytes 25 func hostRowWriterPutBytes(id uint64, typ uint32, namePtr, nameSize, valuePtr, valueSize uint32) 26 27 //export hostRowWriterPutQName 28 func hostRowWriterPutQName(id uint64, typ uint32, namePtr, nameSize, pkgPtr, pkgSize, entityPtr, entitySize uint32) 29 30 //export hostRowWriterPutIntBool 31 func hostRowWriterPutBool(id uint64, typ uint32, namePtr, nameSize, value uint32) 32 33 //export hostRowWriterPutInt32 34 func hostRowWriterPutInt32(id uint64, typ uint32, namePtr, nameSize, value uint32) 35 36 //export hostRowWriterPutInt64 37 func hostRowWriterPutInt64(id uint64, typ uint32, namePtr, nameSize uint32, value uint64) 38 39 //export hostRowWriterPutFloat32 40 func hostRowWriterPutFloat32(id uint64, typ uint32, namePtr, nameSize uint32, value float32) 41 42 //export hostRowWriterPutFloat64 43 func hostRowWriterPutFloat64(id uint64, typ uint32, namePtr, nameSize uint32, value float64) 44 45 //export hostGetKey 46 func hostGetKey(storagePtr, storageSize, entityPtr, entitySize uint32) uint64 47 48 //export hostQueryValue 49 func hostQueryValue(keyId uint64) (result uint64) 50 51 //export hostNewValue 52 func hostNewValue(keyId uint64) uint64 53 54 //export hostUpdateValue 55 func hostUpdateValue(keyId uint64, existingValueId uint64) uint64 56 57 //export hostValueLength 58 func hostValueLength(id uint64) uint32 59 60 //export hostValueAsBytes 61 func hostValueAsBytes(id uint64, namePtr, nameSize uint32) uint64 62 63 //export hostValueAsString 64 func hostValueAsString(id uint64, namePtr, nameSize uint32) uint64 65 66 //export hostValueAsInt32 67 func hostValueAsInt32(id uint64, namePtr, nameSize uint32) uint32 68 69 //export hostValueAsInt64 70 func hostValueAsInt64(id uint64, namePtr, nameSize uint32) uint64 71 72 //export hostValueAsFloat32 73 func hostValueAsFloat32(id uint64, namePtr, nameSize uint32) float32 74 75 //export hostValueAsFloat64 76 func hostValueAsFloat64(id uint64, namePtr, nameSize uint32) float64 77 78 //export hostValueAsValue 79 func hostValueAsValue(id uint64, namePtr, nameSize uint32) uint64 80 81 //export hostValueAsQNamePkg 82 func hostValueAsQNamePkg(id uint64, namePtr, nameSize uint32) uint64 83 84 //export hostValueAsQNameEntity 85 func hostValueAsQNameEntity(id uint64, namePtr, nameSize uint32) uint64 86 87 //export hostValueAsBool 88 func hostValueAsBool(id uint64, namePtr, nameSize uint32) uint64 89 90 //export hostValueGetAsBytes 91 func hostValueGetAsBytes(id uint64, index uint32) uint64 92 93 //export hostValueGetAsString 94 func hostValueGetAsString(id uint64, index uint32) uint64 95 96 //export hostValueGetAsInt32 97 func hostValueGetAsInt32(id uint64, index uint32) uint32 98 99 //export hostValueGetAsInt64 100 func hostValueGetAsInt64(id uint64, index uint32) uint64 101 102 //export hostValueGetAsFloat32 103 func hostValueGetAsFloat32(id uint64, index uint32) float32 104 105 //export hostValueGetAsFloat64 106 func hostValueGetAsFloat64(id uint64, index uint32) float64 107 108 //export hostValueGetAsValue 109 func hostValueGetAsValue(id uint64, index uint32) uint64 110 111 //export hostValueGetAsQNamePkg 112 func hostValueGetAsQNamePkg(id uint64, index uint32) uint64 113 114 //export hostValueGetAsQNameEntity 115 func hostValueGetAsQNameEntity(id uint64, index uint32) uint64 116 117 //export hostValueGetAsBool 118 func hostValueGetAsBool(id uint64, index uint32) uint64 119 120 //export hostKeyAsString 121 func hostKeyAsString(id uint64, namePtr, nameSize uint32) uint64 122 123 //export hostKeyAsBytes 124 func hostKeyAsBytes(id uint64, namePtr, nameSize uint32) uint64 125 126 //export hostKeyAsQNamePkg 127 func hostKeyAsQNamePkg(id uint64, namePtr, nameSize uint32) uint64 128 129 //export hostKeyAsQNameEntity 130 func hostKeyAsQNameEntity(id uint64, namePtr, nameSize uint32) uint64 131 132 //export hostKeyAsBool 133 func hostKeyAsBool(id uint64, namePtr, nameSize uint32) uint64 134 135 //export hostKeyAsInt32 136 func hostKeyAsInt32(id uint64, namePtr, nameSize uint32) uint32 137 138 //export hostKeyAsInt64 139 func hostKeyAsInt64(id uint64, namePtr, nameSize uint32) uint64 140 141 //export hostKeyAsFloat32 142 func hostKeyAsFloat32(id uint64, namePtr, nameSize uint32) float32 143 144 //export hostKeyAsFloat64 145 func hostKeyAsFloat64(id uint64, namePtr, nameSize uint32) float64 146 147 //export hostReadValues 148 func hostReadValues(keyId uint64) 149 150 //export hostGetValue 151 func hostGetValue(keyId uint64) (result uint64) 152 153 //lint:ignore U1000 this is an exported func 154 //export WasmOnReadValue 155 func onReadValue(key, value uint64) { 156 CurrentReadCallback(isafeapi.TKey(key), isafeapi.TValue(value)) 157 } 158 159 /* 160 returns 0 when not exists 161 */ 162 163 //lint:ignore U1000 this is an exported func 164 //export WasmAbiVersion_0_0_1 165 func proxyABIVersion() { 166 } 167 168 var ms runtime.MemStats 169 170 //lint:ignore U1000 this is an exported func 171 //export WasmGetHeapInuse 172 func getHeapInuse() uint64 { 173 runtime.ReadMemStats(&ms) 174 return ms.HeapInuse 175 } 176 177 //lint:ignore U1000 this is an exported func 178 //export WasmGetMallocs 179 func getMallocs() uint64 { 180 runtime.ReadMemStats(&ms) 181 return ms.Mallocs 182 } 183 184 //lint:ignore U1000 this is an exported func 185 //export WasmGetFrees 186 func getFrees() uint64 { 187 runtime.ReadMemStats(&ms) 188 return ms.Frees 189 } 190 191 //lint:ignore U1000 this is an exported func 192 //export WasmGetHeapSys 193 func getHeapSys() uint64 { 194 runtime.ReadMemStats(&ms) 195 return ms.HeapSys 196 } 197 198 //lint:ignore U1000 this is an exported func 199 //export WasmGC 200 func gc() { 201 runtime.GC() 202 }