-
Notifications
You must be signed in to change notification settings - Fork 1
/
type_traits_numeric.gen.go
executable file
·451 lines (338 loc) · 11.8 KB
/
type_traits_numeric.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
// Code generated by type_traits_numeric.gen.go.tmpl. DO NOT EDIT.
package data
import (
"reflect"
"unsafe"
)
var (
Int64Traits int64Traits
Int32Traits int32Traits
Float64Traits float64Traits
Uint64Traits uint64Traits
Uint32Traits uint32Traits
Float32Traits float32Traits
Int16Traits int16Traits
Uint16Traits uint16Traits
Int8Traits int8Traits
Uint8Traits uint8Traits
)
// Int64 traits
const (
// Int64SizeBytes specifies the number of bytes required to store a single int64 in memory
Int64SizeBytes = int(unsafe.Sizeof(int64(0)))
)
type int64Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (int64Traits) BytesRequired(n int) int { return Int64SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type int64
//
// NOTE: len(b) must be a multiple of Int64SizeBytes
func (int64Traits) CastFromBytes(b []byte) []int64 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []int64
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Int64SizeBytes
s.Cap = h.Cap / Int64SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (int64Traits) CastToBytes(b []int64) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Int64SizeBytes
s.Cap = h.Cap * Int64SizeBytes
return res
}
// Copy copies src to dst
func (int64Traits) Copy(dst, src []int64) { copy(dst, src) }
// Int32 traits
const (
// Int32SizeBytes specifies the number of bytes required to store a single int32 in memory
Int32SizeBytes = int(unsafe.Sizeof(int32(0)))
)
type int32Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (int32Traits) BytesRequired(n int) int { return Int32SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type int32
//
// NOTE: len(b) must be a multiple of Int32SizeBytes
func (int32Traits) CastFromBytes(b []byte) []int32 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []int32
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Int32SizeBytes
s.Cap = h.Cap / Int32SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (int32Traits) CastToBytes(b []int32) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Int32SizeBytes
s.Cap = h.Cap * Int32SizeBytes
return res
}
// Copy copies src to dst
func (int32Traits) Copy(dst, src []int32) { copy(dst, src) }
// Float64 traits
const (
// Float64SizeBytes specifies the number of bytes required to store a single float64 in memory
Float64SizeBytes = int(unsafe.Sizeof(float64(0)))
)
type float64Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (float64Traits) BytesRequired(n int) int { return Float64SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type float64
//
// NOTE: len(b) must be a multiple of Float64SizeBytes
func (float64Traits) CastFromBytes(b []byte) []float64 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []float64
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Float64SizeBytes
s.Cap = h.Cap / Float64SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (float64Traits) CastToBytes(b []float64) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Float64SizeBytes
s.Cap = h.Cap * Float64SizeBytes
return res
}
// Copy copies src to dst
func (float64Traits) Copy(dst, src []float64) { copy(dst, src) }
// Uint64 traits
const (
// Uint64SizeBytes specifies the number of bytes required to store a single uint64 in memory
Uint64SizeBytes = int(unsafe.Sizeof(uint64(0)))
)
type uint64Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (uint64Traits) BytesRequired(n int) int { return Uint64SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type uint64
//
// NOTE: len(b) must be a multiple of Uint64SizeBytes
func (uint64Traits) CastFromBytes(b []byte) []uint64 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []uint64
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Uint64SizeBytes
s.Cap = h.Cap / Uint64SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (uint64Traits) CastToBytes(b []uint64) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Uint64SizeBytes
s.Cap = h.Cap * Uint64SizeBytes
return res
}
// Copy copies src to dst
func (uint64Traits) Copy(dst, src []uint64) { copy(dst, src) }
// Uint32 traits
const (
// Uint32SizeBytes specifies the number of bytes required to store a single uint32 in memory
Uint32SizeBytes = int(unsafe.Sizeof(uint32(0)))
)
type uint32Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (uint32Traits) BytesRequired(n int) int { return Uint32SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type uint32
//
// NOTE: len(b) must be a multiple of Uint32SizeBytes
func (uint32Traits) CastFromBytes(b []byte) []uint32 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []uint32
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Uint32SizeBytes
s.Cap = h.Cap / Uint32SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (uint32Traits) CastToBytes(b []uint32) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Uint32SizeBytes
s.Cap = h.Cap * Uint32SizeBytes
return res
}
// Copy copies src to dst
func (uint32Traits) Copy(dst, src []uint32) { copy(dst, src) }
// Float32 traits
const (
// Float32SizeBytes specifies the number of bytes required to store a single float32 in memory
Float32SizeBytes = int(unsafe.Sizeof(float32(0)))
)
type float32Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (float32Traits) BytesRequired(n int) int { return Float32SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type float32
//
// NOTE: len(b) must be a multiple of Float32SizeBytes
func (float32Traits) CastFromBytes(b []byte) []float32 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []float32
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Float32SizeBytes
s.Cap = h.Cap / Float32SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (float32Traits) CastToBytes(b []float32) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Float32SizeBytes
s.Cap = h.Cap * Float32SizeBytes
return res
}
// Copy copies src to dst
func (float32Traits) Copy(dst, src []float32) { copy(dst, src) }
// Int16 traits
const (
// Int16SizeBytes specifies the number of bytes required to store a single int16 in memory
Int16SizeBytes = int(unsafe.Sizeof(int16(0)))
)
type int16Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (int16Traits) BytesRequired(n int) int { return Int16SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type int16
//
// NOTE: len(b) must be a multiple of Int16SizeBytes
func (int16Traits) CastFromBytes(b []byte) []int16 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []int16
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Int16SizeBytes
s.Cap = h.Cap / Int16SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (int16Traits) CastToBytes(b []int16) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Int16SizeBytes
s.Cap = h.Cap * Int16SizeBytes
return res
}
// Copy copies src to dst
func (int16Traits) Copy(dst, src []int16) { copy(dst, src) }
// Uint16 traits
const (
// Uint16SizeBytes specifies the number of bytes required to store a single uint16 in memory
Uint16SizeBytes = int(unsafe.Sizeof(uint16(0)))
)
type uint16Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (uint16Traits) BytesRequired(n int) int { return Uint16SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type uint16
//
// NOTE: len(b) must be a multiple of Uint16SizeBytes
func (uint16Traits) CastFromBytes(b []byte) []uint16 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []uint16
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Uint16SizeBytes
s.Cap = h.Cap / Uint16SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (uint16Traits) CastToBytes(b []uint16) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Uint16SizeBytes
s.Cap = h.Cap * Uint16SizeBytes
return res
}
// Copy copies src to dst
func (uint16Traits) Copy(dst, src []uint16) { copy(dst, src) }
// Int8 traits
const (
// Int8SizeBytes specifies the number of bytes required to store a single int8 in memory
Int8SizeBytes = int(unsafe.Sizeof(int8(0)))
)
type int8Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (int8Traits) BytesRequired(n int) int { return Int8SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type int8
//
// NOTE: len(b) must be a multiple of Int8SizeBytes
func (int8Traits) CastFromBytes(b []byte) []int8 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []int8
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Int8SizeBytes
s.Cap = h.Cap / Int8SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (int8Traits) CastToBytes(b []int8) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Int8SizeBytes
s.Cap = h.Cap * Int8SizeBytes
return res
}
// Copy copies src to dst
func (int8Traits) Copy(dst, src []int8) { copy(dst, src) }
// Uint8 traits
const (
// Uint8SizeBytes specifies the number of bytes required to store a single uint8 in memory
Uint8SizeBytes = int(unsafe.Sizeof(uint8(0)))
)
type uint8Traits struct{}
// BytesRequired returns the number of bytes required to store n elements in memory
func (uint8Traits) BytesRequired(n int) int { return Uint8SizeBytes * n }
// CastFromBytes reinterprets the slice b to a slice of type uint8
//
// NOTE: len(b) must be a multiple of Uint8SizeBytes
func (uint8Traits) CastFromBytes(b []byte) []uint8 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []uint8
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len / Uint8SizeBytes
s.Cap = h.Cap / Uint8SizeBytes
return res
}
// CastToBytes reinterprets the slice b to a slice of bytes.
func (uint8Traits) CastToBytes(b []uint8) []byte {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
var res []byte
s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
s.Data = h.Data
s.Len = h.Len * Uint8SizeBytes
s.Cap = h.Cap * Uint8SizeBytes
return res
}
// Copy copies src to dst
func (uint8Traits) Copy(dst, src []uint8) { copy(dst, src) }