blob: 46380f57d6d05554bca236623a72c054891f8afa [file] [log] [blame]
Damien Neilc37adef2019-04-01 13:49:56 -07001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style.
3// license that can be found in the LICENSE file.
4
5// Code generated by generate-types. DO NOT EDIT.
6
7package impl
8
9import (
10 "math"
Joe Tsaic51e2e02019-07-13 00:44:41 -070011 "unicode/utf8"
Damien Neilc37adef2019-04-01 13:49:56 -070012
13 "google.golang.org/protobuf/internal/encoding/wire"
14 "google.golang.org/protobuf/reflect/protoreflect"
15)
16
17// sizeBool returns the size of wire encoding a bool pointer as a Bool.
18func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
19 v := *p.Bool()
20 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
21}
22
23// appendBool wire encodes a bool pointer as a Bool.
24func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
25 v := *p.Bool()
26 b = wire.AppendVarint(b, wiretag)
27 b = wire.AppendVarint(b, wire.EncodeBool(v))
28 return b, nil
29}
30
Damien Neile91877d2019-06-27 10:54:42 -070031// consumeBool wire decodes a bool pointer as a Bool.
32func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
33 if wtyp != wire.VarintType {
34 return 0, errUnknown
35 }
36 v, n := wire.ConsumeVarint(b)
37 if n < 0 {
38 return 0, wire.ParseError(n)
39 }
40 *p.Bool() = wire.DecodeBool(v)
41 return n, nil
42}
43
Damien Neilc37adef2019-04-01 13:49:56 -070044var coderBool = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070045 size: sizeBool,
46 marshal: appendBool,
47 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070048}
49
Joe Tsaic51e2e02019-07-13 00:44:41 -070050// sizeBoolNoZero returns the size of wire encoding a bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070051// The zero value is not encoded.
52func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
53 v := *p.Bool()
54 if v == false {
55 return 0
56 }
57 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
58}
59
Joe Tsaic51e2e02019-07-13 00:44:41 -070060// appendBoolNoZero wire encodes a bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070061// The zero value is not encoded.
62func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
63 v := *p.Bool()
64 if v == false {
65 return b, nil
66 }
67 b = wire.AppendVarint(b, wiretag)
68 b = wire.AppendVarint(b, wire.EncodeBool(v))
69 return b, nil
70}
71
72var coderBoolNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070073 size: sizeBoolNoZero,
74 marshal: appendBoolNoZero,
75 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070076}
77
78// sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
79// It panics if the pointer is nil.
80func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
81 v := **p.BoolPtr()
82 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
83}
84
Damien Neile91877d2019-06-27 10:54:42 -070085// appendBoolPtr wire encodes a *bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070086// It panics if the pointer is nil.
87func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
88 v := **p.BoolPtr()
89 b = wire.AppendVarint(b, wiretag)
90 b = wire.AppendVarint(b, wire.EncodeBool(v))
91 return b, nil
92}
93
Damien Neile91877d2019-06-27 10:54:42 -070094// consumeBoolPtr wire decodes a *bool pointer as a Bool.
95func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
96 if wtyp != wire.VarintType {
97 return 0, errUnknown
98 }
99 v, n := wire.ConsumeVarint(b)
100 if n < 0 {
101 return 0, wire.ParseError(n)
102 }
103 vp := p.BoolPtr()
104 if *vp == nil {
105 *vp = new(bool)
106 }
107 **vp = wire.DecodeBool(v)
108 return n, nil
109}
110
Damien Neilc37adef2019-04-01 13:49:56 -0700111var coderBoolPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700112 size: sizeBoolPtr,
113 marshal: appendBoolPtr,
114 unmarshal: consumeBoolPtr,
Damien Neilc37adef2019-04-01 13:49:56 -0700115}
116
117// sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
118func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
119 s := *p.BoolSlice()
120 for _, v := range s {
121 size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
122 }
123 return size
124}
125
126// appendBoolSlice encodes a []bool pointer as a repeated Bool.
127func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
128 s := *p.BoolSlice()
129 for _, v := range s {
130 b = wire.AppendVarint(b, wiretag)
131 b = wire.AppendVarint(b, wire.EncodeBool(v))
132 }
133 return b, nil
134}
135
Damien Neile91877d2019-06-27 10:54:42 -0700136// consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
137func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
138 sp := p.BoolSlice()
139 if wtyp == wire.BytesType {
140 s := *sp
141 b, n = wire.ConsumeBytes(b)
142 if n < 0 {
143 return 0, wire.ParseError(n)
144 }
145 for len(b) > 0 {
146 v, n := wire.ConsumeVarint(b)
147 if n < 0 {
148 return 0, wire.ParseError(n)
149 }
150 s = append(s, wire.DecodeBool(v))
151 b = b[n:]
152 }
153 *sp = s
154 return n, nil
155 }
156 if wtyp != wire.VarintType {
157 return 0, errUnknown
158 }
159 v, n := wire.ConsumeVarint(b)
160 if n < 0 {
161 return 0, wire.ParseError(n)
162 }
163 *sp = append(*sp, wire.DecodeBool(v))
164 return n, nil
165}
166
Damien Neilc37adef2019-04-01 13:49:56 -0700167var coderBoolSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700168 size: sizeBoolSlice,
169 marshal: appendBoolSlice,
170 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700171}
172
173// sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
174func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
175 s := *p.BoolSlice()
176 if len(s) == 0 {
177 return 0
178 }
179 n := 0
180 for _, v := range s {
181 n += wire.SizeVarint(wire.EncodeBool(v))
182 }
183 return tagsize + wire.SizeBytes(n)
184}
185
186// appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
187func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
188 s := *p.BoolSlice()
189 if len(s) == 0 {
190 return b, nil
191 }
192 b = wire.AppendVarint(b, wiretag)
193 n := 0
194 for _, v := range s {
195 n += wire.SizeVarint(wire.EncodeBool(v))
196 }
197 b = wire.AppendVarint(b, uint64(n))
198 for _, v := range s {
199 b = wire.AppendVarint(b, wire.EncodeBool(v))
200 }
201 return b, nil
202}
203
204var coderBoolPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700205 size: sizeBoolPackedSlice,
206 marshal: appendBoolPackedSlice,
207 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700208}
209
210// sizeBoolIface returns the size of wire encoding a bool value as a Bool.
211func sizeBoolIface(ival interface{}, tagsize int, _ marshalOptions) int {
212 v := ival.(bool)
213 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
214}
215
216// appendBoolIface encodes a bool value as a Bool.
217func appendBoolIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
218 v := ival.(bool)
219 b = wire.AppendVarint(b, wiretag)
220 b = wire.AppendVarint(b, wire.EncodeBool(v))
221 return b, nil
222}
223
Damien Neile91877d2019-06-27 10:54:42 -0700224// consumeBoolIface decodes a bool value as a Bool.
225func consumeBoolIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
226 if wtyp != wire.VarintType {
227 return nil, 0, errUnknown
228 }
229 v, n := wire.ConsumeVarint(b)
230 if n < 0 {
231 return nil, 0, wire.ParseError(n)
232 }
233 return wire.DecodeBool(v), n, nil
234}
235
Damien Neilc37adef2019-04-01 13:49:56 -0700236var coderBoolIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700237 size: sizeBoolIface,
238 marshal: appendBoolIface,
239 unmarshal: consumeBoolIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700240}
241
242// sizeBoolSliceIface returns the size of wire encoding a []bool value as a repeated Bool.
243func sizeBoolSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
244 s := *ival.(*[]bool)
245 for _, v := range s {
246 size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
247 }
248 return size
249}
250
251// appendBoolSliceIface encodes a []bool value as a repeated Bool.
252func appendBoolSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
253 s := *ival.(*[]bool)
254 for _, v := range s {
255 b = wire.AppendVarint(b, wiretag)
256 b = wire.AppendVarint(b, wire.EncodeBool(v))
257 }
258 return b, nil
259}
260
Damien Neile91877d2019-06-27 10:54:42 -0700261// consumeBoolSliceIface wire decodes a []bool value as a repeated Bool.
262func consumeBoolSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
263 sp := ival.(*[]bool)
264 if wtyp == wire.BytesType {
265 s := *sp
266 b, n = wire.ConsumeBytes(b)
267 if n < 0 {
268 return nil, 0, wire.ParseError(n)
269 }
270 for len(b) > 0 {
271 v, n := wire.ConsumeVarint(b)
272 if n < 0 {
273 return nil, 0, wire.ParseError(n)
274 }
275 s = append(s, wire.DecodeBool(v))
276 b = b[n:]
277 }
278 *sp = s
279 return ival, n, nil
280 }
281 if wtyp != wire.VarintType {
282 return nil, 0, errUnknown
283 }
284 v, n := wire.ConsumeVarint(b)
285 if n < 0 {
286 return nil, 0, wire.ParseError(n)
287 }
288 *sp = append(*sp, wire.DecodeBool(v))
289 return ival, n, nil
290}
291
Damien Neilc37adef2019-04-01 13:49:56 -0700292var coderBoolSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700293 size: sizeBoolSliceIface,
294 marshal: appendBoolSliceIface,
295 unmarshal: consumeBoolSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700296}
297
Damien Neil7492a092019-07-10 15:23:29 -0700298// sizeBoolPackedSliceIface returns the size of wire encoding a []bool value as a packed repeated Bool.
299func sizeBoolPackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
300 s := *ival.(*[]bool)
301 if len(s) == 0 {
302 return 0
303 }
304 n := 0
305 for _, v := range s {
306 n += wire.SizeVarint(wire.EncodeBool(v))
307 }
308 return tagsize + wire.SizeBytes(n)
309}
310
311// appendBoolPackedSliceIface encodes a []bool value as a packed repeated Bool.
312func appendBoolPackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
313 s := *ival.(*[]bool)
314 if len(s) == 0 {
315 return b, nil
316 }
317 b = wire.AppendVarint(b, wiretag)
318 n := 0
319 for _, v := range s {
320 n += wire.SizeVarint(wire.EncodeBool(v))
321 }
322 b = wire.AppendVarint(b, uint64(n))
323 for _, v := range s {
324 b = wire.AppendVarint(b, wire.EncodeBool(v))
325 }
326 return b, nil
327}
328
329var coderBoolPackedSliceIface = ifaceCoderFuncs{
330 size: sizeBoolPackedSliceIface,
331 marshal: appendBoolPackedSliceIface,
332 unmarshal: consumeBoolSliceIface,
333}
334
Damien Neilc37adef2019-04-01 13:49:56 -0700335// sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
336func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
337 v := *p.Int32()
338 return tagsize + wire.SizeVarint(uint64(v))
339}
340
341// appendInt32 wire encodes a int32 pointer as a Int32.
342func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
343 v := *p.Int32()
344 b = wire.AppendVarint(b, wiretag)
345 b = wire.AppendVarint(b, uint64(v))
346 return b, nil
347}
348
Damien Neile91877d2019-06-27 10:54:42 -0700349// consumeInt32 wire decodes a int32 pointer as a Int32.
350func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
351 if wtyp != wire.VarintType {
352 return 0, errUnknown
353 }
354 v, n := wire.ConsumeVarint(b)
355 if n < 0 {
356 return 0, wire.ParseError(n)
357 }
358 *p.Int32() = int32(v)
359 return n, nil
360}
361
Damien Neilc37adef2019-04-01 13:49:56 -0700362var coderInt32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700363 size: sizeInt32,
364 marshal: appendInt32,
365 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700366}
367
Joe Tsaic51e2e02019-07-13 00:44:41 -0700368// sizeInt32NoZero returns the size of wire encoding a int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700369// The zero value is not encoded.
370func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
371 v := *p.Int32()
372 if v == 0 {
373 return 0
374 }
375 return tagsize + wire.SizeVarint(uint64(v))
376}
377
Joe Tsaic51e2e02019-07-13 00:44:41 -0700378// appendInt32NoZero wire encodes a int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700379// The zero value is not encoded.
380func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
381 v := *p.Int32()
382 if v == 0 {
383 return b, nil
384 }
385 b = wire.AppendVarint(b, wiretag)
386 b = wire.AppendVarint(b, uint64(v))
387 return b, nil
388}
389
390var coderInt32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700391 size: sizeInt32NoZero,
392 marshal: appendInt32NoZero,
393 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700394}
395
396// sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
397// It panics if the pointer is nil.
398func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
399 v := **p.Int32Ptr()
400 return tagsize + wire.SizeVarint(uint64(v))
401}
402
Damien Neile91877d2019-06-27 10:54:42 -0700403// appendInt32Ptr wire encodes a *int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700404// It panics if the pointer is nil.
405func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
406 v := **p.Int32Ptr()
407 b = wire.AppendVarint(b, wiretag)
408 b = wire.AppendVarint(b, uint64(v))
409 return b, nil
410}
411
Damien Neile91877d2019-06-27 10:54:42 -0700412// consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
413func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
414 if wtyp != wire.VarintType {
415 return 0, errUnknown
416 }
417 v, n := wire.ConsumeVarint(b)
418 if n < 0 {
419 return 0, wire.ParseError(n)
420 }
421 vp := p.Int32Ptr()
422 if *vp == nil {
423 *vp = new(int32)
424 }
425 **vp = int32(v)
426 return n, nil
427}
428
Damien Neilc37adef2019-04-01 13:49:56 -0700429var coderInt32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700430 size: sizeInt32Ptr,
431 marshal: appendInt32Ptr,
432 unmarshal: consumeInt32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700433}
434
435// sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
436func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
437 s := *p.Int32Slice()
438 for _, v := range s {
439 size += tagsize + wire.SizeVarint(uint64(v))
440 }
441 return size
442}
443
444// appendInt32Slice encodes a []int32 pointer as a repeated Int32.
445func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
446 s := *p.Int32Slice()
447 for _, v := range s {
448 b = wire.AppendVarint(b, wiretag)
449 b = wire.AppendVarint(b, uint64(v))
450 }
451 return b, nil
452}
453
Damien Neile91877d2019-06-27 10:54:42 -0700454// consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
455func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
456 sp := p.Int32Slice()
457 if wtyp == wire.BytesType {
458 s := *sp
459 b, n = wire.ConsumeBytes(b)
460 if n < 0 {
461 return 0, wire.ParseError(n)
462 }
463 for len(b) > 0 {
464 v, n := wire.ConsumeVarint(b)
465 if n < 0 {
466 return 0, wire.ParseError(n)
467 }
468 s = append(s, int32(v))
469 b = b[n:]
470 }
471 *sp = s
472 return n, nil
473 }
474 if wtyp != wire.VarintType {
475 return 0, errUnknown
476 }
477 v, n := wire.ConsumeVarint(b)
478 if n < 0 {
479 return 0, wire.ParseError(n)
480 }
481 *sp = append(*sp, int32(v))
482 return n, nil
483}
484
Damien Neilc37adef2019-04-01 13:49:56 -0700485var coderInt32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700486 size: sizeInt32Slice,
487 marshal: appendInt32Slice,
488 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700489}
490
491// sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
492func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
493 s := *p.Int32Slice()
494 if len(s) == 0 {
495 return 0
496 }
497 n := 0
498 for _, v := range s {
499 n += wire.SizeVarint(uint64(v))
500 }
501 return tagsize + wire.SizeBytes(n)
502}
503
504// appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
505func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
506 s := *p.Int32Slice()
507 if len(s) == 0 {
508 return b, nil
509 }
510 b = wire.AppendVarint(b, wiretag)
511 n := 0
512 for _, v := range s {
513 n += wire.SizeVarint(uint64(v))
514 }
515 b = wire.AppendVarint(b, uint64(n))
516 for _, v := range s {
517 b = wire.AppendVarint(b, uint64(v))
518 }
519 return b, nil
520}
521
522var coderInt32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700523 size: sizeInt32PackedSlice,
524 marshal: appendInt32PackedSlice,
525 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700526}
527
528// sizeInt32Iface returns the size of wire encoding a int32 value as a Int32.
529func sizeInt32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
530 v := ival.(int32)
531 return tagsize + wire.SizeVarint(uint64(v))
532}
533
534// appendInt32Iface encodes a int32 value as a Int32.
535func appendInt32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
536 v := ival.(int32)
537 b = wire.AppendVarint(b, wiretag)
538 b = wire.AppendVarint(b, uint64(v))
539 return b, nil
540}
541
Damien Neile91877d2019-06-27 10:54:42 -0700542// consumeInt32Iface decodes a int32 value as a Int32.
543func consumeInt32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
544 if wtyp != wire.VarintType {
545 return nil, 0, errUnknown
546 }
547 v, n := wire.ConsumeVarint(b)
548 if n < 0 {
549 return nil, 0, wire.ParseError(n)
550 }
551 return int32(v), n, nil
552}
553
Damien Neilc37adef2019-04-01 13:49:56 -0700554var coderInt32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700555 size: sizeInt32Iface,
556 marshal: appendInt32Iface,
557 unmarshal: consumeInt32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -0700558}
559
560// sizeInt32SliceIface returns the size of wire encoding a []int32 value as a repeated Int32.
561func sizeInt32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
562 s := *ival.(*[]int32)
563 for _, v := range s {
564 size += tagsize + wire.SizeVarint(uint64(v))
565 }
566 return size
567}
568
569// appendInt32SliceIface encodes a []int32 value as a repeated Int32.
570func appendInt32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
571 s := *ival.(*[]int32)
572 for _, v := range s {
573 b = wire.AppendVarint(b, wiretag)
574 b = wire.AppendVarint(b, uint64(v))
575 }
576 return b, nil
577}
578
Damien Neile91877d2019-06-27 10:54:42 -0700579// consumeInt32SliceIface wire decodes a []int32 value as a repeated Int32.
580func consumeInt32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
581 sp := ival.(*[]int32)
582 if wtyp == wire.BytesType {
583 s := *sp
584 b, n = wire.ConsumeBytes(b)
585 if n < 0 {
586 return nil, 0, wire.ParseError(n)
587 }
588 for len(b) > 0 {
589 v, n := wire.ConsumeVarint(b)
590 if n < 0 {
591 return nil, 0, wire.ParseError(n)
592 }
593 s = append(s, int32(v))
594 b = b[n:]
595 }
596 *sp = s
597 return ival, n, nil
598 }
599 if wtyp != wire.VarintType {
600 return nil, 0, errUnknown
601 }
602 v, n := wire.ConsumeVarint(b)
603 if n < 0 {
604 return nil, 0, wire.ParseError(n)
605 }
606 *sp = append(*sp, int32(v))
607 return ival, n, nil
608}
609
Damien Neilc37adef2019-04-01 13:49:56 -0700610var coderInt32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700611 size: sizeInt32SliceIface,
612 marshal: appendInt32SliceIface,
613 unmarshal: consumeInt32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700614}
615
Damien Neil7492a092019-07-10 15:23:29 -0700616// sizeInt32PackedSliceIface returns the size of wire encoding a []int32 value as a packed repeated Int32.
617func sizeInt32PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
618 s := *ival.(*[]int32)
619 if len(s) == 0 {
620 return 0
621 }
622 n := 0
623 for _, v := range s {
624 n += wire.SizeVarint(uint64(v))
625 }
626 return tagsize + wire.SizeBytes(n)
627}
628
629// appendInt32PackedSliceIface encodes a []int32 value as a packed repeated Int32.
630func appendInt32PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
631 s := *ival.(*[]int32)
632 if len(s) == 0 {
633 return b, nil
634 }
635 b = wire.AppendVarint(b, wiretag)
636 n := 0
637 for _, v := range s {
638 n += wire.SizeVarint(uint64(v))
639 }
640 b = wire.AppendVarint(b, uint64(n))
641 for _, v := range s {
642 b = wire.AppendVarint(b, uint64(v))
643 }
644 return b, nil
645}
646
647var coderInt32PackedSliceIface = ifaceCoderFuncs{
648 size: sizeInt32PackedSliceIface,
649 marshal: appendInt32PackedSliceIface,
650 unmarshal: consumeInt32SliceIface,
651}
652
Damien Neilc37adef2019-04-01 13:49:56 -0700653// sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
654func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
655 v := *p.Int32()
656 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
657}
658
659// appendSint32 wire encodes a int32 pointer as a Sint32.
660func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
661 v := *p.Int32()
662 b = wire.AppendVarint(b, wiretag)
663 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
664 return b, nil
665}
666
Damien Neile91877d2019-06-27 10:54:42 -0700667// consumeSint32 wire decodes a int32 pointer as a Sint32.
668func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
669 if wtyp != wire.VarintType {
670 return 0, errUnknown
671 }
672 v, n := wire.ConsumeVarint(b)
673 if n < 0 {
674 return 0, wire.ParseError(n)
675 }
676 *p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
677 return n, nil
678}
679
Damien Neilc37adef2019-04-01 13:49:56 -0700680var coderSint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700681 size: sizeSint32,
682 marshal: appendSint32,
683 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700684}
685
Joe Tsaic51e2e02019-07-13 00:44:41 -0700686// sizeSint32NoZero returns the size of wire encoding a int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700687// The zero value is not encoded.
688func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
689 v := *p.Int32()
690 if v == 0 {
691 return 0
692 }
693 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
694}
695
Joe Tsaic51e2e02019-07-13 00:44:41 -0700696// appendSint32NoZero wire encodes a int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700697// The zero value is not encoded.
698func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
699 v := *p.Int32()
700 if v == 0 {
701 return b, nil
702 }
703 b = wire.AppendVarint(b, wiretag)
704 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
705 return b, nil
706}
707
708var coderSint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700709 size: sizeSint32NoZero,
710 marshal: appendSint32NoZero,
711 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700712}
713
714// sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
715// It panics if the pointer is nil.
716func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
717 v := **p.Int32Ptr()
718 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
719}
720
Damien Neile91877d2019-06-27 10:54:42 -0700721// appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700722// It panics if the pointer is nil.
723func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
724 v := **p.Int32Ptr()
725 b = wire.AppendVarint(b, wiretag)
726 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
727 return b, nil
728}
729
Damien Neile91877d2019-06-27 10:54:42 -0700730// consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
731func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
732 if wtyp != wire.VarintType {
733 return 0, errUnknown
734 }
735 v, n := wire.ConsumeVarint(b)
736 if n < 0 {
737 return 0, wire.ParseError(n)
738 }
739 vp := p.Int32Ptr()
740 if *vp == nil {
741 *vp = new(int32)
742 }
743 **vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
744 return n, nil
745}
746
Damien Neilc37adef2019-04-01 13:49:56 -0700747var coderSint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700748 size: sizeSint32Ptr,
749 marshal: appendSint32Ptr,
750 unmarshal: consumeSint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700751}
752
753// sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
754func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
755 s := *p.Int32Slice()
756 for _, v := range s {
757 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
758 }
759 return size
760}
761
762// appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
763func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
764 s := *p.Int32Slice()
765 for _, v := range s {
766 b = wire.AppendVarint(b, wiretag)
767 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
768 }
769 return b, nil
770}
771
Damien Neile91877d2019-06-27 10:54:42 -0700772// consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
773func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
774 sp := p.Int32Slice()
775 if wtyp == wire.BytesType {
776 s := *sp
777 b, n = wire.ConsumeBytes(b)
778 if n < 0 {
779 return 0, wire.ParseError(n)
780 }
781 for len(b) > 0 {
782 v, n := wire.ConsumeVarint(b)
783 if n < 0 {
784 return 0, wire.ParseError(n)
785 }
786 s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
787 b = b[n:]
788 }
789 *sp = s
790 return n, nil
791 }
792 if wtyp != wire.VarintType {
793 return 0, errUnknown
794 }
795 v, n := wire.ConsumeVarint(b)
796 if n < 0 {
797 return 0, wire.ParseError(n)
798 }
799 *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
800 return n, nil
801}
802
Damien Neilc37adef2019-04-01 13:49:56 -0700803var coderSint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700804 size: sizeSint32Slice,
805 marshal: appendSint32Slice,
806 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700807}
808
809// sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
810func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
811 s := *p.Int32Slice()
812 if len(s) == 0 {
813 return 0
814 }
815 n := 0
816 for _, v := range s {
817 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
818 }
819 return tagsize + wire.SizeBytes(n)
820}
821
822// appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
823func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
824 s := *p.Int32Slice()
825 if len(s) == 0 {
826 return b, nil
827 }
828 b = wire.AppendVarint(b, wiretag)
829 n := 0
830 for _, v := range s {
831 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
832 }
833 b = wire.AppendVarint(b, uint64(n))
834 for _, v := range s {
835 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
836 }
837 return b, nil
838}
839
840var coderSint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700841 size: sizeSint32PackedSlice,
842 marshal: appendSint32PackedSlice,
843 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700844}
845
846// sizeSint32Iface returns the size of wire encoding a int32 value as a Sint32.
847func sizeSint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
848 v := ival.(int32)
849 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
850}
851
852// appendSint32Iface encodes a int32 value as a Sint32.
853func appendSint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
854 v := ival.(int32)
855 b = wire.AppendVarint(b, wiretag)
856 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
857 return b, nil
858}
859
Damien Neile91877d2019-06-27 10:54:42 -0700860// consumeSint32Iface decodes a int32 value as a Sint32.
861func consumeSint32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
862 if wtyp != wire.VarintType {
863 return nil, 0, errUnknown
864 }
865 v, n := wire.ConsumeVarint(b)
866 if n < 0 {
867 return nil, 0, wire.ParseError(n)
868 }
869 return int32(wire.DecodeZigZag(v & math.MaxUint32)), n, nil
870}
871
Damien Neilc37adef2019-04-01 13:49:56 -0700872var coderSint32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700873 size: sizeSint32Iface,
874 marshal: appendSint32Iface,
875 unmarshal: consumeSint32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -0700876}
877
878// sizeSint32SliceIface returns the size of wire encoding a []int32 value as a repeated Sint32.
879func sizeSint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
880 s := *ival.(*[]int32)
881 for _, v := range s {
882 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
883 }
884 return size
885}
886
887// appendSint32SliceIface encodes a []int32 value as a repeated Sint32.
888func appendSint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
889 s := *ival.(*[]int32)
890 for _, v := range s {
891 b = wire.AppendVarint(b, wiretag)
892 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
893 }
894 return b, nil
895}
896
Damien Neile91877d2019-06-27 10:54:42 -0700897// consumeSint32SliceIface wire decodes a []int32 value as a repeated Sint32.
898func consumeSint32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
899 sp := ival.(*[]int32)
900 if wtyp == wire.BytesType {
901 s := *sp
902 b, n = wire.ConsumeBytes(b)
903 if n < 0 {
904 return nil, 0, wire.ParseError(n)
905 }
906 for len(b) > 0 {
907 v, n := wire.ConsumeVarint(b)
908 if n < 0 {
909 return nil, 0, wire.ParseError(n)
910 }
911 s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
912 b = b[n:]
913 }
914 *sp = s
915 return ival, n, nil
916 }
917 if wtyp != wire.VarintType {
918 return nil, 0, errUnknown
919 }
920 v, n := wire.ConsumeVarint(b)
921 if n < 0 {
922 return nil, 0, wire.ParseError(n)
923 }
924 *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
925 return ival, n, nil
926}
927
Damien Neilc37adef2019-04-01 13:49:56 -0700928var coderSint32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700929 size: sizeSint32SliceIface,
930 marshal: appendSint32SliceIface,
931 unmarshal: consumeSint32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700932}
933
Damien Neil7492a092019-07-10 15:23:29 -0700934// sizeSint32PackedSliceIface returns the size of wire encoding a []int32 value as a packed repeated Sint32.
935func sizeSint32PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
936 s := *ival.(*[]int32)
937 if len(s) == 0 {
938 return 0
939 }
940 n := 0
941 for _, v := range s {
942 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
943 }
944 return tagsize + wire.SizeBytes(n)
945}
946
947// appendSint32PackedSliceIface encodes a []int32 value as a packed repeated Sint32.
948func appendSint32PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
949 s := *ival.(*[]int32)
950 if len(s) == 0 {
951 return b, nil
952 }
953 b = wire.AppendVarint(b, wiretag)
954 n := 0
955 for _, v := range s {
956 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
957 }
958 b = wire.AppendVarint(b, uint64(n))
959 for _, v := range s {
960 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
961 }
962 return b, nil
963}
964
965var coderSint32PackedSliceIface = ifaceCoderFuncs{
966 size: sizeSint32PackedSliceIface,
967 marshal: appendSint32PackedSliceIface,
968 unmarshal: consumeSint32SliceIface,
969}
970
Damien Neilc37adef2019-04-01 13:49:56 -0700971// sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
972func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
973 v := *p.Uint32()
974 return tagsize + wire.SizeVarint(uint64(v))
975}
976
977// appendUint32 wire encodes a uint32 pointer as a Uint32.
978func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
979 v := *p.Uint32()
980 b = wire.AppendVarint(b, wiretag)
981 b = wire.AppendVarint(b, uint64(v))
982 return b, nil
983}
984
Damien Neile91877d2019-06-27 10:54:42 -0700985// consumeUint32 wire decodes a uint32 pointer as a Uint32.
986func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
987 if wtyp != wire.VarintType {
988 return 0, errUnknown
989 }
990 v, n := wire.ConsumeVarint(b)
991 if n < 0 {
992 return 0, wire.ParseError(n)
993 }
994 *p.Uint32() = uint32(v)
995 return n, nil
996}
997
Damien Neilc37adef2019-04-01 13:49:56 -0700998var coderUint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700999 size: sizeUint32,
1000 marshal: appendUint32,
1001 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -07001002}
1003
Joe Tsaic51e2e02019-07-13 00:44:41 -07001004// sizeUint32NoZero returns the size of wire encoding a uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001005// The zero value is not encoded.
1006func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1007 v := *p.Uint32()
1008 if v == 0 {
1009 return 0
1010 }
1011 return tagsize + wire.SizeVarint(uint64(v))
1012}
1013
Joe Tsaic51e2e02019-07-13 00:44:41 -07001014// appendUint32NoZero wire encodes a uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001015// The zero value is not encoded.
1016func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1017 v := *p.Uint32()
1018 if v == 0 {
1019 return b, nil
1020 }
1021 b = wire.AppendVarint(b, wiretag)
1022 b = wire.AppendVarint(b, uint64(v))
1023 return b, nil
1024}
1025
1026var coderUint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001027 size: sizeUint32NoZero,
1028 marshal: appendUint32NoZero,
1029 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -07001030}
1031
1032// sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
1033// It panics if the pointer is nil.
1034func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1035 v := **p.Uint32Ptr()
1036 return tagsize + wire.SizeVarint(uint64(v))
1037}
1038
Damien Neile91877d2019-06-27 10:54:42 -07001039// appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001040// It panics if the pointer is nil.
1041func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1042 v := **p.Uint32Ptr()
1043 b = wire.AppendVarint(b, wiretag)
1044 b = wire.AppendVarint(b, uint64(v))
1045 return b, nil
1046}
1047
Damien Neile91877d2019-06-27 10:54:42 -07001048// consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
1049func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1050 if wtyp != wire.VarintType {
1051 return 0, errUnknown
1052 }
1053 v, n := wire.ConsumeVarint(b)
1054 if n < 0 {
1055 return 0, wire.ParseError(n)
1056 }
1057 vp := p.Uint32Ptr()
1058 if *vp == nil {
1059 *vp = new(uint32)
1060 }
1061 **vp = uint32(v)
1062 return n, nil
1063}
1064
Damien Neilc37adef2019-04-01 13:49:56 -07001065var coderUint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001066 size: sizeUint32Ptr,
1067 marshal: appendUint32Ptr,
1068 unmarshal: consumeUint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001069}
1070
1071// sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
1072func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1073 s := *p.Uint32Slice()
1074 for _, v := range s {
1075 size += tagsize + wire.SizeVarint(uint64(v))
1076 }
1077 return size
1078}
1079
1080// appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
1081func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1082 s := *p.Uint32Slice()
1083 for _, v := range s {
1084 b = wire.AppendVarint(b, wiretag)
1085 b = wire.AppendVarint(b, uint64(v))
1086 }
1087 return b, nil
1088}
1089
Damien Neile91877d2019-06-27 10:54:42 -07001090// consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
1091func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1092 sp := p.Uint32Slice()
1093 if wtyp == wire.BytesType {
1094 s := *sp
1095 b, n = wire.ConsumeBytes(b)
1096 if n < 0 {
1097 return 0, wire.ParseError(n)
1098 }
1099 for len(b) > 0 {
1100 v, n := wire.ConsumeVarint(b)
1101 if n < 0 {
1102 return 0, wire.ParseError(n)
1103 }
1104 s = append(s, uint32(v))
1105 b = b[n:]
1106 }
1107 *sp = s
1108 return n, nil
1109 }
1110 if wtyp != wire.VarintType {
1111 return 0, errUnknown
1112 }
1113 v, n := wire.ConsumeVarint(b)
1114 if n < 0 {
1115 return 0, wire.ParseError(n)
1116 }
1117 *sp = append(*sp, uint32(v))
1118 return n, nil
1119}
1120
Damien Neilc37adef2019-04-01 13:49:56 -07001121var coderUint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001122 size: sizeUint32Slice,
1123 marshal: appendUint32Slice,
1124 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001125}
1126
1127// sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
1128func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1129 s := *p.Uint32Slice()
1130 if len(s) == 0 {
1131 return 0
1132 }
1133 n := 0
1134 for _, v := range s {
1135 n += wire.SizeVarint(uint64(v))
1136 }
1137 return tagsize + wire.SizeBytes(n)
1138}
1139
1140// appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
1141func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1142 s := *p.Uint32Slice()
1143 if len(s) == 0 {
1144 return b, nil
1145 }
1146 b = wire.AppendVarint(b, wiretag)
1147 n := 0
1148 for _, v := range s {
1149 n += wire.SizeVarint(uint64(v))
1150 }
1151 b = wire.AppendVarint(b, uint64(n))
1152 for _, v := range s {
1153 b = wire.AppendVarint(b, uint64(v))
1154 }
1155 return b, nil
1156}
1157
1158var coderUint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001159 size: sizeUint32PackedSlice,
1160 marshal: appendUint32PackedSlice,
1161 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001162}
1163
1164// sizeUint32Iface returns the size of wire encoding a uint32 value as a Uint32.
1165func sizeUint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1166 v := ival.(uint32)
1167 return tagsize + wire.SizeVarint(uint64(v))
1168}
1169
1170// appendUint32Iface encodes a uint32 value as a Uint32.
1171func appendUint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1172 v := ival.(uint32)
1173 b = wire.AppendVarint(b, wiretag)
1174 b = wire.AppendVarint(b, uint64(v))
1175 return b, nil
1176}
1177
Damien Neile91877d2019-06-27 10:54:42 -07001178// consumeUint32Iface decodes a uint32 value as a Uint32.
1179func consumeUint32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1180 if wtyp != wire.VarintType {
1181 return nil, 0, errUnknown
1182 }
1183 v, n := wire.ConsumeVarint(b)
1184 if n < 0 {
1185 return nil, 0, wire.ParseError(n)
1186 }
1187 return uint32(v), n, nil
1188}
1189
Damien Neilc37adef2019-04-01 13:49:56 -07001190var coderUint32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001191 size: sizeUint32Iface,
1192 marshal: appendUint32Iface,
1193 unmarshal: consumeUint32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001194}
1195
1196// sizeUint32SliceIface returns the size of wire encoding a []uint32 value as a repeated Uint32.
1197func sizeUint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1198 s := *ival.(*[]uint32)
1199 for _, v := range s {
1200 size += tagsize + wire.SizeVarint(uint64(v))
1201 }
1202 return size
1203}
1204
1205// appendUint32SliceIface encodes a []uint32 value as a repeated Uint32.
1206func appendUint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1207 s := *ival.(*[]uint32)
1208 for _, v := range s {
1209 b = wire.AppendVarint(b, wiretag)
1210 b = wire.AppendVarint(b, uint64(v))
1211 }
1212 return b, nil
1213}
1214
Damien Neile91877d2019-06-27 10:54:42 -07001215// consumeUint32SliceIface wire decodes a []uint32 value as a repeated Uint32.
1216func consumeUint32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1217 sp := ival.(*[]uint32)
1218 if wtyp == wire.BytesType {
1219 s := *sp
1220 b, n = wire.ConsumeBytes(b)
1221 if n < 0 {
1222 return nil, 0, wire.ParseError(n)
1223 }
1224 for len(b) > 0 {
1225 v, n := wire.ConsumeVarint(b)
1226 if n < 0 {
1227 return nil, 0, wire.ParseError(n)
1228 }
1229 s = append(s, uint32(v))
1230 b = b[n:]
1231 }
1232 *sp = s
1233 return ival, n, nil
1234 }
1235 if wtyp != wire.VarintType {
1236 return nil, 0, errUnknown
1237 }
1238 v, n := wire.ConsumeVarint(b)
1239 if n < 0 {
1240 return nil, 0, wire.ParseError(n)
1241 }
1242 *sp = append(*sp, uint32(v))
1243 return ival, n, nil
1244}
1245
Damien Neilc37adef2019-04-01 13:49:56 -07001246var coderUint32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001247 size: sizeUint32SliceIface,
1248 marshal: appendUint32SliceIface,
1249 unmarshal: consumeUint32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001250}
1251
Damien Neil7492a092019-07-10 15:23:29 -07001252// sizeUint32PackedSliceIface returns the size of wire encoding a []uint32 value as a packed repeated Uint32.
1253func sizeUint32PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1254 s := *ival.(*[]uint32)
1255 if len(s) == 0 {
1256 return 0
1257 }
1258 n := 0
1259 for _, v := range s {
1260 n += wire.SizeVarint(uint64(v))
1261 }
1262 return tagsize + wire.SizeBytes(n)
1263}
1264
1265// appendUint32PackedSliceIface encodes a []uint32 value as a packed repeated Uint32.
1266func appendUint32PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1267 s := *ival.(*[]uint32)
1268 if len(s) == 0 {
1269 return b, nil
1270 }
1271 b = wire.AppendVarint(b, wiretag)
1272 n := 0
1273 for _, v := range s {
1274 n += wire.SizeVarint(uint64(v))
1275 }
1276 b = wire.AppendVarint(b, uint64(n))
1277 for _, v := range s {
1278 b = wire.AppendVarint(b, uint64(v))
1279 }
1280 return b, nil
1281}
1282
1283var coderUint32PackedSliceIface = ifaceCoderFuncs{
1284 size: sizeUint32PackedSliceIface,
1285 marshal: appendUint32PackedSliceIface,
1286 unmarshal: consumeUint32SliceIface,
1287}
1288
Damien Neilc37adef2019-04-01 13:49:56 -07001289// sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
1290func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
1291 v := *p.Int64()
1292 return tagsize + wire.SizeVarint(uint64(v))
1293}
1294
1295// appendInt64 wire encodes a int64 pointer as a Int64.
1296func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1297 v := *p.Int64()
1298 b = wire.AppendVarint(b, wiretag)
1299 b = wire.AppendVarint(b, uint64(v))
1300 return b, nil
1301}
1302
Damien Neile91877d2019-06-27 10:54:42 -07001303// consumeInt64 wire decodes a int64 pointer as a Int64.
1304func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1305 if wtyp != wire.VarintType {
1306 return 0, errUnknown
1307 }
1308 v, n := wire.ConsumeVarint(b)
1309 if n < 0 {
1310 return 0, wire.ParseError(n)
1311 }
1312 *p.Int64() = int64(v)
1313 return n, nil
1314}
1315
Damien Neilc37adef2019-04-01 13:49:56 -07001316var coderInt64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001317 size: sizeInt64,
1318 marshal: appendInt64,
1319 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001320}
1321
Joe Tsaic51e2e02019-07-13 00:44:41 -07001322// sizeInt64NoZero returns the size of wire encoding a int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001323// The zero value is not encoded.
1324func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1325 v := *p.Int64()
1326 if v == 0 {
1327 return 0
1328 }
1329 return tagsize + wire.SizeVarint(uint64(v))
1330}
1331
Joe Tsaic51e2e02019-07-13 00:44:41 -07001332// appendInt64NoZero wire encodes a int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001333// The zero value is not encoded.
1334func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1335 v := *p.Int64()
1336 if v == 0 {
1337 return b, nil
1338 }
1339 b = wire.AppendVarint(b, wiretag)
1340 b = wire.AppendVarint(b, uint64(v))
1341 return b, nil
1342}
1343
1344var coderInt64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001345 size: sizeInt64NoZero,
1346 marshal: appendInt64NoZero,
1347 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001348}
1349
1350// sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
1351// It panics if the pointer is nil.
1352func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1353 v := **p.Int64Ptr()
1354 return tagsize + wire.SizeVarint(uint64(v))
1355}
1356
Damien Neile91877d2019-06-27 10:54:42 -07001357// appendInt64Ptr wire encodes a *int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001358// It panics if the pointer is nil.
1359func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1360 v := **p.Int64Ptr()
1361 b = wire.AppendVarint(b, wiretag)
1362 b = wire.AppendVarint(b, uint64(v))
1363 return b, nil
1364}
1365
Damien Neile91877d2019-06-27 10:54:42 -07001366// consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
1367func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1368 if wtyp != wire.VarintType {
1369 return 0, errUnknown
1370 }
1371 v, n := wire.ConsumeVarint(b)
1372 if n < 0 {
1373 return 0, wire.ParseError(n)
1374 }
1375 vp := p.Int64Ptr()
1376 if *vp == nil {
1377 *vp = new(int64)
1378 }
1379 **vp = int64(v)
1380 return n, nil
1381}
1382
Damien Neilc37adef2019-04-01 13:49:56 -07001383var coderInt64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001384 size: sizeInt64Ptr,
1385 marshal: appendInt64Ptr,
1386 unmarshal: consumeInt64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001387}
1388
1389// sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
1390func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1391 s := *p.Int64Slice()
1392 for _, v := range s {
1393 size += tagsize + wire.SizeVarint(uint64(v))
1394 }
1395 return size
1396}
1397
1398// appendInt64Slice encodes a []int64 pointer as a repeated Int64.
1399func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1400 s := *p.Int64Slice()
1401 for _, v := range s {
1402 b = wire.AppendVarint(b, wiretag)
1403 b = wire.AppendVarint(b, uint64(v))
1404 }
1405 return b, nil
1406}
1407
Damien Neile91877d2019-06-27 10:54:42 -07001408// consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
1409func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1410 sp := p.Int64Slice()
1411 if wtyp == wire.BytesType {
1412 s := *sp
1413 b, n = wire.ConsumeBytes(b)
1414 if n < 0 {
1415 return 0, wire.ParseError(n)
1416 }
1417 for len(b) > 0 {
1418 v, n := wire.ConsumeVarint(b)
1419 if n < 0 {
1420 return 0, wire.ParseError(n)
1421 }
1422 s = append(s, int64(v))
1423 b = b[n:]
1424 }
1425 *sp = s
1426 return n, nil
1427 }
1428 if wtyp != wire.VarintType {
1429 return 0, errUnknown
1430 }
1431 v, n := wire.ConsumeVarint(b)
1432 if n < 0 {
1433 return 0, wire.ParseError(n)
1434 }
1435 *sp = append(*sp, int64(v))
1436 return n, nil
1437}
1438
Damien Neilc37adef2019-04-01 13:49:56 -07001439var coderInt64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001440 size: sizeInt64Slice,
1441 marshal: appendInt64Slice,
1442 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001443}
1444
1445// sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
1446func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1447 s := *p.Int64Slice()
1448 if len(s) == 0 {
1449 return 0
1450 }
1451 n := 0
1452 for _, v := range s {
1453 n += wire.SizeVarint(uint64(v))
1454 }
1455 return tagsize + wire.SizeBytes(n)
1456}
1457
1458// appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
1459func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1460 s := *p.Int64Slice()
1461 if len(s) == 0 {
1462 return b, nil
1463 }
1464 b = wire.AppendVarint(b, wiretag)
1465 n := 0
1466 for _, v := range s {
1467 n += wire.SizeVarint(uint64(v))
1468 }
1469 b = wire.AppendVarint(b, uint64(n))
1470 for _, v := range s {
1471 b = wire.AppendVarint(b, uint64(v))
1472 }
1473 return b, nil
1474}
1475
1476var coderInt64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001477 size: sizeInt64PackedSlice,
1478 marshal: appendInt64PackedSlice,
1479 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001480}
1481
1482// sizeInt64Iface returns the size of wire encoding a int64 value as a Int64.
1483func sizeInt64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1484 v := ival.(int64)
1485 return tagsize + wire.SizeVarint(uint64(v))
1486}
1487
1488// appendInt64Iface encodes a int64 value as a Int64.
1489func appendInt64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1490 v := ival.(int64)
1491 b = wire.AppendVarint(b, wiretag)
1492 b = wire.AppendVarint(b, uint64(v))
1493 return b, nil
1494}
1495
Damien Neile91877d2019-06-27 10:54:42 -07001496// consumeInt64Iface decodes a int64 value as a Int64.
1497func consumeInt64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1498 if wtyp != wire.VarintType {
1499 return nil, 0, errUnknown
1500 }
1501 v, n := wire.ConsumeVarint(b)
1502 if n < 0 {
1503 return nil, 0, wire.ParseError(n)
1504 }
1505 return int64(v), n, nil
1506}
1507
Damien Neilc37adef2019-04-01 13:49:56 -07001508var coderInt64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001509 size: sizeInt64Iface,
1510 marshal: appendInt64Iface,
1511 unmarshal: consumeInt64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001512}
1513
1514// sizeInt64SliceIface returns the size of wire encoding a []int64 value as a repeated Int64.
1515func sizeInt64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1516 s := *ival.(*[]int64)
1517 for _, v := range s {
1518 size += tagsize + wire.SizeVarint(uint64(v))
1519 }
1520 return size
1521}
1522
1523// appendInt64SliceIface encodes a []int64 value as a repeated Int64.
1524func appendInt64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1525 s := *ival.(*[]int64)
1526 for _, v := range s {
1527 b = wire.AppendVarint(b, wiretag)
1528 b = wire.AppendVarint(b, uint64(v))
1529 }
1530 return b, nil
1531}
1532
Damien Neile91877d2019-06-27 10:54:42 -07001533// consumeInt64SliceIface wire decodes a []int64 value as a repeated Int64.
1534func consumeInt64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1535 sp := ival.(*[]int64)
1536 if wtyp == wire.BytesType {
1537 s := *sp
1538 b, n = wire.ConsumeBytes(b)
1539 if n < 0 {
1540 return nil, 0, wire.ParseError(n)
1541 }
1542 for len(b) > 0 {
1543 v, n := wire.ConsumeVarint(b)
1544 if n < 0 {
1545 return nil, 0, wire.ParseError(n)
1546 }
1547 s = append(s, int64(v))
1548 b = b[n:]
1549 }
1550 *sp = s
1551 return ival, n, nil
1552 }
1553 if wtyp != wire.VarintType {
1554 return nil, 0, errUnknown
1555 }
1556 v, n := wire.ConsumeVarint(b)
1557 if n < 0 {
1558 return nil, 0, wire.ParseError(n)
1559 }
1560 *sp = append(*sp, int64(v))
1561 return ival, n, nil
1562}
1563
Damien Neilc37adef2019-04-01 13:49:56 -07001564var coderInt64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001565 size: sizeInt64SliceIface,
1566 marshal: appendInt64SliceIface,
1567 unmarshal: consumeInt64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001568}
1569
Damien Neil7492a092019-07-10 15:23:29 -07001570// sizeInt64PackedSliceIface returns the size of wire encoding a []int64 value as a packed repeated Int64.
1571func sizeInt64PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1572 s := *ival.(*[]int64)
1573 if len(s) == 0 {
1574 return 0
1575 }
1576 n := 0
1577 for _, v := range s {
1578 n += wire.SizeVarint(uint64(v))
1579 }
1580 return tagsize + wire.SizeBytes(n)
1581}
1582
1583// appendInt64PackedSliceIface encodes a []int64 value as a packed repeated Int64.
1584func appendInt64PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1585 s := *ival.(*[]int64)
1586 if len(s) == 0 {
1587 return b, nil
1588 }
1589 b = wire.AppendVarint(b, wiretag)
1590 n := 0
1591 for _, v := range s {
1592 n += wire.SizeVarint(uint64(v))
1593 }
1594 b = wire.AppendVarint(b, uint64(n))
1595 for _, v := range s {
1596 b = wire.AppendVarint(b, uint64(v))
1597 }
1598 return b, nil
1599}
1600
1601var coderInt64PackedSliceIface = ifaceCoderFuncs{
1602 size: sizeInt64PackedSliceIface,
1603 marshal: appendInt64PackedSliceIface,
1604 unmarshal: consumeInt64SliceIface,
1605}
1606
Damien Neilc37adef2019-04-01 13:49:56 -07001607// sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
1608func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
1609 v := *p.Int64()
1610 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1611}
1612
1613// appendSint64 wire encodes a int64 pointer as a Sint64.
1614func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1615 v := *p.Int64()
1616 b = wire.AppendVarint(b, wiretag)
1617 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1618 return b, nil
1619}
1620
Damien Neile91877d2019-06-27 10:54:42 -07001621// consumeSint64 wire decodes a int64 pointer as a Sint64.
1622func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1623 if wtyp != wire.VarintType {
1624 return 0, errUnknown
1625 }
1626 v, n := wire.ConsumeVarint(b)
1627 if n < 0 {
1628 return 0, wire.ParseError(n)
1629 }
1630 *p.Int64() = wire.DecodeZigZag(v)
1631 return n, nil
1632}
1633
Damien Neilc37adef2019-04-01 13:49:56 -07001634var coderSint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001635 size: sizeSint64,
1636 marshal: appendSint64,
1637 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001638}
1639
Joe Tsaic51e2e02019-07-13 00:44:41 -07001640// sizeSint64NoZero returns the size of wire encoding a int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001641// The zero value is not encoded.
1642func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1643 v := *p.Int64()
1644 if v == 0 {
1645 return 0
1646 }
1647 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1648}
1649
Joe Tsaic51e2e02019-07-13 00:44:41 -07001650// appendSint64NoZero wire encodes a int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001651// The zero value is not encoded.
1652func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1653 v := *p.Int64()
1654 if v == 0 {
1655 return b, nil
1656 }
1657 b = wire.AppendVarint(b, wiretag)
1658 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1659 return b, nil
1660}
1661
1662var coderSint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001663 size: sizeSint64NoZero,
1664 marshal: appendSint64NoZero,
1665 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001666}
1667
1668// sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
1669// It panics if the pointer is nil.
1670func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1671 v := **p.Int64Ptr()
1672 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1673}
1674
Damien Neile91877d2019-06-27 10:54:42 -07001675// appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001676// It panics if the pointer is nil.
1677func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1678 v := **p.Int64Ptr()
1679 b = wire.AppendVarint(b, wiretag)
1680 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1681 return b, nil
1682}
1683
Damien Neile91877d2019-06-27 10:54:42 -07001684// consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
1685func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1686 if wtyp != wire.VarintType {
1687 return 0, errUnknown
1688 }
1689 v, n := wire.ConsumeVarint(b)
1690 if n < 0 {
1691 return 0, wire.ParseError(n)
1692 }
1693 vp := p.Int64Ptr()
1694 if *vp == nil {
1695 *vp = new(int64)
1696 }
1697 **vp = wire.DecodeZigZag(v)
1698 return n, nil
1699}
1700
Damien Neilc37adef2019-04-01 13:49:56 -07001701var coderSint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001702 size: sizeSint64Ptr,
1703 marshal: appendSint64Ptr,
1704 unmarshal: consumeSint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001705}
1706
1707// sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
1708func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1709 s := *p.Int64Slice()
1710 for _, v := range s {
1711 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1712 }
1713 return size
1714}
1715
1716// appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
1717func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1718 s := *p.Int64Slice()
1719 for _, v := range s {
1720 b = wire.AppendVarint(b, wiretag)
1721 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1722 }
1723 return b, nil
1724}
1725
Damien Neile91877d2019-06-27 10:54:42 -07001726// consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
1727func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1728 sp := p.Int64Slice()
1729 if wtyp == wire.BytesType {
1730 s := *sp
1731 b, n = wire.ConsumeBytes(b)
1732 if n < 0 {
1733 return 0, wire.ParseError(n)
1734 }
1735 for len(b) > 0 {
1736 v, n := wire.ConsumeVarint(b)
1737 if n < 0 {
1738 return 0, wire.ParseError(n)
1739 }
1740 s = append(s, wire.DecodeZigZag(v))
1741 b = b[n:]
1742 }
1743 *sp = s
1744 return n, nil
1745 }
1746 if wtyp != wire.VarintType {
1747 return 0, errUnknown
1748 }
1749 v, n := wire.ConsumeVarint(b)
1750 if n < 0 {
1751 return 0, wire.ParseError(n)
1752 }
1753 *sp = append(*sp, wire.DecodeZigZag(v))
1754 return n, nil
1755}
1756
Damien Neilc37adef2019-04-01 13:49:56 -07001757var coderSint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001758 size: sizeSint64Slice,
1759 marshal: appendSint64Slice,
1760 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001761}
1762
1763// sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
1764func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1765 s := *p.Int64Slice()
1766 if len(s) == 0 {
1767 return 0
1768 }
1769 n := 0
1770 for _, v := range s {
1771 n += wire.SizeVarint(wire.EncodeZigZag(v))
1772 }
1773 return tagsize + wire.SizeBytes(n)
1774}
1775
1776// appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
1777func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1778 s := *p.Int64Slice()
1779 if len(s) == 0 {
1780 return b, nil
1781 }
1782 b = wire.AppendVarint(b, wiretag)
1783 n := 0
1784 for _, v := range s {
1785 n += wire.SizeVarint(wire.EncodeZigZag(v))
1786 }
1787 b = wire.AppendVarint(b, uint64(n))
1788 for _, v := range s {
1789 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1790 }
1791 return b, nil
1792}
1793
1794var coderSint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001795 size: sizeSint64PackedSlice,
1796 marshal: appendSint64PackedSlice,
1797 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001798}
1799
1800// sizeSint64Iface returns the size of wire encoding a int64 value as a Sint64.
1801func sizeSint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1802 v := ival.(int64)
1803 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1804}
1805
1806// appendSint64Iface encodes a int64 value as a Sint64.
1807func appendSint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1808 v := ival.(int64)
1809 b = wire.AppendVarint(b, wiretag)
1810 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1811 return b, nil
1812}
1813
Damien Neile91877d2019-06-27 10:54:42 -07001814// consumeSint64Iface decodes a int64 value as a Sint64.
1815func consumeSint64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1816 if wtyp != wire.VarintType {
1817 return nil, 0, errUnknown
1818 }
1819 v, n := wire.ConsumeVarint(b)
1820 if n < 0 {
1821 return nil, 0, wire.ParseError(n)
1822 }
1823 return wire.DecodeZigZag(v), n, nil
1824}
1825
Damien Neilc37adef2019-04-01 13:49:56 -07001826var coderSint64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001827 size: sizeSint64Iface,
1828 marshal: appendSint64Iface,
1829 unmarshal: consumeSint64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001830}
1831
1832// sizeSint64SliceIface returns the size of wire encoding a []int64 value as a repeated Sint64.
1833func sizeSint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1834 s := *ival.(*[]int64)
1835 for _, v := range s {
1836 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1837 }
1838 return size
1839}
1840
1841// appendSint64SliceIface encodes a []int64 value as a repeated Sint64.
1842func appendSint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1843 s := *ival.(*[]int64)
1844 for _, v := range s {
1845 b = wire.AppendVarint(b, wiretag)
1846 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1847 }
1848 return b, nil
1849}
1850
Damien Neile91877d2019-06-27 10:54:42 -07001851// consumeSint64SliceIface wire decodes a []int64 value as a repeated Sint64.
1852func consumeSint64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1853 sp := ival.(*[]int64)
1854 if wtyp == wire.BytesType {
1855 s := *sp
1856 b, n = wire.ConsumeBytes(b)
1857 if n < 0 {
1858 return nil, 0, wire.ParseError(n)
1859 }
1860 for len(b) > 0 {
1861 v, n := wire.ConsumeVarint(b)
1862 if n < 0 {
1863 return nil, 0, wire.ParseError(n)
1864 }
1865 s = append(s, wire.DecodeZigZag(v))
1866 b = b[n:]
1867 }
1868 *sp = s
1869 return ival, n, nil
1870 }
1871 if wtyp != wire.VarintType {
1872 return nil, 0, errUnknown
1873 }
1874 v, n := wire.ConsumeVarint(b)
1875 if n < 0 {
1876 return nil, 0, wire.ParseError(n)
1877 }
1878 *sp = append(*sp, wire.DecodeZigZag(v))
1879 return ival, n, nil
1880}
1881
Damien Neilc37adef2019-04-01 13:49:56 -07001882var coderSint64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001883 size: sizeSint64SliceIface,
1884 marshal: appendSint64SliceIface,
1885 unmarshal: consumeSint64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001886}
1887
Damien Neil7492a092019-07-10 15:23:29 -07001888// sizeSint64PackedSliceIface returns the size of wire encoding a []int64 value as a packed repeated Sint64.
1889func sizeSint64PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1890 s := *ival.(*[]int64)
1891 if len(s) == 0 {
1892 return 0
1893 }
1894 n := 0
1895 for _, v := range s {
1896 n += wire.SizeVarint(wire.EncodeZigZag(v))
1897 }
1898 return tagsize + wire.SizeBytes(n)
1899}
1900
1901// appendSint64PackedSliceIface encodes a []int64 value as a packed repeated Sint64.
1902func appendSint64PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1903 s := *ival.(*[]int64)
1904 if len(s) == 0 {
1905 return b, nil
1906 }
1907 b = wire.AppendVarint(b, wiretag)
1908 n := 0
1909 for _, v := range s {
1910 n += wire.SizeVarint(wire.EncodeZigZag(v))
1911 }
1912 b = wire.AppendVarint(b, uint64(n))
1913 for _, v := range s {
1914 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1915 }
1916 return b, nil
1917}
1918
1919var coderSint64PackedSliceIface = ifaceCoderFuncs{
1920 size: sizeSint64PackedSliceIface,
1921 marshal: appendSint64PackedSliceIface,
1922 unmarshal: consumeSint64SliceIface,
1923}
1924
Damien Neilc37adef2019-04-01 13:49:56 -07001925// sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
1926func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
1927 v := *p.Uint64()
1928 return tagsize + wire.SizeVarint(v)
1929}
1930
1931// appendUint64 wire encodes a uint64 pointer as a Uint64.
1932func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1933 v := *p.Uint64()
1934 b = wire.AppendVarint(b, wiretag)
1935 b = wire.AppendVarint(b, v)
1936 return b, nil
1937}
1938
Damien Neile91877d2019-06-27 10:54:42 -07001939// consumeUint64 wire decodes a uint64 pointer as a Uint64.
1940func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1941 if wtyp != wire.VarintType {
1942 return 0, errUnknown
1943 }
1944 v, n := wire.ConsumeVarint(b)
1945 if n < 0 {
1946 return 0, wire.ParseError(n)
1947 }
1948 *p.Uint64() = v
1949 return n, nil
1950}
1951
Damien Neilc37adef2019-04-01 13:49:56 -07001952var coderUint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001953 size: sizeUint64,
1954 marshal: appendUint64,
1955 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001956}
1957
Joe Tsaic51e2e02019-07-13 00:44:41 -07001958// sizeUint64NoZero returns the size of wire encoding a uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001959// The zero value is not encoded.
1960func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1961 v := *p.Uint64()
1962 if v == 0 {
1963 return 0
1964 }
1965 return tagsize + wire.SizeVarint(v)
1966}
1967
Joe Tsaic51e2e02019-07-13 00:44:41 -07001968// appendUint64NoZero wire encodes a uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001969// The zero value is not encoded.
1970func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1971 v := *p.Uint64()
1972 if v == 0 {
1973 return b, nil
1974 }
1975 b = wire.AppendVarint(b, wiretag)
1976 b = wire.AppendVarint(b, v)
1977 return b, nil
1978}
1979
1980var coderUint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001981 size: sizeUint64NoZero,
1982 marshal: appendUint64NoZero,
1983 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001984}
1985
1986// sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
1987// It panics if the pointer is nil.
1988func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1989 v := **p.Uint64Ptr()
1990 return tagsize + wire.SizeVarint(v)
1991}
1992
Damien Neile91877d2019-06-27 10:54:42 -07001993// appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001994// It panics if the pointer is nil.
1995func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1996 v := **p.Uint64Ptr()
1997 b = wire.AppendVarint(b, wiretag)
1998 b = wire.AppendVarint(b, v)
1999 return b, nil
2000}
2001
Damien Neile91877d2019-06-27 10:54:42 -07002002// consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
2003func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2004 if wtyp != wire.VarintType {
2005 return 0, errUnknown
2006 }
2007 v, n := wire.ConsumeVarint(b)
2008 if n < 0 {
2009 return 0, wire.ParseError(n)
2010 }
2011 vp := p.Uint64Ptr()
2012 if *vp == nil {
2013 *vp = new(uint64)
2014 }
2015 **vp = v
2016 return n, nil
2017}
2018
Damien Neilc37adef2019-04-01 13:49:56 -07002019var coderUint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002020 size: sizeUint64Ptr,
2021 marshal: appendUint64Ptr,
2022 unmarshal: consumeUint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002023}
2024
2025// sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
2026func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2027 s := *p.Uint64Slice()
2028 for _, v := range s {
2029 size += tagsize + wire.SizeVarint(v)
2030 }
2031 return size
2032}
2033
2034// appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
2035func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2036 s := *p.Uint64Slice()
2037 for _, v := range s {
2038 b = wire.AppendVarint(b, wiretag)
2039 b = wire.AppendVarint(b, v)
2040 }
2041 return b, nil
2042}
2043
Damien Neile91877d2019-06-27 10:54:42 -07002044// consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
2045func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2046 sp := p.Uint64Slice()
2047 if wtyp == wire.BytesType {
2048 s := *sp
2049 b, n = wire.ConsumeBytes(b)
2050 if n < 0 {
2051 return 0, wire.ParseError(n)
2052 }
2053 for len(b) > 0 {
2054 v, n := wire.ConsumeVarint(b)
2055 if n < 0 {
2056 return 0, wire.ParseError(n)
2057 }
2058 s = append(s, v)
2059 b = b[n:]
2060 }
2061 *sp = s
2062 return n, nil
2063 }
2064 if wtyp != wire.VarintType {
2065 return 0, errUnknown
2066 }
2067 v, n := wire.ConsumeVarint(b)
2068 if n < 0 {
2069 return 0, wire.ParseError(n)
2070 }
2071 *sp = append(*sp, v)
2072 return n, nil
2073}
2074
Damien Neilc37adef2019-04-01 13:49:56 -07002075var coderUint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002076 size: sizeUint64Slice,
2077 marshal: appendUint64Slice,
2078 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002079}
2080
2081// sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
2082func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2083 s := *p.Uint64Slice()
2084 if len(s) == 0 {
2085 return 0
2086 }
2087 n := 0
2088 for _, v := range s {
2089 n += wire.SizeVarint(v)
2090 }
2091 return tagsize + wire.SizeBytes(n)
2092}
2093
2094// appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
2095func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2096 s := *p.Uint64Slice()
2097 if len(s) == 0 {
2098 return b, nil
2099 }
2100 b = wire.AppendVarint(b, wiretag)
2101 n := 0
2102 for _, v := range s {
2103 n += wire.SizeVarint(v)
2104 }
2105 b = wire.AppendVarint(b, uint64(n))
2106 for _, v := range s {
2107 b = wire.AppendVarint(b, v)
2108 }
2109 return b, nil
2110}
2111
2112var coderUint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002113 size: sizeUint64PackedSlice,
2114 marshal: appendUint64PackedSlice,
2115 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002116}
2117
2118// sizeUint64Iface returns the size of wire encoding a uint64 value as a Uint64.
2119func sizeUint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2120 v := ival.(uint64)
2121 return tagsize + wire.SizeVarint(v)
2122}
2123
2124// appendUint64Iface encodes a uint64 value as a Uint64.
2125func appendUint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2126 v := ival.(uint64)
2127 b = wire.AppendVarint(b, wiretag)
2128 b = wire.AppendVarint(b, v)
2129 return b, nil
2130}
2131
Damien Neile91877d2019-06-27 10:54:42 -07002132// consumeUint64Iface decodes a uint64 value as a Uint64.
2133func consumeUint64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2134 if wtyp != wire.VarintType {
2135 return nil, 0, errUnknown
2136 }
2137 v, n := wire.ConsumeVarint(b)
2138 if n < 0 {
2139 return nil, 0, wire.ParseError(n)
2140 }
2141 return v, n, nil
2142}
2143
Damien Neilc37adef2019-04-01 13:49:56 -07002144var coderUint64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002145 size: sizeUint64Iface,
2146 marshal: appendUint64Iface,
2147 unmarshal: consumeUint64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07002148}
2149
2150// sizeUint64SliceIface returns the size of wire encoding a []uint64 value as a repeated Uint64.
2151func sizeUint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2152 s := *ival.(*[]uint64)
2153 for _, v := range s {
2154 size += tagsize + wire.SizeVarint(v)
2155 }
2156 return size
2157}
2158
2159// appendUint64SliceIface encodes a []uint64 value as a repeated Uint64.
2160func appendUint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2161 s := *ival.(*[]uint64)
2162 for _, v := range s {
2163 b = wire.AppendVarint(b, wiretag)
2164 b = wire.AppendVarint(b, v)
2165 }
2166 return b, nil
2167}
2168
Damien Neile91877d2019-06-27 10:54:42 -07002169// consumeUint64SliceIface wire decodes a []uint64 value as a repeated Uint64.
2170func consumeUint64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2171 sp := ival.(*[]uint64)
2172 if wtyp == wire.BytesType {
2173 s := *sp
2174 b, n = wire.ConsumeBytes(b)
2175 if n < 0 {
2176 return nil, 0, wire.ParseError(n)
2177 }
2178 for len(b) > 0 {
2179 v, n := wire.ConsumeVarint(b)
2180 if n < 0 {
2181 return nil, 0, wire.ParseError(n)
2182 }
2183 s = append(s, v)
2184 b = b[n:]
2185 }
2186 *sp = s
2187 return ival, n, nil
2188 }
2189 if wtyp != wire.VarintType {
2190 return nil, 0, errUnknown
2191 }
2192 v, n := wire.ConsumeVarint(b)
2193 if n < 0 {
2194 return nil, 0, wire.ParseError(n)
2195 }
2196 *sp = append(*sp, v)
2197 return ival, n, nil
2198}
2199
Damien Neilc37adef2019-04-01 13:49:56 -07002200var coderUint64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002201 size: sizeUint64SliceIface,
2202 marshal: appendUint64SliceIface,
2203 unmarshal: consumeUint64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002204}
2205
Damien Neil7492a092019-07-10 15:23:29 -07002206// sizeUint64PackedSliceIface returns the size of wire encoding a []uint64 value as a packed repeated Uint64.
2207func sizeUint64PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2208 s := *ival.(*[]uint64)
2209 if len(s) == 0 {
2210 return 0
2211 }
2212 n := 0
2213 for _, v := range s {
2214 n += wire.SizeVarint(v)
2215 }
2216 return tagsize + wire.SizeBytes(n)
2217}
2218
2219// appendUint64PackedSliceIface encodes a []uint64 value as a packed repeated Uint64.
2220func appendUint64PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2221 s := *ival.(*[]uint64)
2222 if len(s) == 0 {
2223 return b, nil
2224 }
2225 b = wire.AppendVarint(b, wiretag)
2226 n := 0
2227 for _, v := range s {
2228 n += wire.SizeVarint(v)
2229 }
2230 b = wire.AppendVarint(b, uint64(n))
2231 for _, v := range s {
2232 b = wire.AppendVarint(b, v)
2233 }
2234 return b, nil
2235}
2236
2237var coderUint64PackedSliceIface = ifaceCoderFuncs{
2238 size: sizeUint64PackedSliceIface,
2239 marshal: appendUint64PackedSliceIface,
2240 unmarshal: consumeUint64SliceIface,
2241}
2242
Damien Neilc37adef2019-04-01 13:49:56 -07002243// sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
2244func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
2245
2246 return tagsize + wire.SizeFixed32()
2247}
2248
2249// appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
2250func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2251 v := *p.Int32()
2252 b = wire.AppendVarint(b, wiretag)
2253 b = wire.AppendFixed32(b, uint32(v))
2254 return b, nil
2255}
2256
Damien Neile91877d2019-06-27 10:54:42 -07002257// consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
2258func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2259 if wtyp != wire.Fixed32Type {
2260 return 0, errUnknown
2261 }
2262 v, n := wire.ConsumeFixed32(b)
2263 if n < 0 {
2264 return 0, wire.ParseError(n)
2265 }
2266 *p.Int32() = int32(v)
2267 return n, nil
2268}
2269
Damien Neilc37adef2019-04-01 13:49:56 -07002270var coderSfixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002271 size: sizeSfixed32,
2272 marshal: appendSfixed32,
2273 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002274}
2275
Joe Tsaic51e2e02019-07-13 00:44:41 -07002276// sizeSfixed32NoZero returns the size of wire encoding a int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002277// The zero value is not encoded.
2278func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2279 v := *p.Int32()
2280 if v == 0 {
2281 return 0
2282 }
2283 return tagsize + wire.SizeFixed32()
2284}
2285
Joe Tsaic51e2e02019-07-13 00:44:41 -07002286// appendSfixed32NoZero wire encodes a int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002287// The zero value is not encoded.
2288func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2289 v := *p.Int32()
2290 if v == 0 {
2291 return b, nil
2292 }
2293 b = wire.AppendVarint(b, wiretag)
2294 b = wire.AppendFixed32(b, uint32(v))
2295 return b, nil
2296}
2297
2298var coderSfixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002299 size: sizeSfixed32NoZero,
2300 marshal: appendSfixed32NoZero,
2301 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002302}
2303
2304// sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
2305// It panics if the pointer is nil.
2306func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2307 return tagsize + wire.SizeFixed32()
2308}
2309
Damien Neile91877d2019-06-27 10:54:42 -07002310// appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002311// It panics if the pointer is nil.
2312func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2313 v := **p.Int32Ptr()
2314 b = wire.AppendVarint(b, wiretag)
2315 b = wire.AppendFixed32(b, uint32(v))
2316 return b, nil
2317}
2318
Damien Neile91877d2019-06-27 10:54:42 -07002319// consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
2320func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2321 if wtyp != wire.Fixed32Type {
2322 return 0, errUnknown
2323 }
2324 v, n := wire.ConsumeFixed32(b)
2325 if n < 0 {
2326 return 0, wire.ParseError(n)
2327 }
2328 vp := p.Int32Ptr()
2329 if *vp == nil {
2330 *vp = new(int32)
2331 }
2332 **vp = int32(v)
2333 return n, nil
2334}
2335
Damien Neilc37adef2019-04-01 13:49:56 -07002336var coderSfixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002337 size: sizeSfixed32Ptr,
2338 marshal: appendSfixed32Ptr,
2339 unmarshal: consumeSfixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002340}
2341
2342// sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
2343func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2344 s := *p.Int32Slice()
2345 size = len(s) * (tagsize + wire.SizeFixed32())
2346 return size
2347}
2348
2349// appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
2350func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2351 s := *p.Int32Slice()
2352 for _, v := range s {
2353 b = wire.AppendVarint(b, wiretag)
2354 b = wire.AppendFixed32(b, uint32(v))
2355 }
2356 return b, nil
2357}
2358
Damien Neile91877d2019-06-27 10:54:42 -07002359// consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
2360func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2361 sp := p.Int32Slice()
2362 if wtyp == wire.BytesType {
2363 s := *sp
2364 b, n = wire.ConsumeBytes(b)
2365 if n < 0 {
2366 return 0, wire.ParseError(n)
2367 }
2368 for len(b) > 0 {
2369 v, n := wire.ConsumeFixed32(b)
2370 if n < 0 {
2371 return 0, wire.ParseError(n)
2372 }
2373 s = append(s, int32(v))
2374 b = b[n:]
2375 }
2376 *sp = s
2377 return n, nil
2378 }
2379 if wtyp != wire.Fixed32Type {
2380 return 0, errUnknown
2381 }
2382 v, n := wire.ConsumeFixed32(b)
2383 if n < 0 {
2384 return 0, wire.ParseError(n)
2385 }
2386 *sp = append(*sp, int32(v))
2387 return n, nil
2388}
2389
Damien Neilc37adef2019-04-01 13:49:56 -07002390var coderSfixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002391 size: sizeSfixed32Slice,
2392 marshal: appendSfixed32Slice,
2393 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002394}
2395
2396// sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
2397func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2398 s := *p.Int32Slice()
2399 if len(s) == 0 {
2400 return 0
2401 }
2402 n := len(s) * wire.SizeFixed32()
2403 return tagsize + wire.SizeBytes(n)
2404}
2405
2406// appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
2407func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2408 s := *p.Int32Slice()
2409 if len(s) == 0 {
2410 return b, nil
2411 }
2412 b = wire.AppendVarint(b, wiretag)
2413 n := len(s) * wire.SizeFixed32()
2414 b = wire.AppendVarint(b, uint64(n))
2415 for _, v := range s {
2416 b = wire.AppendFixed32(b, uint32(v))
2417 }
2418 return b, nil
2419}
2420
2421var coderSfixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002422 size: sizeSfixed32PackedSlice,
2423 marshal: appendSfixed32PackedSlice,
2424 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002425}
2426
2427// sizeSfixed32Iface returns the size of wire encoding a int32 value as a Sfixed32.
2428func sizeSfixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2429 return tagsize + wire.SizeFixed32()
2430}
2431
2432// appendSfixed32Iface encodes a int32 value as a Sfixed32.
2433func appendSfixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2434 v := ival.(int32)
2435 b = wire.AppendVarint(b, wiretag)
2436 b = wire.AppendFixed32(b, uint32(v))
2437 return b, nil
2438}
2439
Damien Neile91877d2019-06-27 10:54:42 -07002440// consumeSfixed32Iface decodes a int32 value as a Sfixed32.
2441func consumeSfixed32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2442 if wtyp != wire.Fixed32Type {
2443 return nil, 0, errUnknown
2444 }
2445 v, n := wire.ConsumeFixed32(b)
2446 if n < 0 {
2447 return nil, 0, wire.ParseError(n)
2448 }
2449 return int32(v), n, nil
2450}
2451
Damien Neilc37adef2019-04-01 13:49:56 -07002452var coderSfixed32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002453 size: sizeSfixed32Iface,
2454 marshal: appendSfixed32Iface,
2455 unmarshal: consumeSfixed32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07002456}
2457
2458// sizeSfixed32SliceIface returns the size of wire encoding a []int32 value as a repeated Sfixed32.
2459func sizeSfixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2460 s := *ival.(*[]int32)
2461 size = len(s) * (tagsize + wire.SizeFixed32())
2462 return size
2463}
2464
2465// appendSfixed32SliceIface encodes a []int32 value as a repeated Sfixed32.
2466func appendSfixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2467 s := *ival.(*[]int32)
2468 for _, v := range s {
2469 b = wire.AppendVarint(b, wiretag)
2470 b = wire.AppendFixed32(b, uint32(v))
2471 }
2472 return b, nil
2473}
2474
Damien Neile91877d2019-06-27 10:54:42 -07002475// consumeSfixed32SliceIface wire decodes a []int32 value as a repeated Sfixed32.
2476func consumeSfixed32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2477 sp := ival.(*[]int32)
2478 if wtyp == wire.BytesType {
2479 s := *sp
2480 b, n = wire.ConsumeBytes(b)
2481 if n < 0 {
2482 return nil, 0, wire.ParseError(n)
2483 }
2484 for len(b) > 0 {
2485 v, n := wire.ConsumeFixed32(b)
2486 if n < 0 {
2487 return nil, 0, wire.ParseError(n)
2488 }
2489 s = append(s, int32(v))
2490 b = b[n:]
2491 }
2492 *sp = s
2493 return ival, n, nil
2494 }
2495 if wtyp != wire.Fixed32Type {
2496 return nil, 0, errUnknown
2497 }
2498 v, n := wire.ConsumeFixed32(b)
2499 if n < 0 {
2500 return nil, 0, wire.ParseError(n)
2501 }
2502 *sp = append(*sp, int32(v))
2503 return ival, n, nil
2504}
2505
Damien Neilc37adef2019-04-01 13:49:56 -07002506var coderSfixed32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002507 size: sizeSfixed32SliceIface,
2508 marshal: appendSfixed32SliceIface,
2509 unmarshal: consumeSfixed32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002510}
2511
Damien Neil7492a092019-07-10 15:23:29 -07002512// sizeSfixed32PackedSliceIface returns the size of wire encoding a []int32 value as a packed repeated Sfixed32.
2513func sizeSfixed32PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2514 s := *ival.(*[]int32)
2515 if len(s) == 0 {
2516 return 0
2517 }
2518 n := len(s) * wire.SizeFixed32()
2519 return tagsize + wire.SizeBytes(n)
2520}
2521
2522// appendSfixed32PackedSliceIface encodes a []int32 value as a packed repeated Sfixed32.
2523func appendSfixed32PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2524 s := *ival.(*[]int32)
2525 if len(s) == 0 {
2526 return b, nil
2527 }
2528 b = wire.AppendVarint(b, wiretag)
2529 n := len(s) * wire.SizeFixed32()
2530 b = wire.AppendVarint(b, uint64(n))
2531 for _, v := range s {
2532 b = wire.AppendFixed32(b, uint32(v))
2533 }
2534 return b, nil
2535}
2536
2537var coderSfixed32PackedSliceIface = ifaceCoderFuncs{
2538 size: sizeSfixed32PackedSliceIface,
2539 marshal: appendSfixed32PackedSliceIface,
2540 unmarshal: consumeSfixed32SliceIface,
2541}
2542
Damien Neilc37adef2019-04-01 13:49:56 -07002543// sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
2544func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
2545
2546 return tagsize + wire.SizeFixed32()
2547}
2548
2549// appendFixed32 wire encodes a uint32 pointer as a Fixed32.
2550func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2551 v := *p.Uint32()
2552 b = wire.AppendVarint(b, wiretag)
2553 b = wire.AppendFixed32(b, v)
2554 return b, nil
2555}
2556
Damien Neile91877d2019-06-27 10:54:42 -07002557// consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
2558func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2559 if wtyp != wire.Fixed32Type {
2560 return 0, errUnknown
2561 }
2562 v, n := wire.ConsumeFixed32(b)
2563 if n < 0 {
2564 return 0, wire.ParseError(n)
2565 }
2566 *p.Uint32() = v
2567 return n, nil
2568}
2569
Damien Neilc37adef2019-04-01 13:49:56 -07002570var coderFixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002571 size: sizeFixed32,
2572 marshal: appendFixed32,
2573 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002574}
2575
Joe Tsaic51e2e02019-07-13 00:44:41 -07002576// sizeFixed32NoZero returns the size of wire encoding a uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002577// The zero value is not encoded.
2578func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2579 v := *p.Uint32()
2580 if v == 0 {
2581 return 0
2582 }
2583 return tagsize + wire.SizeFixed32()
2584}
2585
Joe Tsaic51e2e02019-07-13 00:44:41 -07002586// appendFixed32NoZero wire encodes a uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002587// The zero value is not encoded.
2588func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2589 v := *p.Uint32()
2590 if v == 0 {
2591 return b, nil
2592 }
2593 b = wire.AppendVarint(b, wiretag)
2594 b = wire.AppendFixed32(b, v)
2595 return b, nil
2596}
2597
2598var coderFixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002599 size: sizeFixed32NoZero,
2600 marshal: appendFixed32NoZero,
2601 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002602}
2603
2604// sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
2605// It panics if the pointer is nil.
2606func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2607 return tagsize + wire.SizeFixed32()
2608}
2609
Damien Neile91877d2019-06-27 10:54:42 -07002610// appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002611// It panics if the pointer is nil.
2612func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2613 v := **p.Uint32Ptr()
2614 b = wire.AppendVarint(b, wiretag)
2615 b = wire.AppendFixed32(b, v)
2616 return b, nil
2617}
2618
Damien Neile91877d2019-06-27 10:54:42 -07002619// consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
2620func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2621 if wtyp != wire.Fixed32Type {
2622 return 0, errUnknown
2623 }
2624 v, n := wire.ConsumeFixed32(b)
2625 if n < 0 {
2626 return 0, wire.ParseError(n)
2627 }
2628 vp := p.Uint32Ptr()
2629 if *vp == nil {
2630 *vp = new(uint32)
2631 }
2632 **vp = v
2633 return n, nil
2634}
2635
Damien Neilc37adef2019-04-01 13:49:56 -07002636var coderFixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002637 size: sizeFixed32Ptr,
2638 marshal: appendFixed32Ptr,
2639 unmarshal: consumeFixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002640}
2641
2642// sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
2643func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2644 s := *p.Uint32Slice()
2645 size = len(s) * (tagsize + wire.SizeFixed32())
2646 return size
2647}
2648
2649// appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
2650func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2651 s := *p.Uint32Slice()
2652 for _, v := range s {
2653 b = wire.AppendVarint(b, wiretag)
2654 b = wire.AppendFixed32(b, v)
2655 }
2656 return b, nil
2657}
2658
Damien Neile91877d2019-06-27 10:54:42 -07002659// consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
2660func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2661 sp := p.Uint32Slice()
2662 if wtyp == wire.BytesType {
2663 s := *sp
2664 b, n = wire.ConsumeBytes(b)
2665 if n < 0 {
2666 return 0, wire.ParseError(n)
2667 }
2668 for len(b) > 0 {
2669 v, n := wire.ConsumeFixed32(b)
2670 if n < 0 {
2671 return 0, wire.ParseError(n)
2672 }
2673 s = append(s, v)
2674 b = b[n:]
2675 }
2676 *sp = s
2677 return n, nil
2678 }
2679 if wtyp != wire.Fixed32Type {
2680 return 0, errUnknown
2681 }
2682 v, n := wire.ConsumeFixed32(b)
2683 if n < 0 {
2684 return 0, wire.ParseError(n)
2685 }
2686 *sp = append(*sp, v)
2687 return n, nil
2688}
2689
Damien Neilc37adef2019-04-01 13:49:56 -07002690var coderFixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002691 size: sizeFixed32Slice,
2692 marshal: appendFixed32Slice,
2693 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002694}
2695
2696// sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
2697func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2698 s := *p.Uint32Slice()
2699 if len(s) == 0 {
2700 return 0
2701 }
2702 n := len(s) * wire.SizeFixed32()
2703 return tagsize + wire.SizeBytes(n)
2704}
2705
2706// appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
2707func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2708 s := *p.Uint32Slice()
2709 if len(s) == 0 {
2710 return b, nil
2711 }
2712 b = wire.AppendVarint(b, wiretag)
2713 n := len(s) * wire.SizeFixed32()
2714 b = wire.AppendVarint(b, uint64(n))
2715 for _, v := range s {
2716 b = wire.AppendFixed32(b, v)
2717 }
2718 return b, nil
2719}
2720
2721var coderFixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002722 size: sizeFixed32PackedSlice,
2723 marshal: appendFixed32PackedSlice,
2724 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002725}
2726
2727// sizeFixed32Iface returns the size of wire encoding a uint32 value as a Fixed32.
2728func sizeFixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2729 return tagsize + wire.SizeFixed32()
2730}
2731
2732// appendFixed32Iface encodes a uint32 value as a Fixed32.
2733func appendFixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2734 v := ival.(uint32)
2735 b = wire.AppendVarint(b, wiretag)
2736 b = wire.AppendFixed32(b, v)
2737 return b, nil
2738}
2739
Damien Neile91877d2019-06-27 10:54:42 -07002740// consumeFixed32Iface decodes a uint32 value as a Fixed32.
2741func consumeFixed32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2742 if wtyp != wire.Fixed32Type {
2743 return nil, 0, errUnknown
2744 }
2745 v, n := wire.ConsumeFixed32(b)
2746 if n < 0 {
2747 return nil, 0, wire.ParseError(n)
2748 }
2749 return v, n, nil
2750}
2751
Damien Neilc37adef2019-04-01 13:49:56 -07002752var coderFixed32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002753 size: sizeFixed32Iface,
2754 marshal: appendFixed32Iface,
2755 unmarshal: consumeFixed32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07002756}
2757
2758// sizeFixed32SliceIface returns the size of wire encoding a []uint32 value as a repeated Fixed32.
2759func sizeFixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2760 s := *ival.(*[]uint32)
2761 size = len(s) * (tagsize + wire.SizeFixed32())
2762 return size
2763}
2764
2765// appendFixed32SliceIface encodes a []uint32 value as a repeated Fixed32.
2766func appendFixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2767 s := *ival.(*[]uint32)
2768 for _, v := range s {
2769 b = wire.AppendVarint(b, wiretag)
2770 b = wire.AppendFixed32(b, v)
2771 }
2772 return b, nil
2773}
2774
Damien Neile91877d2019-06-27 10:54:42 -07002775// consumeFixed32SliceIface wire decodes a []uint32 value as a repeated Fixed32.
2776func consumeFixed32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2777 sp := ival.(*[]uint32)
2778 if wtyp == wire.BytesType {
2779 s := *sp
2780 b, n = wire.ConsumeBytes(b)
2781 if n < 0 {
2782 return nil, 0, wire.ParseError(n)
2783 }
2784 for len(b) > 0 {
2785 v, n := wire.ConsumeFixed32(b)
2786 if n < 0 {
2787 return nil, 0, wire.ParseError(n)
2788 }
2789 s = append(s, v)
2790 b = b[n:]
2791 }
2792 *sp = s
2793 return ival, n, nil
2794 }
2795 if wtyp != wire.Fixed32Type {
2796 return nil, 0, errUnknown
2797 }
2798 v, n := wire.ConsumeFixed32(b)
2799 if n < 0 {
2800 return nil, 0, wire.ParseError(n)
2801 }
2802 *sp = append(*sp, v)
2803 return ival, n, nil
2804}
2805
Damien Neilc37adef2019-04-01 13:49:56 -07002806var coderFixed32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002807 size: sizeFixed32SliceIface,
2808 marshal: appendFixed32SliceIface,
2809 unmarshal: consumeFixed32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002810}
2811
Damien Neil7492a092019-07-10 15:23:29 -07002812// sizeFixed32PackedSliceIface returns the size of wire encoding a []uint32 value as a packed repeated Fixed32.
2813func sizeFixed32PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2814 s := *ival.(*[]uint32)
2815 if len(s) == 0 {
2816 return 0
2817 }
2818 n := len(s) * wire.SizeFixed32()
2819 return tagsize + wire.SizeBytes(n)
2820}
2821
2822// appendFixed32PackedSliceIface encodes a []uint32 value as a packed repeated Fixed32.
2823func appendFixed32PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2824 s := *ival.(*[]uint32)
2825 if len(s) == 0 {
2826 return b, nil
2827 }
2828 b = wire.AppendVarint(b, wiretag)
2829 n := len(s) * wire.SizeFixed32()
2830 b = wire.AppendVarint(b, uint64(n))
2831 for _, v := range s {
2832 b = wire.AppendFixed32(b, v)
2833 }
2834 return b, nil
2835}
2836
2837var coderFixed32PackedSliceIface = ifaceCoderFuncs{
2838 size: sizeFixed32PackedSliceIface,
2839 marshal: appendFixed32PackedSliceIface,
2840 unmarshal: consumeFixed32SliceIface,
2841}
2842
Damien Neilc37adef2019-04-01 13:49:56 -07002843// sizeFloat returns the size of wire encoding a float32 pointer as a Float.
2844func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
2845
2846 return tagsize + wire.SizeFixed32()
2847}
2848
2849// appendFloat wire encodes a float32 pointer as a Float.
2850func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2851 v := *p.Float32()
2852 b = wire.AppendVarint(b, wiretag)
2853 b = wire.AppendFixed32(b, math.Float32bits(v))
2854 return b, nil
2855}
2856
Damien Neile91877d2019-06-27 10:54:42 -07002857// consumeFloat wire decodes a float32 pointer as a Float.
2858func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2859 if wtyp != wire.Fixed32Type {
2860 return 0, errUnknown
2861 }
2862 v, n := wire.ConsumeFixed32(b)
2863 if n < 0 {
2864 return 0, wire.ParseError(n)
2865 }
2866 *p.Float32() = math.Float32frombits(v)
2867 return n, nil
2868}
2869
Damien Neilc37adef2019-04-01 13:49:56 -07002870var coderFloat = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002871 size: sizeFloat,
2872 marshal: appendFloat,
2873 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07002874}
2875
Joe Tsaic51e2e02019-07-13 00:44:41 -07002876// sizeFloatNoZero returns the size of wire encoding a float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07002877// The zero value is not encoded.
2878func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2879 v := *p.Float32()
2880 if v == 0 && !math.Signbit(float64(v)) {
2881 return 0
2882 }
2883 return tagsize + wire.SizeFixed32()
2884}
2885
Joe Tsaic51e2e02019-07-13 00:44:41 -07002886// appendFloatNoZero wire encodes a float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07002887// The zero value is not encoded.
2888func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2889 v := *p.Float32()
2890 if v == 0 && !math.Signbit(float64(v)) {
2891 return b, nil
2892 }
2893 b = wire.AppendVarint(b, wiretag)
2894 b = wire.AppendFixed32(b, math.Float32bits(v))
2895 return b, nil
2896}
2897
2898var coderFloatNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002899 size: sizeFloatNoZero,
2900 marshal: appendFloatNoZero,
2901 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07002902}
2903
2904// sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
2905// It panics if the pointer is nil.
2906func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
2907 return tagsize + wire.SizeFixed32()
2908}
2909
Damien Neile91877d2019-06-27 10:54:42 -07002910// appendFloatPtr wire encodes a *float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07002911// It panics if the pointer is nil.
2912func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2913 v := **p.Float32Ptr()
2914 b = wire.AppendVarint(b, wiretag)
2915 b = wire.AppendFixed32(b, math.Float32bits(v))
2916 return b, nil
2917}
2918
Damien Neile91877d2019-06-27 10:54:42 -07002919// consumeFloatPtr wire decodes a *float32 pointer as a Float.
2920func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2921 if wtyp != wire.Fixed32Type {
2922 return 0, errUnknown
2923 }
2924 v, n := wire.ConsumeFixed32(b)
2925 if n < 0 {
2926 return 0, wire.ParseError(n)
2927 }
2928 vp := p.Float32Ptr()
2929 if *vp == nil {
2930 *vp = new(float32)
2931 }
2932 **vp = math.Float32frombits(v)
2933 return n, nil
2934}
2935
Damien Neilc37adef2019-04-01 13:49:56 -07002936var coderFloatPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002937 size: sizeFloatPtr,
2938 marshal: appendFloatPtr,
2939 unmarshal: consumeFloatPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07002940}
2941
2942// sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
2943func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2944 s := *p.Float32Slice()
2945 size = len(s) * (tagsize + wire.SizeFixed32())
2946 return size
2947}
2948
2949// appendFloatSlice encodes a []float32 pointer as a repeated Float.
2950func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2951 s := *p.Float32Slice()
2952 for _, v := range s {
2953 b = wire.AppendVarint(b, wiretag)
2954 b = wire.AppendFixed32(b, math.Float32bits(v))
2955 }
2956 return b, nil
2957}
2958
Damien Neile91877d2019-06-27 10:54:42 -07002959// consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
2960func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2961 sp := p.Float32Slice()
2962 if wtyp == wire.BytesType {
2963 s := *sp
2964 b, n = wire.ConsumeBytes(b)
2965 if n < 0 {
2966 return 0, wire.ParseError(n)
2967 }
2968 for len(b) > 0 {
2969 v, n := wire.ConsumeFixed32(b)
2970 if n < 0 {
2971 return 0, wire.ParseError(n)
2972 }
2973 s = append(s, math.Float32frombits(v))
2974 b = b[n:]
2975 }
2976 *sp = s
2977 return n, nil
2978 }
2979 if wtyp != wire.Fixed32Type {
2980 return 0, errUnknown
2981 }
2982 v, n := wire.ConsumeFixed32(b)
2983 if n < 0 {
2984 return 0, wire.ParseError(n)
2985 }
2986 *sp = append(*sp, math.Float32frombits(v))
2987 return n, nil
2988}
2989
Damien Neilc37adef2019-04-01 13:49:56 -07002990var coderFloatSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002991 size: sizeFloatSlice,
2992 marshal: appendFloatSlice,
2993 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07002994}
2995
2996// sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
2997func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2998 s := *p.Float32Slice()
2999 if len(s) == 0 {
3000 return 0
3001 }
3002 n := len(s) * wire.SizeFixed32()
3003 return tagsize + wire.SizeBytes(n)
3004}
3005
3006// appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
3007func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3008 s := *p.Float32Slice()
3009 if len(s) == 0 {
3010 return b, nil
3011 }
3012 b = wire.AppendVarint(b, wiretag)
3013 n := len(s) * wire.SizeFixed32()
3014 b = wire.AppendVarint(b, uint64(n))
3015 for _, v := range s {
3016 b = wire.AppendFixed32(b, math.Float32bits(v))
3017 }
3018 return b, nil
3019}
3020
3021var coderFloatPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003022 size: sizeFloatPackedSlice,
3023 marshal: appendFloatPackedSlice,
3024 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003025}
3026
3027// sizeFloatIface returns the size of wire encoding a float32 value as a Float.
3028func sizeFloatIface(ival interface{}, tagsize int, _ marshalOptions) int {
3029 return tagsize + wire.SizeFixed32()
3030}
3031
3032// appendFloatIface encodes a float32 value as a Float.
3033func appendFloatIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3034 v := ival.(float32)
3035 b = wire.AppendVarint(b, wiretag)
3036 b = wire.AppendFixed32(b, math.Float32bits(v))
3037 return b, nil
3038}
3039
Damien Neile91877d2019-06-27 10:54:42 -07003040// consumeFloatIface decodes a float32 value as a Float.
3041func consumeFloatIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3042 if wtyp != wire.Fixed32Type {
3043 return nil, 0, errUnknown
3044 }
3045 v, n := wire.ConsumeFixed32(b)
3046 if n < 0 {
3047 return nil, 0, wire.ParseError(n)
3048 }
3049 return math.Float32frombits(v), n, nil
3050}
3051
Damien Neilc37adef2019-04-01 13:49:56 -07003052var coderFloatIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003053 size: sizeFloatIface,
3054 marshal: appendFloatIface,
3055 unmarshal: consumeFloatIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003056}
3057
3058// sizeFloatSliceIface returns the size of wire encoding a []float32 value as a repeated Float.
3059func sizeFloatSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3060 s := *ival.(*[]float32)
3061 size = len(s) * (tagsize + wire.SizeFixed32())
3062 return size
3063}
3064
3065// appendFloatSliceIface encodes a []float32 value as a repeated Float.
3066func appendFloatSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3067 s := *ival.(*[]float32)
3068 for _, v := range s {
3069 b = wire.AppendVarint(b, wiretag)
3070 b = wire.AppendFixed32(b, math.Float32bits(v))
3071 }
3072 return b, nil
3073}
3074
Damien Neile91877d2019-06-27 10:54:42 -07003075// consumeFloatSliceIface wire decodes a []float32 value as a repeated Float.
3076func consumeFloatSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3077 sp := ival.(*[]float32)
3078 if wtyp == wire.BytesType {
3079 s := *sp
3080 b, n = wire.ConsumeBytes(b)
3081 if n < 0 {
3082 return nil, 0, wire.ParseError(n)
3083 }
3084 for len(b) > 0 {
3085 v, n := wire.ConsumeFixed32(b)
3086 if n < 0 {
3087 return nil, 0, wire.ParseError(n)
3088 }
3089 s = append(s, math.Float32frombits(v))
3090 b = b[n:]
3091 }
3092 *sp = s
3093 return ival, n, nil
3094 }
3095 if wtyp != wire.Fixed32Type {
3096 return nil, 0, errUnknown
3097 }
3098 v, n := wire.ConsumeFixed32(b)
3099 if n < 0 {
3100 return nil, 0, wire.ParseError(n)
3101 }
3102 *sp = append(*sp, math.Float32frombits(v))
3103 return ival, n, nil
3104}
3105
Damien Neilc37adef2019-04-01 13:49:56 -07003106var coderFloatSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003107 size: sizeFloatSliceIface,
3108 marshal: appendFloatSliceIface,
3109 unmarshal: consumeFloatSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003110}
3111
Damien Neil7492a092019-07-10 15:23:29 -07003112// sizeFloatPackedSliceIface returns the size of wire encoding a []float32 value as a packed repeated Float.
3113func sizeFloatPackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3114 s := *ival.(*[]float32)
3115 if len(s) == 0 {
3116 return 0
3117 }
3118 n := len(s) * wire.SizeFixed32()
3119 return tagsize + wire.SizeBytes(n)
3120}
3121
3122// appendFloatPackedSliceIface encodes a []float32 value as a packed repeated Float.
3123func appendFloatPackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3124 s := *ival.(*[]float32)
3125 if len(s) == 0 {
3126 return b, nil
3127 }
3128 b = wire.AppendVarint(b, wiretag)
3129 n := len(s) * wire.SizeFixed32()
3130 b = wire.AppendVarint(b, uint64(n))
3131 for _, v := range s {
3132 b = wire.AppendFixed32(b, math.Float32bits(v))
3133 }
3134 return b, nil
3135}
3136
3137var coderFloatPackedSliceIface = ifaceCoderFuncs{
3138 size: sizeFloatPackedSliceIface,
3139 marshal: appendFloatPackedSliceIface,
3140 unmarshal: consumeFloatSliceIface,
3141}
3142
Damien Neilc37adef2019-04-01 13:49:56 -07003143// sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
3144func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
3145
3146 return tagsize + wire.SizeFixed64()
3147}
3148
3149// appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
3150func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3151 v := *p.Int64()
3152 b = wire.AppendVarint(b, wiretag)
3153 b = wire.AppendFixed64(b, uint64(v))
3154 return b, nil
3155}
3156
Damien Neile91877d2019-06-27 10:54:42 -07003157// consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
3158func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3159 if wtyp != wire.Fixed64Type {
3160 return 0, errUnknown
3161 }
3162 v, n := wire.ConsumeFixed64(b)
3163 if n < 0 {
3164 return 0, wire.ParseError(n)
3165 }
3166 *p.Int64() = int64(v)
3167 return n, nil
3168}
3169
Damien Neilc37adef2019-04-01 13:49:56 -07003170var coderSfixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003171 size: sizeSfixed64,
3172 marshal: appendSfixed64,
3173 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003174}
3175
Joe Tsaic51e2e02019-07-13 00:44:41 -07003176// sizeSfixed64NoZero returns the size of wire encoding a int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003177// The zero value is not encoded.
3178func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3179 v := *p.Int64()
3180 if v == 0 {
3181 return 0
3182 }
3183 return tagsize + wire.SizeFixed64()
3184}
3185
Joe Tsaic51e2e02019-07-13 00:44:41 -07003186// appendSfixed64NoZero wire encodes a int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003187// The zero value is not encoded.
3188func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3189 v := *p.Int64()
3190 if v == 0 {
3191 return b, nil
3192 }
3193 b = wire.AppendVarint(b, wiretag)
3194 b = wire.AppendFixed64(b, uint64(v))
3195 return b, nil
3196}
3197
3198var coderSfixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003199 size: sizeSfixed64NoZero,
3200 marshal: appendSfixed64NoZero,
3201 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003202}
3203
3204// sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
3205// It panics if the pointer is nil.
3206func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
3207 return tagsize + wire.SizeFixed64()
3208}
3209
Damien Neile91877d2019-06-27 10:54:42 -07003210// appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003211// It panics if the pointer is nil.
3212func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3213 v := **p.Int64Ptr()
3214 b = wire.AppendVarint(b, wiretag)
3215 b = wire.AppendFixed64(b, uint64(v))
3216 return b, nil
3217}
3218
Damien Neile91877d2019-06-27 10:54:42 -07003219// consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
3220func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3221 if wtyp != wire.Fixed64Type {
3222 return 0, errUnknown
3223 }
3224 v, n := wire.ConsumeFixed64(b)
3225 if n < 0 {
3226 return 0, wire.ParseError(n)
3227 }
3228 vp := p.Int64Ptr()
3229 if *vp == nil {
3230 *vp = new(int64)
3231 }
3232 **vp = int64(v)
3233 return n, nil
3234}
3235
Damien Neilc37adef2019-04-01 13:49:56 -07003236var coderSfixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003237 size: sizeSfixed64Ptr,
3238 marshal: appendSfixed64Ptr,
3239 unmarshal: consumeSfixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07003240}
3241
3242// sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
3243func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
3244 s := *p.Int64Slice()
3245 size = len(s) * (tagsize + wire.SizeFixed64())
3246 return size
3247}
3248
3249// appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
3250func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3251 s := *p.Int64Slice()
3252 for _, v := range s {
3253 b = wire.AppendVarint(b, wiretag)
3254 b = wire.AppendFixed64(b, uint64(v))
3255 }
3256 return b, nil
3257}
3258
Damien Neile91877d2019-06-27 10:54:42 -07003259// consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
3260func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3261 sp := p.Int64Slice()
3262 if wtyp == wire.BytesType {
3263 s := *sp
3264 b, n = wire.ConsumeBytes(b)
3265 if n < 0 {
3266 return 0, wire.ParseError(n)
3267 }
3268 for len(b) > 0 {
3269 v, n := wire.ConsumeFixed64(b)
3270 if n < 0 {
3271 return 0, wire.ParseError(n)
3272 }
3273 s = append(s, int64(v))
3274 b = b[n:]
3275 }
3276 *sp = s
3277 return n, nil
3278 }
3279 if wtyp != wire.Fixed64Type {
3280 return 0, errUnknown
3281 }
3282 v, n := wire.ConsumeFixed64(b)
3283 if n < 0 {
3284 return 0, wire.ParseError(n)
3285 }
3286 *sp = append(*sp, int64(v))
3287 return n, nil
3288}
3289
Damien Neilc37adef2019-04-01 13:49:56 -07003290var coderSfixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003291 size: sizeSfixed64Slice,
3292 marshal: appendSfixed64Slice,
3293 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003294}
3295
3296// sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
3297func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3298 s := *p.Int64Slice()
3299 if len(s) == 0 {
3300 return 0
3301 }
3302 n := len(s) * wire.SizeFixed64()
3303 return tagsize + wire.SizeBytes(n)
3304}
3305
3306// appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
3307func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3308 s := *p.Int64Slice()
3309 if len(s) == 0 {
3310 return b, nil
3311 }
3312 b = wire.AppendVarint(b, wiretag)
3313 n := len(s) * wire.SizeFixed64()
3314 b = wire.AppendVarint(b, uint64(n))
3315 for _, v := range s {
3316 b = wire.AppendFixed64(b, uint64(v))
3317 }
3318 return b, nil
3319}
3320
3321var coderSfixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003322 size: sizeSfixed64PackedSlice,
3323 marshal: appendSfixed64PackedSlice,
3324 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003325}
3326
3327// sizeSfixed64Iface returns the size of wire encoding a int64 value as a Sfixed64.
3328func sizeSfixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
3329 return tagsize + wire.SizeFixed64()
3330}
3331
3332// appendSfixed64Iface encodes a int64 value as a Sfixed64.
3333func appendSfixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3334 v := ival.(int64)
3335 b = wire.AppendVarint(b, wiretag)
3336 b = wire.AppendFixed64(b, uint64(v))
3337 return b, nil
3338}
3339
Damien Neile91877d2019-06-27 10:54:42 -07003340// consumeSfixed64Iface decodes a int64 value as a Sfixed64.
3341func consumeSfixed64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3342 if wtyp != wire.Fixed64Type {
3343 return nil, 0, errUnknown
3344 }
3345 v, n := wire.ConsumeFixed64(b)
3346 if n < 0 {
3347 return nil, 0, wire.ParseError(n)
3348 }
3349 return int64(v), n, nil
3350}
3351
Damien Neilc37adef2019-04-01 13:49:56 -07003352var coderSfixed64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003353 size: sizeSfixed64Iface,
3354 marshal: appendSfixed64Iface,
3355 unmarshal: consumeSfixed64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07003356}
3357
3358// sizeSfixed64SliceIface returns the size of wire encoding a []int64 value as a repeated Sfixed64.
3359func sizeSfixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3360 s := *ival.(*[]int64)
3361 size = len(s) * (tagsize + wire.SizeFixed64())
3362 return size
3363}
3364
3365// appendSfixed64SliceIface encodes a []int64 value as a repeated Sfixed64.
3366func appendSfixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3367 s := *ival.(*[]int64)
3368 for _, v := range s {
3369 b = wire.AppendVarint(b, wiretag)
3370 b = wire.AppendFixed64(b, uint64(v))
3371 }
3372 return b, nil
3373}
3374
Damien Neile91877d2019-06-27 10:54:42 -07003375// consumeSfixed64SliceIface wire decodes a []int64 value as a repeated Sfixed64.
3376func consumeSfixed64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3377 sp := ival.(*[]int64)
3378 if wtyp == wire.BytesType {
3379 s := *sp
3380 b, n = wire.ConsumeBytes(b)
3381 if n < 0 {
3382 return nil, 0, wire.ParseError(n)
3383 }
3384 for len(b) > 0 {
3385 v, n := wire.ConsumeFixed64(b)
3386 if n < 0 {
3387 return nil, 0, wire.ParseError(n)
3388 }
3389 s = append(s, int64(v))
3390 b = b[n:]
3391 }
3392 *sp = s
3393 return ival, n, nil
3394 }
3395 if wtyp != wire.Fixed64Type {
3396 return nil, 0, errUnknown
3397 }
3398 v, n := wire.ConsumeFixed64(b)
3399 if n < 0 {
3400 return nil, 0, wire.ParseError(n)
3401 }
3402 *sp = append(*sp, int64(v))
3403 return ival, n, nil
3404}
3405
Damien Neilc37adef2019-04-01 13:49:56 -07003406var coderSfixed64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003407 size: sizeSfixed64SliceIface,
3408 marshal: appendSfixed64SliceIface,
3409 unmarshal: consumeSfixed64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003410}
3411
Damien Neil7492a092019-07-10 15:23:29 -07003412// sizeSfixed64PackedSliceIface returns the size of wire encoding a []int64 value as a packed repeated Sfixed64.
3413func sizeSfixed64PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3414 s := *ival.(*[]int64)
3415 if len(s) == 0 {
3416 return 0
3417 }
3418 n := len(s) * wire.SizeFixed64()
3419 return tagsize + wire.SizeBytes(n)
3420}
3421
3422// appendSfixed64PackedSliceIface encodes a []int64 value as a packed repeated Sfixed64.
3423func appendSfixed64PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3424 s := *ival.(*[]int64)
3425 if len(s) == 0 {
3426 return b, nil
3427 }
3428 b = wire.AppendVarint(b, wiretag)
3429 n := len(s) * wire.SizeFixed64()
3430 b = wire.AppendVarint(b, uint64(n))
3431 for _, v := range s {
3432 b = wire.AppendFixed64(b, uint64(v))
3433 }
3434 return b, nil
3435}
3436
3437var coderSfixed64PackedSliceIface = ifaceCoderFuncs{
3438 size: sizeSfixed64PackedSliceIface,
3439 marshal: appendSfixed64PackedSliceIface,
3440 unmarshal: consumeSfixed64SliceIface,
3441}
3442
Damien Neilc37adef2019-04-01 13:49:56 -07003443// sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
3444func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
3445
3446 return tagsize + wire.SizeFixed64()
3447}
3448
3449// appendFixed64 wire encodes a uint64 pointer as a Fixed64.
3450func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3451 v := *p.Uint64()
3452 b = wire.AppendVarint(b, wiretag)
3453 b = wire.AppendFixed64(b, v)
3454 return b, nil
3455}
3456
Damien Neile91877d2019-06-27 10:54:42 -07003457// consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
3458func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3459 if wtyp != wire.Fixed64Type {
3460 return 0, errUnknown
3461 }
3462 v, n := wire.ConsumeFixed64(b)
3463 if n < 0 {
3464 return 0, wire.ParseError(n)
3465 }
3466 *p.Uint64() = v
3467 return n, nil
3468}
3469
Damien Neilc37adef2019-04-01 13:49:56 -07003470var coderFixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003471 size: sizeFixed64,
3472 marshal: appendFixed64,
3473 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003474}
3475
Joe Tsaic51e2e02019-07-13 00:44:41 -07003476// sizeFixed64NoZero returns the size of wire encoding a uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003477// The zero value is not encoded.
3478func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3479 v := *p.Uint64()
3480 if v == 0 {
3481 return 0
3482 }
3483 return tagsize + wire.SizeFixed64()
3484}
3485
Joe Tsaic51e2e02019-07-13 00:44:41 -07003486// appendFixed64NoZero wire encodes a uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003487// The zero value is not encoded.
3488func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3489 v := *p.Uint64()
3490 if v == 0 {
3491 return b, nil
3492 }
3493 b = wire.AppendVarint(b, wiretag)
3494 b = wire.AppendFixed64(b, v)
3495 return b, nil
3496}
3497
3498var coderFixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003499 size: sizeFixed64NoZero,
3500 marshal: appendFixed64NoZero,
3501 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003502}
3503
3504// sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
3505// It panics if the pointer is nil.
3506func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
3507 return tagsize + wire.SizeFixed64()
3508}
3509
Damien Neile91877d2019-06-27 10:54:42 -07003510// appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003511// It panics if the pointer is nil.
3512func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3513 v := **p.Uint64Ptr()
3514 b = wire.AppendVarint(b, wiretag)
3515 b = wire.AppendFixed64(b, v)
3516 return b, nil
3517}
3518
Damien Neile91877d2019-06-27 10:54:42 -07003519// consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
3520func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3521 if wtyp != wire.Fixed64Type {
3522 return 0, errUnknown
3523 }
3524 v, n := wire.ConsumeFixed64(b)
3525 if n < 0 {
3526 return 0, wire.ParseError(n)
3527 }
3528 vp := p.Uint64Ptr()
3529 if *vp == nil {
3530 *vp = new(uint64)
3531 }
3532 **vp = v
3533 return n, nil
3534}
3535
Damien Neilc37adef2019-04-01 13:49:56 -07003536var coderFixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003537 size: sizeFixed64Ptr,
3538 marshal: appendFixed64Ptr,
3539 unmarshal: consumeFixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07003540}
3541
3542// sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
3543func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
3544 s := *p.Uint64Slice()
3545 size = len(s) * (tagsize + wire.SizeFixed64())
3546 return size
3547}
3548
3549// appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
3550func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3551 s := *p.Uint64Slice()
3552 for _, v := range s {
3553 b = wire.AppendVarint(b, wiretag)
3554 b = wire.AppendFixed64(b, v)
3555 }
3556 return b, nil
3557}
3558
Damien Neile91877d2019-06-27 10:54:42 -07003559// consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
3560func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3561 sp := p.Uint64Slice()
3562 if wtyp == wire.BytesType {
3563 s := *sp
3564 b, n = wire.ConsumeBytes(b)
3565 if n < 0 {
3566 return 0, wire.ParseError(n)
3567 }
3568 for len(b) > 0 {
3569 v, n := wire.ConsumeFixed64(b)
3570 if n < 0 {
3571 return 0, wire.ParseError(n)
3572 }
3573 s = append(s, v)
3574 b = b[n:]
3575 }
3576 *sp = s
3577 return n, nil
3578 }
3579 if wtyp != wire.Fixed64Type {
3580 return 0, errUnknown
3581 }
3582 v, n := wire.ConsumeFixed64(b)
3583 if n < 0 {
3584 return 0, wire.ParseError(n)
3585 }
3586 *sp = append(*sp, v)
3587 return n, nil
3588}
3589
Damien Neilc37adef2019-04-01 13:49:56 -07003590var coderFixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003591 size: sizeFixed64Slice,
3592 marshal: appendFixed64Slice,
3593 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003594}
3595
3596// sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
3597func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3598 s := *p.Uint64Slice()
3599 if len(s) == 0 {
3600 return 0
3601 }
3602 n := len(s) * wire.SizeFixed64()
3603 return tagsize + wire.SizeBytes(n)
3604}
3605
3606// appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
3607func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3608 s := *p.Uint64Slice()
3609 if len(s) == 0 {
3610 return b, nil
3611 }
3612 b = wire.AppendVarint(b, wiretag)
3613 n := len(s) * wire.SizeFixed64()
3614 b = wire.AppendVarint(b, uint64(n))
3615 for _, v := range s {
3616 b = wire.AppendFixed64(b, v)
3617 }
3618 return b, nil
3619}
3620
3621var coderFixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003622 size: sizeFixed64PackedSlice,
3623 marshal: appendFixed64PackedSlice,
3624 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003625}
3626
3627// sizeFixed64Iface returns the size of wire encoding a uint64 value as a Fixed64.
3628func sizeFixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
3629 return tagsize + wire.SizeFixed64()
3630}
3631
3632// appendFixed64Iface encodes a uint64 value as a Fixed64.
3633func appendFixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3634 v := ival.(uint64)
3635 b = wire.AppendVarint(b, wiretag)
3636 b = wire.AppendFixed64(b, v)
3637 return b, nil
3638}
3639
Damien Neile91877d2019-06-27 10:54:42 -07003640// consumeFixed64Iface decodes a uint64 value as a Fixed64.
3641func consumeFixed64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3642 if wtyp != wire.Fixed64Type {
3643 return nil, 0, errUnknown
3644 }
3645 v, n := wire.ConsumeFixed64(b)
3646 if n < 0 {
3647 return nil, 0, wire.ParseError(n)
3648 }
3649 return v, n, nil
3650}
3651
Damien Neilc37adef2019-04-01 13:49:56 -07003652var coderFixed64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003653 size: sizeFixed64Iface,
3654 marshal: appendFixed64Iface,
3655 unmarshal: consumeFixed64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07003656}
3657
3658// sizeFixed64SliceIface returns the size of wire encoding a []uint64 value as a repeated Fixed64.
3659func sizeFixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3660 s := *ival.(*[]uint64)
3661 size = len(s) * (tagsize + wire.SizeFixed64())
3662 return size
3663}
3664
3665// appendFixed64SliceIface encodes a []uint64 value as a repeated Fixed64.
3666func appendFixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3667 s := *ival.(*[]uint64)
3668 for _, v := range s {
3669 b = wire.AppendVarint(b, wiretag)
3670 b = wire.AppendFixed64(b, v)
3671 }
3672 return b, nil
3673}
3674
Damien Neile91877d2019-06-27 10:54:42 -07003675// consumeFixed64SliceIface wire decodes a []uint64 value as a repeated Fixed64.
3676func consumeFixed64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3677 sp := ival.(*[]uint64)
3678 if wtyp == wire.BytesType {
3679 s := *sp
3680 b, n = wire.ConsumeBytes(b)
3681 if n < 0 {
3682 return nil, 0, wire.ParseError(n)
3683 }
3684 for len(b) > 0 {
3685 v, n := wire.ConsumeFixed64(b)
3686 if n < 0 {
3687 return nil, 0, wire.ParseError(n)
3688 }
3689 s = append(s, v)
3690 b = b[n:]
3691 }
3692 *sp = s
3693 return ival, n, nil
3694 }
3695 if wtyp != wire.Fixed64Type {
3696 return nil, 0, errUnknown
3697 }
3698 v, n := wire.ConsumeFixed64(b)
3699 if n < 0 {
3700 return nil, 0, wire.ParseError(n)
3701 }
3702 *sp = append(*sp, v)
3703 return ival, n, nil
3704}
3705
Damien Neilc37adef2019-04-01 13:49:56 -07003706var coderFixed64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003707 size: sizeFixed64SliceIface,
3708 marshal: appendFixed64SliceIface,
3709 unmarshal: consumeFixed64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003710}
3711
Damien Neil7492a092019-07-10 15:23:29 -07003712// sizeFixed64PackedSliceIface returns the size of wire encoding a []uint64 value as a packed repeated Fixed64.
3713func sizeFixed64PackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3714 s := *ival.(*[]uint64)
3715 if len(s) == 0 {
3716 return 0
3717 }
3718 n := len(s) * wire.SizeFixed64()
3719 return tagsize + wire.SizeBytes(n)
3720}
3721
3722// appendFixed64PackedSliceIface encodes a []uint64 value as a packed repeated Fixed64.
3723func appendFixed64PackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3724 s := *ival.(*[]uint64)
3725 if len(s) == 0 {
3726 return b, nil
3727 }
3728 b = wire.AppendVarint(b, wiretag)
3729 n := len(s) * wire.SizeFixed64()
3730 b = wire.AppendVarint(b, uint64(n))
3731 for _, v := range s {
3732 b = wire.AppendFixed64(b, v)
3733 }
3734 return b, nil
3735}
3736
3737var coderFixed64PackedSliceIface = ifaceCoderFuncs{
3738 size: sizeFixed64PackedSliceIface,
3739 marshal: appendFixed64PackedSliceIface,
3740 unmarshal: consumeFixed64SliceIface,
3741}
3742
Damien Neilc37adef2019-04-01 13:49:56 -07003743// sizeDouble returns the size of wire encoding a float64 pointer as a Double.
3744func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
3745
3746 return tagsize + wire.SizeFixed64()
3747}
3748
3749// appendDouble wire encodes a float64 pointer as a Double.
3750func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3751 v := *p.Float64()
3752 b = wire.AppendVarint(b, wiretag)
3753 b = wire.AppendFixed64(b, math.Float64bits(v))
3754 return b, nil
3755}
3756
Damien Neile91877d2019-06-27 10:54:42 -07003757// consumeDouble wire decodes a float64 pointer as a Double.
3758func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3759 if wtyp != wire.Fixed64Type {
3760 return 0, errUnknown
3761 }
3762 v, n := wire.ConsumeFixed64(b)
3763 if n < 0 {
3764 return 0, wire.ParseError(n)
3765 }
3766 *p.Float64() = math.Float64frombits(v)
3767 return n, nil
3768}
3769
Damien Neilc37adef2019-04-01 13:49:56 -07003770var coderDouble = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003771 size: sizeDouble,
3772 marshal: appendDouble,
3773 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07003774}
3775
Joe Tsaic51e2e02019-07-13 00:44:41 -07003776// sizeDoubleNoZero returns the size of wire encoding a float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07003777// The zero value is not encoded.
3778func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3779 v := *p.Float64()
3780 if v == 0 && !math.Signbit(float64(v)) {
3781 return 0
3782 }
3783 return tagsize + wire.SizeFixed64()
3784}
3785
Joe Tsaic51e2e02019-07-13 00:44:41 -07003786// appendDoubleNoZero wire encodes a float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07003787// The zero value is not encoded.
3788func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3789 v := *p.Float64()
3790 if v == 0 && !math.Signbit(float64(v)) {
3791 return b, nil
3792 }
3793 b = wire.AppendVarint(b, wiretag)
3794 b = wire.AppendFixed64(b, math.Float64bits(v))
3795 return b, nil
3796}
3797
3798var coderDoubleNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003799 size: sizeDoubleNoZero,
3800 marshal: appendDoubleNoZero,
3801 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07003802}
3803
3804// sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
3805// It panics if the pointer is nil.
3806func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
3807 return tagsize + wire.SizeFixed64()
3808}
3809
Damien Neile91877d2019-06-27 10:54:42 -07003810// appendDoublePtr wire encodes a *float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07003811// It panics if the pointer is nil.
3812func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3813 v := **p.Float64Ptr()
3814 b = wire.AppendVarint(b, wiretag)
3815 b = wire.AppendFixed64(b, math.Float64bits(v))
3816 return b, nil
3817}
3818
Damien Neile91877d2019-06-27 10:54:42 -07003819// consumeDoublePtr wire decodes a *float64 pointer as a Double.
3820func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3821 if wtyp != wire.Fixed64Type {
3822 return 0, errUnknown
3823 }
3824 v, n := wire.ConsumeFixed64(b)
3825 if n < 0 {
3826 return 0, wire.ParseError(n)
3827 }
3828 vp := p.Float64Ptr()
3829 if *vp == nil {
3830 *vp = new(float64)
3831 }
3832 **vp = math.Float64frombits(v)
3833 return n, nil
3834}
3835
Damien Neilc37adef2019-04-01 13:49:56 -07003836var coderDoublePtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003837 size: sizeDoublePtr,
3838 marshal: appendDoublePtr,
3839 unmarshal: consumeDoublePtr,
Damien Neilc37adef2019-04-01 13:49:56 -07003840}
3841
3842// sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
3843func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3844 s := *p.Float64Slice()
3845 size = len(s) * (tagsize + wire.SizeFixed64())
3846 return size
3847}
3848
3849// appendDoubleSlice encodes a []float64 pointer as a repeated Double.
3850func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3851 s := *p.Float64Slice()
3852 for _, v := range s {
3853 b = wire.AppendVarint(b, wiretag)
3854 b = wire.AppendFixed64(b, math.Float64bits(v))
3855 }
3856 return b, nil
3857}
3858
Damien Neile91877d2019-06-27 10:54:42 -07003859// consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
3860func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3861 sp := p.Float64Slice()
3862 if wtyp == wire.BytesType {
3863 s := *sp
3864 b, n = wire.ConsumeBytes(b)
3865 if n < 0 {
3866 return 0, wire.ParseError(n)
3867 }
3868 for len(b) > 0 {
3869 v, n := wire.ConsumeFixed64(b)
3870 if n < 0 {
3871 return 0, wire.ParseError(n)
3872 }
3873 s = append(s, math.Float64frombits(v))
3874 b = b[n:]
3875 }
3876 *sp = s
3877 return n, nil
3878 }
3879 if wtyp != wire.Fixed64Type {
3880 return 0, errUnknown
3881 }
3882 v, n := wire.ConsumeFixed64(b)
3883 if n < 0 {
3884 return 0, wire.ParseError(n)
3885 }
3886 *sp = append(*sp, math.Float64frombits(v))
3887 return n, nil
3888}
3889
Damien Neilc37adef2019-04-01 13:49:56 -07003890var coderDoubleSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003891 size: sizeDoubleSlice,
3892 marshal: appendDoubleSlice,
3893 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003894}
3895
3896// sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
3897func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3898 s := *p.Float64Slice()
3899 if len(s) == 0 {
3900 return 0
3901 }
3902 n := len(s) * wire.SizeFixed64()
3903 return tagsize + wire.SizeBytes(n)
3904}
3905
3906// appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
3907func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3908 s := *p.Float64Slice()
3909 if len(s) == 0 {
3910 return b, nil
3911 }
3912 b = wire.AppendVarint(b, wiretag)
3913 n := len(s) * wire.SizeFixed64()
3914 b = wire.AppendVarint(b, uint64(n))
3915 for _, v := range s {
3916 b = wire.AppendFixed64(b, math.Float64bits(v))
3917 }
3918 return b, nil
3919}
3920
3921var coderDoublePackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003922 size: sizeDoublePackedSlice,
3923 marshal: appendDoublePackedSlice,
3924 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003925}
3926
3927// sizeDoubleIface returns the size of wire encoding a float64 value as a Double.
3928func sizeDoubleIface(ival interface{}, tagsize int, _ marshalOptions) int {
3929 return tagsize + wire.SizeFixed64()
3930}
3931
3932// appendDoubleIface encodes a float64 value as a Double.
3933func appendDoubleIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3934 v := ival.(float64)
3935 b = wire.AppendVarint(b, wiretag)
3936 b = wire.AppendFixed64(b, math.Float64bits(v))
3937 return b, nil
3938}
3939
Damien Neile91877d2019-06-27 10:54:42 -07003940// consumeDoubleIface decodes a float64 value as a Double.
3941func consumeDoubleIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3942 if wtyp != wire.Fixed64Type {
3943 return nil, 0, errUnknown
3944 }
3945 v, n := wire.ConsumeFixed64(b)
3946 if n < 0 {
3947 return nil, 0, wire.ParseError(n)
3948 }
3949 return math.Float64frombits(v), n, nil
3950}
3951
Damien Neilc37adef2019-04-01 13:49:56 -07003952var coderDoubleIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003953 size: sizeDoubleIface,
3954 marshal: appendDoubleIface,
3955 unmarshal: consumeDoubleIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003956}
3957
3958// sizeDoubleSliceIface returns the size of wire encoding a []float64 value as a repeated Double.
3959func sizeDoubleSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3960 s := *ival.(*[]float64)
3961 size = len(s) * (tagsize + wire.SizeFixed64())
3962 return size
3963}
3964
3965// appendDoubleSliceIface encodes a []float64 value as a repeated Double.
3966func appendDoubleSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3967 s := *ival.(*[]float64)
3968 for _, v := range s {
3969 b = wire.AppendVarint(b, wiretag)
3970 b = wire.AppendFixed64(b, math.Float64bits(v))
3971 }
3972 return b, nil
3973}
3974
Damien Neile91877d2019-06-27 10:54:42 -07003975// consumeDoubleSliceIface wire decodes a []float64 value as a repeated Double.
3976func consumeDoubleSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3977 sp := ival.(*[]float64)
3978 if wtyp == wire.BytesType {
3979 s := *sp
3980 b, n = wire.ConsumeBytes(b)
3981 if n < 0 {
3982 return nil, 0, wire.ParseError(n)
3983 }
3984 for len(b) > 0 {
3985 v, n := wire.ConsumeFixed64(b)
3986 if n < 0 {
3987 return nil, 0, wire.ParseError(n)
3988 }
3989 s = append(s, math.Float64frombits(v))
3990 b = b[n:]
3991 }
3992 *sp = s
3993 return ival, n, nil
3994 }
3995 if wtyp != wire.Fixed64Type {
3996 return nil, 0, errUnknown
3997 }
3998 v, n := wire.ConsumeFixed64(b)
3999 if n < 0 {
4000 return nil, 0, wire.ParseError(n)
4001 }
4002 *sp = append(*sp, math.Float64frombits(v))
4003 return ival, n, nil
4004}
4005
Damien Neilc37adef2019-04-01 13:49:56 -07004006var coderDoubleSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004007 size: sizeDoubleSliceIface,
4008 marshal: appendDoubleSliceIface,
4009 unmarshal: consumeDoubleSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07004010}
4011
Damien Neil7492a092019-07-10 15:23:29 -07004012// sizeDoublePackedSliceIface returns the size of wire encoding a []float64 value as a packed repeated Double.
4013func sizeDoublePackedSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
4014 s := *ival.(*[]float64)
4015 if len(s) == 0 {
4016 return 0
4017 }
4018 n := len(s) * wire.SizeFixed64()
4019 return tagsize + wire.SizeBytes(n)
4020}
4021
4022// appendDoublePackedSliceIface encodes a []float64 value as a packed repeated Double.
4023func appendDoublePackedSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4024 s := *ival.(*[]float64)
4025 if len(s) == 0 {
4026 return b, nil
4027 }
4028 b = wire.AppendVarint(b, wiretag)
4029 n := len(s) * wire.SizeFixed64()
4030 b = wire.AppendVarint(b, uint64(n))
4031 for _, v := range s {
4032 b = wire.AppendFixed64(b, math.Float64bits(v))
4033 }
4034 return b, nil
4035}
4036
4037var coderDoublePackedSliceIface = ifaceCoderFuncs{
4038 size: sizeDoublePackedSliceIface,
4039 marshal: appendDoublePackedSliceIface,
4040 unmarshal: consumeDoubleSliceIface,
4041}
4042
Damien Neilc37adef2019-04-01 13:49:56 -07004043// sizeString returns the size of wire encoding a string pointer as a String.
4044func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
4045 v := *p.String()
Damien Neilcedb5952019-06-21 12:04:07 -07004046 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004047}
4048
4049// appendString wire encodes a string pointer as a String.
4050func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4051 v := *p.String()
4052 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004053 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004054 return b, nil
4055}
4056
Damien Neile91877d2019-06-27 10:54:42 -07004057// consumeString wire decodes a string pointer as a String.
4058func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4059 if wtyp != wire.BytesType {
4060 return 0, errUnknown
4061 }
4062 v, n := wire.ConsumeString(b)
4063 if n < 0 {
4064 return 0, wire.ParseError(n)
4065 }
4066 *p.String() = v
4067 return n, nil
4068}
4069
Damien Neilc37adef2019-04-01 13:49:56 -07004070var coderString = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004071 size: sizeString,
4072 marshal: appendString,
4073 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07004074}
4075
Joe Tsaic51e2e02019-07-13 00:44:41 -07004076// appendStringValidateUTF8 wire encodes a string pointer as a String.
4077func appendStringValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4078 v := *p.String()
4079 b = wire.AppendVarint(b, wiretag)
4080 b = wire.AppendString(b, v)
4081 if !utf8.ValidString(v) {
4082 return b, errInvalidUTF8{}
4083 }
4084 return b, nil
4085}
4086
4087// consumeStringValidateUTF8 wire decodes a string pointer as a String.
4088func consumeStringValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4089 if wtyp != wire.BytesType {
4090 return 0, errUnknown
4091 }
4092 v, n := wire.ConsumeString(b)
4093 if n < 0 {
4094 return 0, wire.ParseError(n)
4095 }
4096 if !utf8.ValidString(v) {
4097 return 0, errInvalidUTF8{}
4098 }
4099 *p.String() = v
4100 return n, nil
4101}
4102
4103var coderStringValidateUTF8 = pointerCoderFuncs{
4104 size: sizeString,
4105 marshal: appendStringValidateUTF8,
4106 unmarshal: consumeStringValidateUTF8,
4107}
4108
4109// sizeStringNoZero returns the size of wire encoding a string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004110// The zero value is not encoded.
4111func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
4112 v := *p.String()
4113 if len(v) == 0 {
4114 return 0
4115 }
Damien Neilcedb5952019-06-21 12:04:07 -07004116 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004117}
4118
Joe Tsaic51e2e02019-07-13 00:44:41 -07004119// appendStringNoZero wire encodes a string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004120// The zero value is not encoded.
4121func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4122 v := *p.String()
4123 if len(v) == 0 {
4124 return b, nil
4125 }
4126 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004127 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004128 return b, nil
4129}
4130
4131var coderStringNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004132 size: sizeStringNoZero,
4133 marshal: appendStringNoZero,
4134 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07004135}
4136
Joe Tsaic51e2e02019-07-13 00:44:41 -07004137// appendStringNoZeroValidateUTF8 wire encodes a string pointer as a String.
4138// The zero value is not encoded.
4139func appendStringNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4140 v := *p.String()
4141 if len(v) == 0 {
4142 return b, nil
4143 }
4144 b = wire.AppendVarint(b, wiretag)
4145 b = wire.AppendString(b, v)
4146 if !utf8.ValidString(v) {
4147 return b, errInvalidUTF8{}
4148 }
4149 return b, nil
4150}
4151
4152var coderStringNoZeroValidateUTF8 = pointerCoderFuncs{
4153 size: sizeStringNoZero,
4154 marshal: appendStringNoZeroValidateUTF8,
4155 unmarshal: consumeStringValidateUTF8,
4156}
4157
Damien Neilc37adef2019-04-01 13:49:56 -07004158// sizeStringPtr returns the size of wire encoding a *string pointer as a String.
4159// It panics if the pointer is nil.
4160func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
4161 v := **p.StringPtr()
Damien Neilcedb5952019-06-21 12:04:07 -07004162 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004163}
4164
Damien Neile91877d2019-06-27 10:54:42 -07004165// appendStringPtr wire encodes a *string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004166// It panics if the pointer is nil.
4167func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4168 v := **p.StringPtr()
4169 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004170 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004171 return b, nil
4172}
4173
Damien Neile91877d2019-06-27 10:54:42 -07004174// consumeStringPtr wire decodes a *string pointer as a String.
4175func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4176 if wtyp != wire.BytesType {
4177 return 0, errUnknown
4178 }
4179 v, n := wire.ConsumeString(b)
4180 if n < 0 {
4181 return 0, wire.ParseError(n)
4182 }
4183 vp := p.StringPtr()
4184 if *vp == nil {
4185 *vp = new(string)
4186 }
4187 **vp = v
4188 return n, nil
4189}
4190
Damien Neilc37adef2019-04-01 13:49:56 -07004191var coderStringPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004192 size: sizeStringPtr,
4193 marshal: appendStringPtr,
4194 unmarshal: consumeStringPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07004195}
4196
4197// sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
4198func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4199 s := *p.StringSlice()
4200 for _, v := range s {
Damien Neilcedb5952019-06-21 12:04:07 -07004201 size += tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004202 }
4203 return size
4204}
4205
4206// appendStringSlice encodes a []string pointer as a repeated String.
4207func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4208 s := *p.StringSlice()
4209 for _, v := range s {
4210 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004211 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004212 }
4213 return b, nil
4214}
4215
Damien Neile91877d2019-06-27 10:54:42 -07004216// consumeStringSlice wire decodes a []string pointer as a repeated String.
4217func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4218 sp := p.StringSlice()
4219 if wtyp != wire.BytesType {
4220 return 0, errUnknown
4221 }
4222 v, n := wire.ConsumeString(b)
4223 if n < 0 {
4224 return 0, wire.ParseError(n)
4225 }
4226 *sp = append(*sp, v)
4227 return n, nil
4228}
4229
Damien Neilc37adef2019-04-01 13:49:56 -07004230var coderStringSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004231 size: sizeStringSlice,
4232 marshal: appendStringSlice,
4233 unmarshal: consumeStringSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004234}
4235
Joe Tsaic51e2e02019-07-13 00:44:41 -07004236// appendStringSliceValidateUTF8 encodes a []string pointer as a repeated String.
4237func appendStringSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4238 s := *p.StringSlice()
4239 for _, v := range s {
4240 b = wire.AppendVarint(b, wiretag)
4241 b = wire.AppendString(b, v)
4242 if !utf8.ValidString(v) {
4243 return b, errInvalidUTF8{}
4244 }
4245 }
4246 return b, nil
4247}
4248
4249// consumeStringSliceValidateUTF8 wire decodes a []string pointer as a repeated String.
4250func consumeStringSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4251 sp := p.StringSlice()
4252 if wtyp != wire.BytesType {
4253 return 0, errUnknown
4254 }
4255 v, n := wire.ConsumeString(b)
4256 if n < 0 {
4257 return 0, wire.ParseError(n)
4258 }
4259 if !utf8.ValidString(v) {
4260 return 0, errInvalidUTF8{}
4261 }
4262 *sp = append(*sp, v)
4263 return n, nil
4264}
4265
4266var coderStringSliceValidateUTF8 = pointerCoderFuncs{
4267 size: sizeStringSlice,
4268 marshal: appendStringSliceValidateUTF8,
4269 unmarshal: consumeStringSliceValidateUTF8,
4270}
4271
Damien Neilc37adef2019-04-01 13:49:56 -07004272// sizeStringIface returns the size of wire encoding a string value as a String.
4273func sizeStringIface(ival interface{}, tagsize int, _ marshalOptions) int {
4274 v := ival.(string)
Damien Neilcedb5952019-06-21 12:04:07 -07004275 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004276}
4277
4278// appendStringIface encodes a string value as a String.
4279func appendStringIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4280 v := ival.(string)
4281 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004282 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004283 return b, nil
4284}
4285
Damien Neile91877d2019-06-27 10:54:42 -07004286// consumeStringIface decodes a string value as a String.
4287func consumeStringIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
4288 if wtyp != wire.BytesType {
4289 return nil, 0, errUnknown
4290 }
4291 v, n := wire.ConsumeString(b)
4292 if n < 0 {
4293 return nil, 0, wire.ParseError(n)
4294 }
4295 return v, n, nil
4296}
4297
Damien Neilc37adef2019-04-01 13:49:56 -07004298var coderStringIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004299 size: sizeStringIface,
4300 marshal: appendStringIface,
4301 unmarshal: consumeStringIface,
Damien Neilc37adef2019-04-01 13:49:56 -07004302}
4303
Joe Tsaic51e2e02019-07-13 00:44:41 -07004304// appendStringIfaceValidateUTF8 encodes a string value as a String.
4305func appendStringIfaceValidateUTF8(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4306 v := ival.(string)
4307 b = wire.AppendVarint(b, wiretag)
4308 b = wire.AppendString(b, v)
4309 if !utf8.ValidString(v) {
4310 return b, errInvalidUTF8{}
4311 }
4312 return b, nil
4313}
4314
4315// consumeStringIfaceValidateUTF8 decodes a string value as a String.
4316func consumeStringIfaceValidateUTF8(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
4317 if wtyp != wire.BytesType {
4318 return nil, 0, errUnknown
4319 }
4320 v, n := wire.ConsumeString(b)
4321 if n < 0 {
4322 return nil, 0, wire.ParseError(n)
4323 }
4324 if !utf8.ValidString(v) {
4325 return nil, 0, errInvalidUTF8{}
4326 }
4327 return v, n, nil
4328}
4329
4330var coderStringIfaceValidateUTF8 = ifaceCoderFuncs{
4331 size: sizeStringIface,
4332 marshal: appendStringIfaceValidateUTF8,
4333 unmarshal: consumeStringIfaceValidateUTF8,
4334}
4335
Damien Neilc37adef2019-04-01 13:49:56 -07004336// sizeStringSliceIface returns the size of wire encoding a []string value as a repeated String.
4337func sizeStringSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
4338 s := *ival.(*[]string)
4339 for _, v := range s {
Damien Neilcedb5952019-06-21 12:04:07 -07004340 size += tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004341 }
4342 return size
4343}
4344
4345// appendStringSliceIface encodes a []string value as a repeated String.
4346func appendStringSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4347 s := *ival.(*[]string)
4348 for _, v := range s {
4349 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004350 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004351 }
4352 return b, nil
4353}
4354
Damien Neile91877d2019-06-27 10:54:42 -07004355// consumeStringSliceIface wire decodes a []string value as a repeated String.
4356func consumeStringSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
4357 sp := ival.(*[]string)
4358 if wtyp != wire.BytesType {
4359 return nil, 0, errUnknown
4360 }
4361 v, n := wire.ConsumeString(b)
4362 if n < 0 {
4363 return nil, 0, wire.ParseError(n)
4364 }
4365 *sp = append(*sp, v)
4366 return ival, n, nil
4367}
4368
Damien Neilc37adef2019-04-01 13:49:56 -07004369var coderStringSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004370 size: sizeStringSliceIface,
4371 marshal: appendStringSliceIface,
4372 unmarshal: consumeStringSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07004373}
4374
4375// sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
4376func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
4377 v := *p.Bytes()
4378 return tagsize + wire.SizeBytes(len(v))
4379}
4380
4381// appendBytes wire encodes a []byte pointer as a Bytes.
4382func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4383 v := *p.Bytes()
4384 b = wire.AppendVarint(b, wiretag)
4385 b = wire.AppendBytes(b, v)
4386 return b, nil
4387}
4388
Damien Neile91877d2019-06-27 10:54:42 -07004389// consumeBytes wire decodes a []byte pointer as a Bytes.
4390func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4391 if wtyp != wire.BytesType {
4392 return 0, errUnknown
4393 }
4394 v, n := wire.ConsumeBytes(b)
4395 if n < 0 {
4396 return 0, wire.ParseError(n)
4397 }
4398 *p.Bytes() = append(([]byte)(nil), v...)
4399 return n, nil
4400}
4401
Damien Neilc37adef2019-04-01 13:49:56 -07004402var coderBytes = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004403 size: sizeBytes,
4404 marshal: appendBytes,
4405 unmarshal: consumeBytes,
Damien Neilc37adef2019-04-01 13:49:56 -07004406}
4407
Joe Tsaic51e2e02019-07-13 00:44:41 -07004408// appendBytesValidateUTF8 wire encodes a []byte pointer as a Bytes.
4409func appendBytesValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4410 v := *p.Bytes()
4411 b = wire.AppendVarint(b, wiretag)
4412 b = wire.AppendBytes(b, v)
4413 if !utf8.Valid(v) {
4414 return b, errInvalidUTF8{}
4415 }
4416 return b, nil
4417}
4418
4419// consumeBytesValidateUTF8 wire decodes a []byte pointer as a Bytes.
4420func consumeBytesValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4421 if wtyp != wire.BytesType {
4422 return 0, errUnknown
4423 }
4424 v, n := wire.ConsumeBytes(b)
4425 if n < 0 {
4426 return 0, wire.ParseError(n)
4427 }
4428 if !utf8.Valid(v) {
4429 return 0, errInvalidUTF8{}
4430 }
4431 *p.Bytes() = append(([]byte)(nil), v...)
4432 return n, nil
4433}
4434
4435var coderBytesValidateUTF8 = pointerCoderFuncs{
4436 size: sizeBytes,
4437 marshal: appendBytesValidateUTF8,
4438 unmarshal: consumeBytesValidateUTF8,
4439}
4440
4441// sizeBytesNoZero returns the size of wire encoding a []byte pointer as a Bytes.
Damien Neilc37adef2019-04-01 13:49:56 -07004442// The zero value is not encoded.
4443func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
4444 v := *p.Bytes()
4445 if len(v) == 0 {
4446 return 0
4447 }
4448 return tagsize + wire.SizeBytes(len(v))
4449}
4450
Joe Tsaic51e2e02019-07-13 00:44:41 -07004451// appendBytesNoZero wire encodes a []byte pointer as a Bytes.
Damien Neilc37adef2019-04-01 13:49:56 -07004452// The zero value is not encoded.
4453func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4454 v := *p.Bytes()
4455 if len(v) == 0 {
4456 return b, nil
4457 }
4458 b = wire.AppendVarint(b, wiretag)
4459 b = wire.AppendBytes(b, v)
4460 return b, nil
4461}
4462
4463var coderBytesNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004464 size: sizeBytesNoZero,
4465 marshal: appendBytesNoZero,
4466 unmarshal: consumeBytes,
Damien Neilc37adef2019-04-01 13:49:56 -07004467}
4468
Joe Tsaic51e2e02019-07-13 00:44:41 -07004469// appendBytesNoZeroValidateUTF8 wire encodes a []byte pointer as a Bytes.
4470// The zero value is not encoded.
4471func appendBytesNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4472 v := *p.Bytes()
4473 if len(v) == 0 {
4474 return b, nil
4475 }
4476 b = wire.AppendVarint(b, wiretag)
4477 b = wire.AppendBytes(b, v)
4478 if !utf8.Valid(v) {
4479 return b, errInvalidUTF8{}
4480 }
4481 return b, nil
4482}
4483
4484var coderBytesNoZeroValidateUTF8 = pointerCoderFuncs{
4485 size: sizeBytesNoZero,
4486 marshal: appendBytesNoZeroValidateUTF8,
4487 unmarshal: consumeBytesValidateUTF8,
4488}
4489
Damien Neilc37adef2019-04-01 13:49:56 -07004490// sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
4491func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4492 s := *p.BytesSlice()
4493 for _, v := range s {
4494 size += tagsize + wire.SizeBytes(len(v))
4495 }
4496 return size
4497}
4498
4499// appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
4500func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4501 s := *p.BytesSlice()
4502 for _, v := range s {
4503 b = wire.AppendVarint(b, wiretag)
4504 b = wire.AppendBytes(b, v)
4505 }
4506 return b, nil
4507}
4508
Damien Neile91877d2019-06-27 10:54:42 -07004509// consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
4510func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4511 sp := p.BytesSlice()
4512 if wtyp != wire.BytesType {
4513 return 0, errUnknown
4514 }
4515 v, n := wire.ConsumeBytes(b)
4516 if n < 0 {
4517 return 0, wire.ParseError(n)
4518 }
4519 *sp = append(*sp, append(([]byte)(nil), v...))
4520 return n, nil
4521}
4522
Damien Neilc37adef2019-04-01 13:49:56 -07004523var coderBytesSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004524 size: sizeBytesSlice,
4525 marshal: appendBytesSlice,
4526 unmarshal: consumeBytesSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004527}
4528
Joe Tsaic51e2e02019-07-13 00:44:41 -07004529// appendBytesSliceValidateUTF8 encodes a [][]byte pointer as a repeated Bytes.
4530func appendBytesSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4531 s := *p.BytesSlice()
4532 for _, v := range s {
4533 b = wire.AppendVarint(b, wiretag)
4534 b = wire.AppendBytes(b, v)
4535 if !utf8.Valid(v) {
4536 return b, errInvalidUTF8{}
4537 }
4538 }
4539 return b, nil
4540}
4541
4542// consumeBytesSliceValidateUTF8 wire decodes a [][]byte pointer as a repeated Bytes.
4543func consumeBytesSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
4544 sp := p.BytesSlice()
4545 if wtyp != wire.BytesType {
4546 return 0, errUnknown
4547 }
4548 v, n := wire.ConsumeBytes(b)
4549 if n < 0 {
4550 return 0, wire.ParseError(n)
4551 }
4552 if !utf8.Valid(v) {
4553 return 0, errInvalidUTF8{}
4554 }
4555 *sp = append(*sp, append(([]byte)(nil), v...))
4556 return n, nil
4557}
4558
4559var coderBytesSliceValidateUTF8 = pointerCoderFuncs{
4560 size: sizeBytesSlice,
4561 marshal: appendBytesSliceValidateUTF8,
4562 unmarshal: consumeBytesSliceValidateUTF8,
4563}
4564
Damien Neilc37adef2019-04-01 13:49:56 -07004565// sizeBytesIface returns the size of wire encoding a []byte value as a Bytes.
4566func sizeBytesIface(ival interface{}, tagsize int, _ marshalOptions) int {
4567 v := ival.([]byte)
4568 return tagsize + wire.SizeBytes(len(v))
4569}
4570
4571// appendBytesIface encodes a []byte value as a Bytes.
4572func appendBytesIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4573 v := ival.([]byte)
4574 b = wire.AppendVarint(b, wiretag)
4575 b = wire.AppendBytes(b, v)
4576 return b, nil
4577}
4578
Damien Neile91877d2019-06-27 10:54:42 -07004579// consumeBytesIface decodes a []byte value as a Bytes.
4580func consumeBytesIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
4581 if wtyp != wire.BytesType {
4582 return nil, 0, errUnknown
4583 }
4584 v, n := wire.ConsumeBytes(b)
4585 if n < 0 {
4586 return nil, 0, wire.ParseError(n)
4587 }
4588 return append(([]byte)(nil), v...), n, nil
4589}
4590
Damien Neilc37adef2019-04-01 13:49:56 -07004591var coderBytesIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004592 size: sizeBytesIface,
4593 marshal: appendBytesIface,
4594 unmarshal: consumeBytesIface,
Damien Neilc37adef2019-04-01 13:49:56 -07004595}
4596
Joe Tsaic51e2e02019-07-13 00:44:41 -07004597// appendBytesIfaceValidateUTF8 encodes a []byte value as a Bytes.
4598func appendBytesIfaceValidateUTF8(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4599 v := ival.([]byte)
4600 b = wire.AppendVarint(b, wiretag)
4601 b = wire.AppendBytes(b, v)
4602 if !utf8.Valid(v) {
4603 return b, errInvalidUTF8{}
4604 }
4605 return b, nil
4606}
4607
4608// consumeBytesIfaceValidateUTF8 decodes a []byte value as a Bytes.
4609func consumeBytesIfaceValidateUTF8(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
4610 if wtyp != wire.BytesType {
4611 return nil, 0, errUnknown
4612 }
4613 v, n := wire.ConsumeBytes(b)
4614 if n < 0 {
4615 return nil, 0, wire.ParseError(n)
4616 }
4617 if !utf8.Valid(v) {
4618 return nil, 0, errInvalidUTF8{}
4619 }
4620 return append(([]byte)(nil), v...), n, nil
4621}
4622
4623var coderBytesIfaceValidateUTF8 = ifaceCoderFuncs{
4624 size: sizeBytesIface,
4625 marshal: appendBytesIfaceValidateUTF8,
4626 unmarshal: consumeBytesIfaceValidateUTF8,
4627}
4628
Damien Neilc37adef2019-04-01 13:49:56 -07004629// sizeBytesSliceIface returns the size of wire encoding a [][]byte value as a repeated Bytes.
4630func sizeBytesSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
4631 s := *ival.(*[][]byte)
4632 for _, v := range s {
4633 size += tagsize + wire.SizeBytes(len(v))
4634 }
4635 return size
4636}
4637
4638// appendBytesSliceIface encodes a [][]byte value as a repeated Bytes.
4639func appendBytesSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
4640 s := *ival.(*[][]byte)
4641 for _, v := range s {
4642 b = wire.AppendVarint(b, wiretag)
4643 b = wire.AppendBytes(b, v)
4644 }
4645 return b, nil
4646}
4647
Damien Neile91877d2019-06-27 10:54:42 -07004648// consumeBytesSliceIface wire decodes a [][]byte value as a repeated Bytes.
4649func consumeBytesSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
4650 sp := ival.(*[][]byte)
4651 if wtyp != wire.BytesType {
4652 return nil, 0, errUnknown
4653 }
4654 v, n := wire.ConsumeBytes(b)
4655 if n < 0 {
4656 return nil, 0, wire.ParseError(n)
4657 }
4658 *sp = append(*sp, append(([]byte)(nil), v...))
4659 return ival, n, nil
4660}
4661
Damien Neilc37adef2019-04-01 13:49:56 -07004662var coderBytesSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004663 size: sizeBytesSliceIface,
4664 marshal: appendBytesSliceIface,
4665 unmarshal: consumeBytesSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07004666}
4667
4668var wireTypes = map[protoreflect.Kind]wire.Type{
4669 protoreflect.BoolKind: wire.VarintType,
4670 protoreflect.EnumKind: wire.VarintType,
4671 protoreflect.Int32Kind: wire.VarintType,
4672 protoreflect.Sint32Kind: wire.VarintType,
4673 protoreflect.Uint32Kind: wire.VarintType,
4674 protoreflect.Int64Kind: wire.VarintType,
4675 protoreflect.Sint64Kind: wire.VarintType,
4676 protoreflect.Uint64Kind: wire.VarintType,
4677 protoreflect.Sfixed32Kind: wire.Fixed32Type,
4678 protoreflect.Fixed32Kind: wire.Fixed32Type,
4679 protoreflect.FloatKind: wire.Fixed32Type,
4680 protoreflect.Sfixed64Kind: wire.Fixed64Type,
4681 protoreflect.Fixed64Kind: wire.Fixed64Type,
4682 protoreflect.DoubleKind: wire.Fixed64Type,
4683 protoreflect.StringKind: wire.BytesType,
4684 protoreflect.BytesKind: wire.BytesType,
4685 protoreflect.MessageKind: wire.BytesType,
4686 protoreflect.GroupKind: wire.StartGroupType,
4687}