github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekaunsafe/rtype.go (about) 1 // Copyright © 2020. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekaunsafe 7 8 import ( 9 "github.com/qioalice/ekago/v3/internal/ekaclike" 10 ) 11 12 /* 13 RTypeBool is a "constant" function. 14 Always returns the same value. 15 16 Returns an integer representation of pointer to the type that describes 17 builtin Golang "bool" type. 18 19 Useful along with reflect2.RTypeOf() function. 20 */ 21 //go:inline 22 func RTypeBool() uintptr { return ekaclike.RTypeBool } 23 24 /* 25 RTypeByte is a "constant" function. 26 Always returns the same value. 27 28 Returns an integer representation of pointer to the type that describes 29 builtin Golang "byte" type. 30 31 Useful along with reflect2.RTypeOf() function. 32 */ 33 //go:inline 34 func RTypeByte() uintptr { return ekaclike.RTypeByte } 35 36 /* 37 RTypeRune is a "constant" function. 38 Always returns the same value. 39 40 Returns an integer representation of pointer to the type that describes 41 builtin Golang "rune" type. 42 43 Useful along with reflect2.RTypeOf() function. 44 */ 45 //go:inline 46 func RTypeRune() uintptr { return ekaclike.RTypeRune } 47 48 /* 49 RTypeInt is a "constant" function. 50 Always returns the same value. 51 52 Returns an integer representation of pointer to the type that describes 53 builtin Golang "int" type (not "int8", "int16", "int32", "int64"!) 54 55 Useful along with reflect2.RTypeOf() function. 56 */ 57 //go:inline 58 func RTypeInt() uintptr { return ekaclike.RTypeInt } 59 60 /* 61 RTypeInt8 is a "constant" function. 62 Always returns the same value. 63 64 Returns an integer representation of pointer to the type that describes 65 builtin Golang "int8" type. 66 67 Useful along with reflect2.RTypeOf() function. 68 */ 69 //go:inline 70 func RTypeInt8() uintptr { return ekaclike.RTypeInt8 } 71 72 /* 73 RTypeInt16 is a "constant" function. 74 Always returns the same value. 75 76 Returns an integer representation of pointer to the type that describes 77 builtin Golang "int16" type. 78 79 Useful along with reflect2.RTypeOf() function. 80 */ 81 //go:inline 82 func RTypeInt16() uintptr { return ekaclike.RTypeInt16 } 83 84 /* 85 RTypeInt32 is a "constant" function. 86 Always returns the same value. 87 88 Returns an integer representation of pointer to the type that describes 89 builtin Golang "int32" type. 90 91 Useful along with reflect2.RTypeOf() function. 92 */ 93 //go:inline 94 func RTypeInt32() uintptr { return ekaclike.RTypeInt32 } 95 96 /* 97 RTypeInt64 is a "constant" function. 98 Always returns the same value. 99 100 Returns an integer representation of pointer to the type that describes 101 builtin Golang "int64" type. 102 103 Useful along with reflect2.RTypeOf() function. 104 */ 105 //go:inline 106 func RTypeInt64() uintptr { return ekaclike.RTypeInt64 } 107 108 /* 109 RTypeUint is a "constant" function. 110 Always returns the same value. 111 112 Returns an integer representation of pointer to the type that describes 113 builtin Golang "uint" type (not "uint8", "uint16", "uint32", "uint64"!) 114 115 Useful along with reflect2.RTypeOf() function. 116 */ 117 //go:inline 118 func RTypeUint() uintptr { return ekaclike.RTypeUint } 119 120 /* 121 RTypeUint8 is a "constant" function. 122 Always returns the same value. 123 124 Returns an integer representation of pointer to the type that describes 125 builtin Golang "uint8" type. 126 127 Useful along with reflect2.RTypeOf() function. 128 */ 129 //go:inline 130 func RTypeUint8() uintptr { return ekaclike.RTypeUint8 } 131 132 /* 133 RTypeUint16 is a "constant" function. 134 Always returns the same value. 135 136 Returns an integer representation of pointer to the type that describes 137 builtin Golang "uint16" type. 138 139 Useful along with reflect2.RTypeOf() function. 140 */ 141 //go:inline 142 func RTypeUint16() uintptr { return ekaclike.RTypeUint16 } 143 144 /* 145 RTypeUint32 is a "constant" function. 146 Always returns the same value. 147 148 Returns an integer representation of pointer to the type that describes 149 builtin Golang "uint32" type. 150 151 Useful along with reflect2.RTypeOf() function. 152 */ 153 //go:inline 154 func RTypeUint32() uintptr { return ekaclike.RTypeUint32 } 155 156 /* 157 RTypeUint64 is a "constant" function. 158 Always returns the same value. 159 160 Returns an integer representation of pointer to the type that describes 161 builtin Golang "uint64" type. 162 163 Useful along with reflect2.RTypeOf() function. 164 */ 165 //go:inline 166 func RTypeUint64() uintptr { return ekaclike.RTypeUint64 } 167 168 /* 169 RTypeFloat32 is a "constant" function. 170 Always returns the same value. 171 172 Returns an integer representation of pointer to the type that describes 173 builtin Golang "float32" type. 174 175 Useful along with reflect2.RTypeOf() function. 176 */ 177 //go:inline 178 func RTypeFloat32() uintptr { return ekaclike.RTypeFloat32 } 179 180 /* 181 RTypeFloat64 is a "constant" function. 182 Always returns the same value. 183 184 Returns an integer representation of pointer to the type that describes 185 builtin Golang "float64" type. 186 187 Useful along with reflect2.RTypeOf() function. 188 */ 189 //go:inline 190 func RTypeFloat64() uintptr { return ekaclike.RTypeFloat64 } 191 192 /* 193 RTypeComplex64 is a "constant" function. 194 Always returns the same value. 195 196 Returns an integer representation of pointer to the type that describes 197 builtin Golang "complex64" type. 198 199 Useful along with reflect2.RTypeOf() function. 200 */ 201 //go:inline 202 func RTypeComplex64() uintptr { return ekaclike.RTypeComplex64 } 203 204 /* 205 RTypeComplex128 is a "constant" function. 206 Always returns the same value. 207 208 Returns an integer representation of pointer to the type that describes 209 builtin Golang "complex128" type. 210 211 Useful along with reflect2.RTypeOf() function. 212 */ 213 //go:inline 214 func RTypeComplex128() uintptr { return ekaclike.RTypeComplex128 } 215 216 /* 217 RTypeString is a "constant" function. 218 Always returns the same value. 219 220 Returns an integer representation of pointer to the type that describes 221 builtin Golang "string" type. 222 223 Useful along with reflect2.RTypeOf() function. 224 */ 225 //go:inline 226 func RTypeString() uintptr { return ekaclike.RTypeString } 227 228 /* 229 RTypeStringArray is a "constant" function. 230 Always returns the same value. 231 232 Returns an integer representation of pointer to the type that describes 233 complex Golang "[]string" type. 234 235 Useful along with reflect2.RTypeOf() function. 236 */ 237 //go:inline 238 func RTypeStringArray() uintptr { return ekaclike.RTypeStringArray } 239 240 /* 241 RTypeBytes is a "constant" function. 242 Always returns the same value. 243 244 Returns an integer representation of pointer to the type that describes 245 complex Golang "[]byte" type. 246 247 Useful along with reflect2.RTypeOf() function. 248 */ 249 //go:inline 250 func RTypeBytes() uintptr { return ekaclike.RTypeBytes } 251 252 /* 253 RTypeBytesArray is a "constant" function. 254 Always returns the same value. 255 256 Returns an integer representation of pointer to the type that describes 257 complex Golang "[][]byte" type. 258 259 Useful along with reflect2.RTypeOf() function. 260 */ 261 //go:inline 262 func RTypeBytesArray() uintptr { return ekaclike.RTypeBytesArray } 263 264 /* 265 RTypeMapStringString is a "constant" function. 266 Always returns the same value. 267 268 Returns an integer representation of pointer to the type that describes 269 complex Golang "map[string]string" type. 270 271 Useful along with reflect2.RTypeOf() function. 272 */ 273 //go:inline 274 func RTypeMapStringString() uintptr { return ekaclike.RTypeMapStringString } 275 276 /* 277 RTypeMapStringInterface is a "constant" function. 278 Always returns the same value. 279 280 Returns an integer representation of pointer to the type that describes 281 complex Golang "map[string]any" type. 282 283 Useful along with reflect2.RTypeOf() function. 284 */ 285 //go:inline 286 func RTypeMapStringInterface() uintptr { return ekaclike.RTypeMapStringInterface } 287 288 /* 289 RTypeIsAnyNumeric returns true if passed rtype is any of signed or unsigned integers. 290 It means, that it's true for 291 - int, int8, int16, int32, int64, 292 - uint, uint8, uint16, uint32, uint64 293 but it also is true for 294 - byte (because it's Golang alias to uint8), 295 - rune (because it's Golang alias to int32). 296 */ 297 //go:inline 298 func RTypeIsAnyNumeric(rtype uintptr) bool { 299 return RTypeIsIntAny(rtype) || RTypeIsUintAny(rtype) 300 } 301 302 /* 303 RTypeIsAnyReal returns true if passed rtype is any of signed or unsigned integers 304 or floats. 305 It means that it's true for 306 - int, int8, int16, int32, int64, 307 - uint, uint8, uint16, uint32, uint64, 308 - float32, float64 309 but it also is true for 310 - byte (because it's Golang alias to uint8), 311 - rune (because it's Golang alias to int32). 312 */ 313 //go:inline 314 func RTypeIsAnyReal(rtype uintptr) bool { 315 return RTypeIsAnyNumeric(rtype) || RTypeIsFloatAny(rtype) 316 } 317 318 /* 319 RTypeIsIntAny returns true if passed rtype is any of signed integers only. 320 It means that it's true for int, int8, int16, int32, int64, 321 but it also true for rune, because it's Golang alias for int32. 322 */ 323 //go:inline 324 func RTypeIsIntAny(rtype uintptr) bool { 325 return rtype == ekaclike.RTypeInt || RTypeIsIntFixed(rtype) 326 } 327 328 /* 329 RTypeIsIntFixed returns true if passed rtype is any of signed fixed length integers only. 330 It means that it's true for int8, int16, int32, int64, 331 but it also true for rune, because it's Golang alias for int32. 332 333 NOTE! 334 Again. It false for just "int"! 335 */ 336 //go:inline 337 func RTypeIsIntFixed(rtype uintptr) bool { 338 switch rtype { 339 case ekaclike.RTypeInt8, ekaclike.RTypeInt16, ekaclike.RTypeInt32, ekaclike.RTypeInt64: 340 return true 341 default: 342 return false 343 } 344 } 345 346 /* 347 RTypeIsUintAny returns true if passed rtype is any of unsigned integers only. 348 It means that it's true for uint, uint8, uint16, uint32, uint64, 349 but it also true for byte, because it's Golang alias for uint8. 350 */ 351 //go:inline 352 func RTypeIsUintAny(rtype uintptr) bool { 353 return rtype == ekaclike.RTypeUint || RTypeIsUintFixed(rtype) 354 } 355 356 /* 357 RTypeIsUintFixed returns true if passed rtype is any of unsigned fixed length integers only. 358 It means that it's true for uint8, uint16, uint32, uint64, 359 but it also true for byte, because it's Golang alias for uint8. 360 361 NOTE! 362 Again. It false for just "uint"! 363 */ 364 //go:inline 365 func RTypeIsUintFixed(rtype uintptr) bool { 366 switch rtype { 367 case ekaclike.RTypeUint8, ekaclike.RTypeUint16, ekaclike.RTypeUint32, ekaclike.RTypeUint64: 368 return true 369 default: 370 return false 371 } 372 } 373 374 /* 375 RTypeIsFloatAny returns true if passed rtype is any of floats only. 376 It means that it's true for float32, float64. 377 */ 378 //go:inline 379 func RTypeIsFloatAny(rtype uintptr) bool { 380 switch rtype { 381 case ekaclike.RTypeFloat32, ekaclike.RTypeFloat64: 382 return true 383 default: 384 return false 385 } 386 } 387 388 /* 389 RTypeIsComplexAny returns true if passed rtype is any of complexes only. 390 It means that it's true for complex64, complex128. 391 */ 392 func RTypeIsComplexAny(rtype uintptr) bool { 393 switch rtype { 394 case ekaclike.RTypeComplex64, ekaclike.RTypeComplex128: 395 return true 396 default: 397 return false 398 } 399 }