1 // Code generated by go run encgen.go -output enc_helpers.go; DO NOT EDIT.
3 // Copyright 2014 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
13 var encArrayHelper
= map[reflect
.Kind
]encHelper
{
14 reflect
.Bool
: encBoolArray
,
15 reflect
.Complex64
: encComplex64Array
,
16 reflect
.Complex128
: encComplex128Array
,
17 reflect
.Float32
: encFloat32Array
,
18 reflect
.Float64
: encFloat64Array
,
19 reflect
.Int
: encIntArray
,
20 reflect
.Int16
: encInt16Array
,
21 reflect
.Int32
: encInt32Array
,
22 reflect
.Int64
: encInt64Array
,
23 reflect
.Int8
: encInt8Array
,
24 reflect
.String
: encStringArray
,
25 reflect
.Uint
: encUintArray
,
26 reflect
.Uint16
: encUint16Array
,
27 reflect
.Uint32
: encUint32Array
,
28 reflect
.Uint64
: encUint64Array
,
29 reflect
.Uintptr
: encUintptrArray
,
32 var encSliceHelper
= map[reflect
.Kind
]encHelper
{
33 reflect
.Bool
: encBoolSlice
,
34 reflect
.Complex64
: encComplex64Slice
,
35 reflect
.Complex128
: encComplex128Slice
,
36 reflect
.Float32
: encFloat32Slice
,
37 reflect
.Float64
: encFloat64Slice
,
38 reflect
.Int
: encIntSlice
,
39 reflect
.Int16
: encInt16Slice
,
40 reflect
.Int32
: encInt32Slice
,
41 reflect
.Int64
: encInt64Slice
,
42 reflect
.Int8
: encInt8Slice
,
43 reflect
.String
: encStringSlice
,
44 reflect
.Uint
: encUintSlice
,
45 reflect
.Uint16
: encUint16Slice
,
46 reflect
.Uint32
: encUint32Slice
,
47 reflect
.Uint64
: encUint64Slice
,
48 reflect
.Uintptr
: encUintptrSlice
,
51 func encBoolArray(state
*encoderState
, v reflect
.Value
) bool {
52 // Can only slice if it is addressable.
56 return encBoolSlice(state
, v
.Slice(0, v
.Len()))
59 func encBoolSlice(state
*encoderState
, v reflect
.Value
) bool {
60 slice
, ok
:= v
.Interface().([]bool)
62 // It is kind bool but not type bool. TODO: We can handle this unsafely.
65 for _
, x
:= range slice
{
66 if x
!= false || state
.sendZero
{
77 func encComplex64Array(state
*encoderState
, v reflect
.Value
) bool {
78 // Can only slice if it is addressable.
82 return encComplex64Slice(state
, v
.Slice(0, v
.Len()))
85 func encComplex64Slice(state
*encoderState
, v reflect
.Value
) bool {
86 slice
, ok
:= v
.Interface().([]complex64
)
88 // It is kind complex64 but not type complex64. TODO: We can handle this unsafely.
91 for _
, x
:= range slice
{
92 if x
!= 0+0i || state
.sendZero
{
93 rpart
:= floatBits(float64(real(x
)))
94 ipart
:= floatBits(float64(imag(x
)))
95 state
.encodeUint(rpart
)
96 state
.encodeUint(ipart
)
102 func encComplex128Array(state
*encoderState
, v reflect
.Value
) bool {
103 // Can only slice if it is addressable.
107 return encComplex128Slice(state
, v
.Slice(0, v
.Len()))
110 func encComplex128Slice(state
*encoderState
, v reflect
.Value
) bool {
111 slice
, ok
:= v
.Interface().([]complex128
)
113 // It is kind complex128 but not type complex128. TODO: We can handle this unsafely.
116 for _
, x
:= range slice
{
117 if x
!= 0+0i || state
.sendZero
{
118 rpart
:= floatBits(real(x
))
119 ipart
:= floatBits(imag(x
))
120 state
.encodeUint(rpart
)
121 state
.encodeUint(ipart
)
127 func encFloat32Array(state
*encoderState
, v reflect
.Value
) bool {
128 // Can only slice if it is addressable.
132 return encFloat32Slice(state
, v
.Slice(0, v
.Len()))
135 func encFloat32Slice(state
*encoderState
, v reflect
.Value
) bool {
136 slice
, ok
:= v
.Interface().([]float32)
138 // It is kind float32 but not type float32. TODO: We can handle this unsafely.
141 for _
, x
:= range slice
{
142 if x
!= 0 || state
.sendZero
{
143 bits
:= floatBits(float64(x
))
144 state
.encodeUint(bits
)
150 func encFloat64Array(state
*encoderState
, v reflect
.Value
) bool {
151 // Can only slice if it is addressable.
155 return encFloat64Slice(state
, v
.Slice(0, v
.Len()))
158 func encFloat64Slice(state
*encoderState
, v reflect
.Value
) bool {
159 slice
, ok
:= v
.Interface().([]float64)
161 // It is kind float64 but not type float64. TODO: We can handle this unsafely.
164 for _
, x
:= range slice
{
165 if x
!= 0 || state
.sendZero
{
167 state
.encodeUint(bits
)
173 func encIntArray(state
*encoderState
, v reflect
.Value
) bool {
174 // Can only slice if it is addressable.
178 return encIntSlice(state
, v
.Slice(0, v
.Len()))
181 func encIntSlice(state
*encoderState
, v reflect
.Value
) bool {
182 slice
, ok
:= v
.Interface().([]int)
184 // It is kind int but not type int. TODO: We can handle this unsafely.
187 for _
, x
:= range slice
{
188 if x
!= 0 || state
.sendZero
{
189 state
.encodeInt(int64(x
))
195 func encInt16Array(state
*encoderState
, v reflect
.Value
) bool {
196 // Can only slice if it is addressable.
200 return encInt16Slice(state
, v
.Slice(0, v
.Len()))
203 func encInt16Slice(state
*encoderState
, v reflect
.Value
) bool {
204 slice
, ok
:= v
.Interface().([]int16)
206 // It is kind int16 but not type int16. TODO: We can handle this unsafely.
209 for _
, x
:= range slice
{
210 if x
!= 0 || state
.sendZero
{
211 state
.encodeInt(int64(x
))
217 func encInt32Array(state
*encoderState
, v reflect
.Value
) bool {
218 // Can only slice if it is addressable.
222 return encInt32Slice(state
, v
.Slice(0, v
.Len()))
225 func encInt32Slice(state
*encoderState
, v reflect
.Value
) bool {
226 slice
, ok
:= v
.Interface().([]int32)
228 // It is kind int32 but not type int32. TODO: We can handle this unsafely.
231 for _
, x
:= range slice
{
232 if x
!= 0 || state
.sendZero
{
233 state
.encodeInt(int64(x
))
239 func encInt64Array(state
*encoderState
, v reflect
.Value
) bool {
240 // Can only slice if it is addressable.
244 return encInt64Slice(state
, v
.Slice(0, v
.Len()))
247 func encInt64Slice(state
*encoderState
, v reflect
.Value
) bool {
248 slice
, ok
:= v
.Interface().([]int64)
250 // It is kind int64 but not type int64. TODO: We can handle this unsafely.
253 for _
, x
:= range slice
{
254 if x
!= 0 || state
.sendZero
{
261 func encInt8Array(state
*encoderState
, v reflect
.Value
) bool {
262 // Can only slice if it is addressable.
266 return encInt8Slice(state
, v
.Slice(0, v
.Len()))
269 func encInt8Slice(state
*encoderState
, v reflect
.Value
) bool {
270 slice
, ok
:= v
.Interface().([]int8)
272 // It is kind int8 but not type int8. TODO: We can handle this unsafely.
275 for _
, x
:= range slice
{
276 if x
!= 0 || state
.sendZero
{
277 state
.encodeInt(int64(x
))
283 func encStringArray(state
*encoderState
, v reflect
.Value
) bool {
284 // Can only slice if it is addressable.
288 return encStringSlice(state
, v
.Slice(0, v
.Len()))
291 func encStringSlice(state
*encoderState
, v reflect
.Value
) bool {
292 slice
, ok
:= v
.Interface().([]string)
294 // It is kind string but not type string. TODO: We can handle this unsafely.
297 for _
, x
:= range slice
{
298 if x
!= "" || state
.sendZero
{
299 state
.encodeUint(uint64(len(x
)))
300 state
.b
.WriteString(x
)
306 func encUintArray(state
*encoderState
, v reflect
.Value
) bool {
307 // Can only slice if it is addressable.
311 return encUintSlice(state
, v
.Slice(0, v
.Len()))
314 func encUintSlice(state
*encoderState
, v reflect
.Value
) bool {
315 slice
, ok
:= v
.Interface().([]uint)
317 // It is kind uint but not type uint. TODO: We can handle this unsafely.
320 for _
, x
:= range slice
{
321 if x
!= 0 || state
.sendZero
{
322 state
.encodeUint(uint64(x
))
328 func encUint16Array(state
*encoderState
, v reflect
.Value
) bool {
329 // Can only slice if it is addressable.
333 return encUint16Slice(state
, v
.Slice(0, v
.Len()))
336 func encUint16Slice(state
*encoderState
, v reflect
.Value
) bool {
337 slice
, ok
:= v
.Interface().([]uint16)
339 // It is kind uint16 but not type uint16. TODO: We can handle this unsafely.
342 for _
, x
:= range slice
{
343 if x
!= 0 || state
.sendZero
{
344 state
.encodeUint(uint64(x
))
350 func encUint32Array(state
*encoderState
, v reflect
.Value
) bool {
351 // Can only slice if it is addressable.
355 return encUint32Slice(state
, v
.Slice(0, v
.Len()))
358 func encUint32Slice(state
*encoderState
, v reflect
.Value
) bool {
359 slice
, ok
:= v
.Interface().([]uint32)
361 // It is kind uint32 but not type uint32. TODO: We can handle this unsafely.
364 for _
, x
:= range slice
{
365 if x
!= 0 || state
.sendZero
{
366 state
.encodeUint(uint64(x
))
372 func encUint64Array(state
*encoderState
, v reflect
.Value
) bool {
373 // Can only slice if it is addressable.
377 return encUint64Slice(state
, v
.Slice(0, v
.Len()))
380 func encUint64Slice(state
*encoderState
, v reflect
.Value
) bool {
381 slice
, ok
:= v
.Interface().([]uint64)
383 // It is kind uint64 but not type uint64. TODO: We can handle this unsafely.
386 for _
, x
:= range slice
{
387 if x
!= 0 || state
.sendZero
{
394 func encUintptrArray(state
*encoderState
, v reflect
.Value
) bool {
395 // Can only slice if it is addressable.
399 return encUintptrSlice(state
, v
.Slice(0, v
.Len()))
402 func encUintptrSlice(state
*encoderState
, v reflect
.Value
) bool {
403 slice
, ok
:= v
.Interface().([]uintptr)
405 // It is kind uintptr but not type uintptr. TODO: We can handle this unsafely.
408 for _
, x
:= range slice
{
409 if x
!= 0 || state
.sendZero
{
410 state
.encodeUint(uint64(x
))