blob: f04e3c52b5fa0ae6720852673fcb2655e6419470 [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"
11
12 "google.golang.org/protobuf/internal/encoding/wire"
13 "google.golang.org/protobuf/reflect/protoreflect"
14)
15
16// sizeBool returns the size of wire encoding a bool pointer as a Bool.
17func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
18 v := *p.Bool()
19 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
20}
21
22// appendBool wire encodes a bool pointer as a Bool.
23func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
24 v := *p.Bool()
25 b = wire.AppendVarint(b, wiretag)
26 b = wire.AppendVarint(b, wire.EncodeBool(v))
27 return b, nil
28}
29
Damien Neile91877d2019-06-27 10:54:42 -070030// consumeBool wire decodes a bool pointer as a Bool.
31func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
32 if wtyp != wire.VarintType {
33 return 0, errUnknown
34 }
35 v, n := wire.ConsumeVarint(b)
36 if n < 0 {
37 return 0, wire.ParseError(n)
38 }
39 *p.Bool() = wire.DecodeBool(v)
40 return n, nil
41}
42
Damien Neilc37adef2019-04-01 13:49:56 -070043var coderBool = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070044 size: sizeBool,
45 marshal: appendBool,
46 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070047}
48
49// sizeBool returns the size of wire encoding a bool pointer as a Bool.
50// The zero value is not encoded.
51func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
52 v := *p.Bool()
53 if v == false {
54 return 0
55 }
56 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
57}
58
59// appendBool wire encodes a bool pointer as a Bool.
60// The zero value is not encoded.
61func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
62 v := *p.Bool()
63 if v == false {
64 return b, nil
65 }
66 b = wire.AppendVarint(b, wiretag)
67 b = wire.AppendVarint(b, wire.EncodeBool(v))
68 return b, nil
69}
70
71var coderBoolNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070072 size: sizeBoolNoZero,
73 marshal: appendBoolNoZero,
74 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070075}
76
77// sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
78// It panics if the pointer is nil.
79func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
80 v := **p.BoolPtr()
81 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
82}
83
Damien Neile91877d2019-06-27 10:54:42 -070084// appendBoolPtr wire encodes a *bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070085// It panics if the pointer is nil.
86func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
87 v := **p.BoolPtr()
88 b = wire.AppendVarint(b, wiretag)
89 b = wire.AppendVarint(b, wire.EncodeBool(v))
90 return b, nil
91}
92
Damien Neile91877d2019-06-27 10:54:42 -070093// consumeBoolPtr wire decodes a *bool pointer as a Bool.
94func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
95 if wtyp != wire.VarintType {
96 return 0, errUnknown
97 }
98 v, n := wire.ConsumeVarint(b)
99 if n < 0 {
100 return 0, wire.ParseError(n)
101 }
102 vp := p.BoolPtr()
103 if *vp == nil {
104 *vp = new(bool)
105 }
106 **vp = wire.DecodeBool(v)
107 return n, nil
108}
109
Damien Neilc37adef2019-04-01 13:49:56 -0700110var coderBoolPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700111 size: sizeBoolPtr,
112 marshal: appendBoolPtr,
113 unmarshal: consumeBoolPtr,
Damien Neilc37adef2019-04-01 13:49:56 -0700114}
115
116// sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
117func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
118 s := *p.BoolSlice()
119 for _, v := range s {
120 size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
121 }
122 return size
123}
124
125// appendBoolSlice encodes a []bool pointer as a repeated Bool.
126func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
127 s := *p.BoolSlice()
128 for _, v := range s {
129 b = wire.AppendVarint(b, wiretag)
130 b = wire.AppendVarint(b, wire.EncodeBool(v))
131 }
132 return b, nil
133}
134
Damien Neile91877d2019-06-27 10:54:42 -0700135// consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
136func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
137 sp := p.BoolSlice()
138 if wtyp == wire.BytesType {
139 s := *sp
140 b, n = wire.ConsumeBytes(b)
141 if n < 0 {
142 return 0, wire.ParseError(n)
143 }
144 for len(b) > 0 {
145 v, n := wire.ConsumeVarint(b)
146 if n < 0 {
147 return 0, wire.ParseError(n)
148 }
149 s = append(s, wire.DecodeBool(v))
150 b = b[n:]
151 }
152 *sp = s
153 return n, nil
154 }
155 if wtyp != wire.VarintType {
156 return 0, errUnknown
157 }
158 v, n := wire.ConsumeVarint(b)
159 if n < 0 {
160 return 0, wire.ParseError(n)
161 }
162 *sp = append(*sp, wire.DecodeBool(v))
163 return n, nil
164}
165
Damien Neilc37adef2019-04-01 13:49:56 -0700166var coderBoolSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700167 size: sizeBoolSlice,
168 marshal: appendBoolSlice,
169 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700170}
171
172// sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
173func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
174 s := *p.BoolSlice()
175 if len(s) == 0 {
176 return 0
177 }
178 n := 0
179 for _, v := range s {
180 n += wire.SizeVarint(wire.EncodeBool(v))
181 }
182 return tagsize + wire.SizeBytes(n)
183}
184
185// appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
186func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
187 s := *p.BoolSlice()
188 if len(s) == 0 {
189 return b, nil
190 }
191 b = wire.AppendVarint(b, wiretag)
192 n := 0
193 for _, v := range s {
194 n += wire.SizeVarint(wire.EncodeBool(v))
195 }
196 b = wire.AppendVarint(b, uint64(n))
197 for _, v := range s {
198 b = wire.AppendVarint(b, wire.EncodeBool(v))
199 }
200 return b, nil
201}
202
203var coderBoolPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700204 size: sizeBoolPackedSlice,
205 marshal: appendBoolPackedSlice,
206 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700207}
208
209// sizeBoolIface returns the size of wire encoding a bool value as a Bool.
210func sizeBoolIface(ival interface{}, tagsize int, _ marshalOptions) int {
211 v := ival.(bool)
212 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
213}
214
215// appendBoolIface encodes a bool value as a Bool.
216func appendBoolIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
217 v := ival.(bool)
218 b = wire.AppendVarint(b, wiretag)
219 b = wire.AppendVarint(b, wire.EncodeBool(v))
220 return b, nil
221}
222
Damien Neile91877d2019-06-27 10:54:42 -0700223// consumeBoolIface decodes a bool value as a Bool.
224func consumeBoolIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
225 if wtyp != wire.VarintType {
226 return nil, 0, errUnknown
227 }
228 v, n := wire.ConsumeVarint(b)
229 if n < 0 {
230 return nil, 0, wire.ParseError(n)
231 }
232 return wire.DecodeBool(v), n, nil
233}
234
Damien Neilc37adef2019-04-01 13:49:56 -0700235var coderBoolIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700236 size: sizeBoolIface,
237 marshal: appendBoolIface,
238 unmarshal: consumeBoolIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700239}
240
241// sizeBoolSliceIface returns the size of wire encoding a []bool value as a repeated Bool.
242func sizeBoolSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
243 s := *ival.(*[]bool)
244 for _, v := range s {
245 size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
246 }
247 return size
248}
249
250// appendBoolSliceIface encodes a []bool value as a repeated Bool.
251func appendBoolSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
252 s := *ival.(*[]bool)
253 for _, v := range s {
254 b = wire.AppendVarint(b, wiretag)
255 b = wire.AppendVarint(b, wire.EncodeBool(v))
256 }
257 return b, nil
258}
259
Damien Neile91877d2019-06-27 10:54:42 -0700260// consumeBoolSliceIface wire decodes a []bool value as a repeated Bool.
261func consumeBoolSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
262 sp := ival.(*[]bool)
263 if wtyp == wire.BytesType {
264 s := *sp
265 b, n = wire.ConsumeBytes(b)
266 if n < 0 {
267 return nil, 0, wire.ParseError(n)
268 }
269 for len(b) > 0 {
270 v, n := wire.ConsumeVarint(b)
271 if n < 0 {
272 return nil, 0, wire.ParseError(n)
273 }
274 s = append(s, wire.DecodeBool(v))
275 b = b[n:]
276 }
277 *sp = s
278 return ival, n, nil
279 }
280 if wtyp != wire.VarintType {
281 return nil, 0, errUnknown
282 }
283 v, n := wire.ConsumeVarint(b)
284 if n < 0 {
285 return nil, 0, wire.ParseError(n)
286 }
287 *sp = append(*sp, wire.DecodeBool(v))
288 return ival, n, nil
289}
290
Damien Neilc37adef2019-04-01 13:49:56 -0700291var coderBoolSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700292 size: sizeBoolSliceIface,
293 marshal: appendBoolSliceIface,
294 unmarshal: consumeBoolSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700295}
296
297// sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
298func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
299 v := *p.Int32()
300 return tagsize + wire.SizeVarint(uint64(v))
301}
302
303// appendInt32 wire encodes a int32 pointer as a Int32.
304func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
305 v := *p.Int32()
306 b = wire.AppendVarint(b, wiretag)
307 b = wire.AppendVarint(b, uint64(v))
308 return b, nil
309}
310
Damien Neile91877d2019-06-27 10:54:42 -0700311// consumeInt32 wire decodes a int32 pointer as a Int32.
312func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
313 if wtyp != wire.VarintType {
314 return 0, errUnknown
315 }
316 v, n := wire.ConsumeVarint(b)
317 if n < 0 {
318 return 0, wire.ParseError(n)
319 }
320 *p.Int32() = int32(v)
321 return n, nil
322}
323
Damien Neilc37adef2019-04-01 13:49:56 -0700324var coderInt32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700325 size: sizeInt32,
326 marshal: appendInt32,
327 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700328}
329
330// sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
331// The zero value is not encoded.
332func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
333 v := *p.Int32()
334 if v == 0 {
335 return 0
336 }
337 return tagsize + wire.SizeVarint(uint64(v))
338}
339
340// appendInt32 wire encodes a int32 pointer as a Int32.
341// The zero value is not encoded.
342func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
343 v := *p.Int32()
344 if v == 0 {
345 return b, nil
346 }
347 b = wire.AppendVarint(b, wiretag)
348 b = wire.AppendVarint(b, uint64(v))
349 return b, nil
350}
351
352var coderInt32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700353 size: sizeInt32NoZero,
354 marshal: appendInt32NoZero,
355 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700356}
357
358// sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
359// It panics if the pointer is nil.
360func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
361 v := **p.Int32Ptr()
362 return tagsize + wire.SizeVarint(uint64(v))
363}
364
Damien Neile91877d2019-06-27 10:54:42 -0700365// appendInt32Ptr wire encodes a *int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700366// It panics if the pointer is nil.
367func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
368 v := **p.Int32Ptr()
369 b = wire.AppendVarint(b, wiretag)
370 b = wire.AppendVarint(b, uint64(v))
371 return b, nil
372}
373
Damien Neile91877d2019-06-27 10:54:42 -0700374// consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
375func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
376 if wtyp != wire.VarintType {
377 return 0, errUnknown
378 }
379 v, n := wire.ConsumeVarint(b)
380 if n < 0 {
381 return 0, wire.ParseError(n)
382 }
383 vp := p.Int32Ptr()
384 if *vp == nil {
385 *vp = new(int32)
386 }
387 **vp = int32(v)
388 return n, nil
389}
390
Damien Neilc37adef2019-04-01 13:49:56 -0700391var coderInt32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700392 size: sizeInt32Ptr,
393 marshal: appendInt32Ptr,
394 unmarshal: consumeInt32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700395}
396
397// sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
398func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
399 s := *p.Int32Slice()
400 for _, v := range s {
401 size += tagsize + wire.SizeVarint(uint64(v))
402 }
403 return size
404}
405
406// appendInt32Slice encodes a []int32 pointer as a repeated Int32.
407func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
408 s := *p.Int32Slice()
409 for _, v := range s {
410 b = wire.AppendVarint(b, wiretag)
411 b = wire.AppendVarint(b, uint64(v))
412 }
413 return b, nil
414}
415
Damien Neile91877d2019-06-27 10:54:42 -0700416// consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
417func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
418 sp := p.Int32Slice()
419 if wtyp == wire.BytesType {
420 s := *sp
421 b, n = wire.ConsumeBytes(b)
422 if n < 0 {
423 return 0, wire.ParseError(n)
424 }
425 for len(b) > 0 {
426 v, n := wire.ConsumeVarint(b)
427 if n < 0 {
428 return 0, wire.ParseError(n)
429 }
430 s = append(s, int32(v))
431 b = b[n:]
432 }
433 *sp = s
434 return n, nil
435 }
436 if wtyp != wire.VarintType {
437 return 0, errUnknown
438 }
439 v, n := wire.ConsumeVarint(b)
440 if n < 0 {
441 return 0, wire.ParseError(n)
442 }
443 *sp = append(*sp, int32(v))
444 return n, nil
445}
446
Damien Neilc37adef2019-04-01 13:49:56 -0700447var coderInt32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700448 size: sizeInt32Slice,
449 marshal: appendInt32Slice,
450 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700451}
452
453// sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
454func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
455 s := *p.Int32Slice()
456 if len(s) == 0 {
457 return 0
458 }
459 n := 0
460 for _, v := range s {
461 n += wire.SizeVarint(uint64(v))
462 }
463 return tagsize + wire.SizeBytes(n)
464}
465
466// appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
467func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
468 s := *p.Int32Slice()
469 if len(s) == 0 {
470 return b, nil
471 }
472 b = wire.AppendVarint(b, wiretag)
473 n := 0
474 for _, v := range s {
475 n += wire.SizeVarint(uint64(v))
476 }
477 b = wire.AppendVarint(b, uint64(n))
478 for _, v := range s {
479 b = wire.AppendVarint(b, uint64(v))
480 }
481 return b, nil
482}
483
484var coderInt32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700485 size: sizeInt32PackedSlice,
486 marshal: appendInt32PackedSlice,
487 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700488}
489
490// sizeInt32Iface returns the size of wire encoding a int32 value as a Int32.
491func sizeInt32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
492 v := ival.(int32)
493 return tagsize + wire.SizeVarint(uint64(v))
494}
495
496// appendInt32Iface encodes a int32 value as a Int32.
497func appendInt32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
498 v := ival.(int32)
499 b = wire.AppendVarint(b, wiretag)
500 b = wire.AppendVarint(b, uint64(v))
501 return b, nil
502}
503
Damien Neile91877d2019-06-27 10:54:42 -0700504// consumeInt32Iface decodes a int32 value as a Int32.
505func consumeInt32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
506 if wtyp != wire.VarintType {
507 return nil, 0, errUnknown
508 }
509 v, n := wire.ConsumeVarint(b)
510 if n < 0 {
511 return nil, 0, wire.ParseError(n)
512 }
513 return int32(v), n, nil
514}
515
Damien Neilc37adef2019-04-01 13:49:56 -0700516var coderInt32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700517 size: sizeInt32Iface,
518 marshal: appendInt32Iface,
519 unmarshal: consumeInt32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -0700520}
521
522// sizeInt32SliceIface returns the size of wire encoding a []int32 value as a repeated Int32.
523func sizeInt32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
524 s := *ival.(*[]int32)
525 for _, v := range s {
526 size += tagsize + wire.SizeVarint(uint64(v))
527 }
528 return size
529}
530
531// appendInt32SliceIface encodes a []int32 value as a repeated Int32.
532func appendInt32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
533 s := *ival.(*[]int32)
534 for _, v := range s {
535 b = wire.AppendVarint(b, wiretag)
536 b = wire.AppendVarint(b, uint64(v))
537 }
538 return b, nil
539}
540
Damien Neile91877d2019-06-27 10:54:42 -0700541// consumeInt32SliceIface wire decodes a []int32 value as a repeated Int32.
542func consumeInt32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
543 sp := ival.(*[]int32)
544 if wtyp == wire.BytesType {
545 s := *sp
546 b, n = wire.ConsumeBytes(b)
547 if n < 0 {
548 return nil, 0, wire.ParseError(n)
549 }
550 for len(b) > 0 {
551 v, n := wire.ConsumeVarint(b)
552 if n < 0 {
553 return nil, 0, wire.ParseError(n)
554 }
555 s = append(s, int32(v))
556 b = b[n:]
557 }
558 *sp = s
559 return ival, n, nil
560 }
561 if wtyp != wire.VarintType {
562 return nil, 0, errUnknown
563 }
564 v, n := wire.ConsumeVarint(b)
565 if n < 0 {
566 return nil, 0, wire.ParseError(n)
567 }
568 *sp = append(*sp, int32(v))
569 return ival, n, nil
570}
571
Damien Neilc37adef2019-04-01 13:49:56 -0700572var coderInt32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700573 size: sizeInt32SliceIface,
574 marshal: appendInt32SliceIface,
575 unmarshal: consumeInt32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700576}
577
578// sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
579func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
580 v := *p.Int32()
581 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
582}
583
584// appendSint32 wire encodes a int32 pointer as a Sint32.
585func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
586 v := *p.Int32()
587 b = wire.AppendVarint(b, wiretag)
588 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
589 return b, nil
590}
591
Damien Neile91877d2019-06-27 10:54:42 -0700592// consumeSint32 wire decodes a int32 pointer as a Sint32.
593func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
594 if wtyp != wire.VarintType {
595 return 0, errUnknown
596 }
597 v, n := wire.ConsumeVarint(b)
598 if n < 0 {
599 return 0, wire.ParseError(n)
600 }
601 *p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
602 return n, nil
603}
604
Damien Neilc37adef2019-04-01 13:49:56 -0700605var coderSint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700606 size: sizeSint32,
607 marshal: appendSint32,
608 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700609}
610
611// sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
612// The zero value is not encoded.
613func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
614 v := *p.Int32()
615 if v == 0 {
616 return 0
617 }
618 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
619}
620
621// appendSint32 wire encodes a int32 pointer as a Sint32.
622// The zero value is not encoded.
623func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
624 v := *p.Int32()
625 if v == 0 {
626 return b, nil
627 }
628 b = wire.AppendVarint(b, wiretag)
629 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
630 return b, nil
631}
632
633var coderSint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700634 size: sizeSint32NoZero,
635 marshal: appendSint32NoZero,
636 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700637}
638
639// sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
640// It panics if the pointer is nil.
641func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
642 v := **p.Int32Ptr()
643 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
644}
645
Damien Neile91877d2019-06-27 10:54:42 -0700646// appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700647// It panics if the pointer is nil.
648func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
649 v := **p.Int32Ptr()
650 b = wire.AppendVarint(b, wiretag)
651 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
652 return b, nil
653}
654
Damien Neile91877d2019-06-27 10:54:42 -0700655// consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
656func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
657 if wtyp != wire.VarintType {
658 return 0, errUnknown
659 }
660 v, n := wire.ConsumeVarint(b)
661 if n < 0 {
662 return 0, wire.ParseError(n)
663 }
664 vp := p.Int32Ptr()
665 if *vp == nil {
666 *vp = new(int32)
667 }
668 **vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
669 return n, nil
670}
671
Damien Neilc37adef2019-04-01 13:49:56 -0700672var coderSint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700673 size: sizeSint32Ptr,
674 marshal: appendSint32Ptr,
675 unmarshal: consumeSint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700676}
677
678// sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
679func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
680 s := *p.Int32Slice()
681 for _, v := range s {
682 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
683 }
684 return size
685}
686
687// appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
688func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
689 s := *p.Int32Slice()
690 for _, v := range s {
691 b = wire.AppendVarint(b, wiretag)
692 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
693 }
694 return b, nil
695}
696
Damien Neile91877d2019-06-27 10:54:42 -0700697// consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
698func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
699 sp := p.Int32Slice()
700 if wtyp == wire.BytesType {
701 s := *sp
702 b, n = wire.ConsumeBytes(b)
703 if n < 0 {
704 return 0, wire.ParseError(n)
705 }
706 for len(b) > 0 {
707 v, n := wire.ConsumeVarint(b)
708 if n < 0 {
709 return 0, wire.ParseError(n)
710 }
711 s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
712 b = b[n:]
713 }
714 *sp = s
715 return n, nil
716 }
717 if wtyp != wire.VarintType {
718 return 0, errUnknown
719 }
720 v, n := wire.ConsumeVarint(b)
721 if n < 0 {
722 return 0, wire.ParseError(n)
723 }
724 *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
725 return n, nil
726}
727
Damien Neilc37adef2019-04-01 13:49:56 -0700728var coderSint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700729 size: sizeSint32Slice,
730 marshal: appendSint32Slice,
731 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700732}
733
734// sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
735func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
736 s := *p.Int32Slice()
737 if len(s) == 0 {
738 return 0
739 }
740 n := 0
741 for _, v := range s {
742 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
743 }
744 return tagsize + wire.SizeBytes(n)
745}
746
747// appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
748func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
749 s := *p.Int32Slice()
750 if len(s) == 0 {
751 return b, nil
752 }
753 b = wire.AppendVarint(b, wiretag)
754 n := 0
755 for _, v := range s {
756 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
757 }
758 b = wire.AppendVarint(b, uint64(n))
759 for _, v := range s {
760 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
761 }
762 return b, nil
763}
764
765var coderSint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700766 size: sizeSint32PackedSlice,
767 marshal: appendSint32PackedSlice,
768 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700769}
770
771// sizeSint32Iface returns the size of wire encoding a int32 value as a Sint32.
772func sizeSint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
773 v := ival.(int32)
774 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
775}
776
777// appendSint32Iface encodes a int32 value as a Sint32.
778func appendSint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
779 v := ival.(int32)
780 b = wire.AppendVarint(b, wiretag)
781 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
782 return b, nil
783}
784
Damien Neile91877d2019-06-27 10:54:42 -0700785// consumeSint32Iface decodes a int32 value as a Sint32.
786func consumeSint32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
787 if wtyp != wire.VarintType {
788 return nil, 0, errUnknown
789 }
790 v, n := wire.ConsumeVarint(b)
791 if n < 0 {
792 return nil, 0, wire.ParseError(n)
793 }
794 return int32(wire.DecodeZigZag(v & math.MaxUint32)), n, nil
795}
796
Damien Neilc37adef2019-04-01 13:49:56 -0700797var coderSint32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700798 size: sizeSint32Iface,
799 marshal: appendSint32Iface,
800 unmarshal: consumeSint32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -0700801}
802
803// sizeSint32SliceIface returns the size of wire encoding a []int32 value as a repeated Sint32.
804func sizeSint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
805 s := *ival.(*[]int32)
806 for _, v := range s {
807 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
808 }
809 return size
810}
811
812// appendSint32SliceIface encodes a []int32 value as a repeated Sint32.
813func appendSint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
814 s := *ival.(*[]int32)
815 for _, v := range s {
816 b = wire.AppendVarint(b, wiretag)
817 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
818 }
819 return b, nil
820}
821
Damien Neile91877d2019-06-27 10:54:42 -0700822// consumeSint32SliceIface wire decodes a []int32 value as a repeated Sint32.
823func consumeSint32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
824 sp := ival.(*[]int32)
825 if wtyp == wire.BytesType {
826 s := *sp
827 b, n = wire.ConsumeBytes(b)
828 if n < 0 {
829 return nil, 0, wire.ParseError(n)
830 }
831 for len(b) > 0 {
832 v, n := wire.ConsumeVarint(b)
833 if n < 0 {
834 return nil, 0, wire.ParseError(n)
835 }
836 s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
837 b = b[n:]
838 }
839 *sp = s
840 return ival, n, nil
841 }
842 if wtyp != wire.VarintType {
843 return nil, 0, errUnknown
844 }
845 v, n := wire.ConsumeVarint(b)
846 if n < 0 {
847 return nil, 0, wire.ParseError(n)
848 }
849 *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
850 return ival, n, nil
851}
852
Damien Neilc37adef2019-04-01 13:49:56 -0700853var coderSint32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700854 size: sizeSint32SliceIface,
855 marshal: appendSint32SliceIface,
856 unmarshal: consumeSint32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -0700857}
858
859// sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
860func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
861 v := *p.Uint32()
862 return tagsize + wire.SizeVarint(uint64(v))
863}
864
865// appendUint32 wire encodes a uint32 pointer as a Uint32.
866func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
867 v := *p.Uint32()
868 b = wire.AppendVarint(b, wiretag)
869 b = wire.AppendVarint(b, uint64(v))
870 return b, nil
871}
872
Damien Neile91877d2019-06-27 10:54:42 -0700873// consumeUint32 wire decodes a uint32 pointer as a Uint32.
874func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
875 if wtyp != wire.VarintType {
876 return 0, errUnknown
877 }
878 v, n := wire.ConsumeVarint(b)
879 if n < 0 {
880 return 0, wire.ParseError(n)
881 }
882 *p.Uint32() = uint32(v)
883 return n, nil
884}
885
Damien Neilc37adef2019-04-01 13:49:56 -0700886var coderUint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700887 size: sizeUint32,
888 marshal: appendUint32,
889 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700890}
891
892// sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
893// The zero value is not encoded.
894func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
895 v := *p.Uint32()
896 if v == 0 {
897 return 0
898 }
899 return tagsize + wire.SizeVarint(uint64(v))
900}
901
902// appendUint32 wire encodes a uint32 pointer as a Uint32.
903// The zero value is not encoded.
904func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
905 v := *p.Uint32()
906 if v == 0 {
907 return b, nil
908 }
909 b = wire.AppendVarint(b, wiretag)
910 b = wire.AppendVarint(b, uint64(v))
911 return b, nil
912}
913
914var coderUint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700915 size: sizeUint32NoZero,
916 marshal: appendUint32NoZero,
917 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700918}
919
920// sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
921// It panics if the pointer is nil.
922func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
923 v := **p.Uint32Ptr()
924 return tagsize + wire.SizeVarint(uint64(v))
925}
926
Damien Neile91877d2019-06-27 10:54:42 -0700927// appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700928// It panics if the pointer is nil.
929func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
930 v := **p.Uint32Ptr()
931 b = wire.AppendVarint(b, wiretag)
932 b = wire.AppendVarint(b, uint64(v))
933 return b, nil
934}
935
Damien Neile91877d2019-06-27 10:54:42 -0700936// consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
937func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
938 if wtyp != wire.VarintType {
939 return 0, errUnknown
940 }
941 v, n := wire.ConsumeVarint(b)
942 if n < 0 {
943 return 0, wire.ParseError(n)
944 }
945 vp := p.Uint32Ptr()
946 if *vp == nil {
947 *vp = new(uint32)
948 }
949 **vp = uint32(v)
950 return n, nil
951}
952
Damien Neilc37adef2019-04-01 13:49:56 -0700953var coderUint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700954 size: sizeUint32Ptr,
955 marshal: appendUint32Ptr,
956 unmarshal: consumeUint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700957}
958
959// sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
960func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
961 s := *p.Uint32Slice()
962 for _, v := range s {
963 size += tagsize + wire.SizeVarint(uint64(v))
964 }
965 return size
966}
967
968// appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
969func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
970 s := *p.Uint32Slice()
971 for _, v := range s {
972 b = wire.AppendVarint(b, wiretag)
973 b = wire.AppendVarint(b, uint64(v))
974 }
975 return b, nil
976}
977
Damien Neile91877d2019-06-27 10:54:42 -0700978// consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
979func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
980 sp := p.Uint32Slice()
981 if wtyp == wire.BytesType {
982 s := *sp
983 b, n = wire.ConsumeBytes(b)
984 if n < 0 {
985 return 0, wire.ParseError(n)
986 }
987 for len(b) > 0 {
988 v, n := wire.ConsumeVarint(b)
989 if n < 0 {
990 return 0, wire.ParseError(n)
991 }
992 s = append(s, uint32(v))
993 b = b[n:]
994 }
995 *sp = s
996 return n, nil
997 }
998 if wtyp != wire.VarintType {
999 return 0, errUnknown
1000 }
1001 v, n := wire.ConsumeVarint(b)
1002 if n < 0 {
1003 return 0, wire.ParseError(n)
1004 }
1005 *sp = append(*sp, uint32(v))
1006 return n, nil
1007}
1008
Damien Neilc37adef2019-04-01 13:49:56 -07001009var coderUint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001010 size: sizeUint32Slice,
1011 marshal: appendUint32Slice,
1012 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001013}
1014
1015// sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
1016func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1017 s := *p.Uint32Slice()
1018 if len(s) == 0 {
1019 return 0
1020 }
1021 n := 0
1022 for _, v := range s {
1023 n += wire.SizeVarint(uint64(v))
1024 }
1025 return tagsize + wire.SizeBytes(n)
1026}
1027
1028// appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
1029func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1030 s := *p.Uint32Slice()
1031 if len(s) == 0 {
1032 return b, nil
1033 }
1034 b = wire.AppendVarint(b, wiretag)
1035 n := 0
1036 for _, v := range s {
1037 n += wire.SizeVarint(uint64(v))
1038 }
1039 b = wire.AppendVarint(b, uint64(n))
1040 for _, v := range s {
1041 b = wire.AppendVarint(b, uint64(v))
1042 }
1043 return b, nil
1044}
1045
1046var coderUint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001047 size: sizeUint32PackedSlice,
1048 marshal: appendUint32PackedSlice,
1049 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001050}
1051
1052// sizeUint32Iface returns the size of wire encoding a uint32 value as a Uint32.
1053func sizeUint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1054 v := ival.(uint32)
1055 return tagsize + wire.SizeVarint(uint64(v))
1056}
1057
1058// appendUint32Iface encodes a uint32 value as a Uint32.
1059func appendUint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1060 v := ival.(uint32)
1061 b = wire.AppendVarint(b, wiretag)
1062 b = wire.AppendVarint(b, uint64(v))
1063 return b, nil
1064}
1065
Damien Neile91877d2019-06-27 10:54:42 -07001066// consumeUint32Iface decodes a uint32 value as a Uint32.
1067func consumeUint32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1068 if wtyp != wire.VarintType {
1069 return nil, 0, errUnknown
1070 }
1071 v, n := wire.ConsumeVarint(b)
1072 if n < 0 {
1073 return nil, 0, wire.ParseError(n)
1074 }
1075 return uint32(v), n, nil
1076}
1077
Damien Neilc37adef2019-04-01 13:49:56 -07001078var coderUint32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001079 size: sizeUint32Iface,
1080 marshal: appendUint32Iface,
1081 unmarshal: consumeUint32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001082}
1083
1084// sizeUint32SliceIface returns the size of wire encoding a []uint32 value as a repeated Uint32.
1085func sizeUint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1086 s := *ival.(*[]uint32)
1087 for _, v := range s {
1088 size += tagsize + wire.SizeVarint(uint64(v))
1089 }
1090 return size
1091}
1092
1093// appendUint32SliceIface encodes a []uint32 value as a repeated Uint32.
1094func appendUint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1095 s := *ival.(*[]uint32)
1096 for _, v := range s {
1097 b = wire.AppendVarint(b, wiretag)
1098 b = wire.AppendVarint(b, uint64(v))
1099 }
1100 return b, nil
1101}
1102
Damien Neile91877d2019-06-27 10:54:42 -07001103// consumeUint32SliceIface wire decodes a []uint32 value as a repeated Uint32.
1104func consumeUint32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1105 sp := ival.(*[]uint32)
1106 if wtyp == wire.BytesType {
1107 s := *sp
1108 b, n = wire.ConsumeBytes(b)
1109 if n < 0 {
1110 return nil, 0, wire.ParseError(n)
1111 }
1112 for len(b) > 0 {
1113 v, n := wire.ConsumeVarint(b)
1114 if n < 0 {
1115 return nil, 0, wire.ParseError(n)
1116 }
1117 s = append(s, uint32(v))
1118 b = b[n:]
1119 }
1120 *sp = s
1121 return ival, n, nil
1122 }
1123 if wtyp != wire.VarintType {
1124 return nil, 0, errUnknown
1125 }
1126 v, n := wire.ConsumeVarint(b)
1127 if n < 0 {
1128 return nil, 0, wire.ParseError(n)
1129 }
1130 *sp = append(*sp, uint32(v))
1131 return ival, n, nil
1132}
1133
Damien Neilc37adef2019-04-01 13:49:56 -07001134var coderUint32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001135 size: sizeUint32SliceIface,
1136 marshal: appendUint32SliceIface,
1137 unmarshal: consumeUint32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001138}
1139
1140// sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
1141func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
1142 v := *p.Int64()
1143 return tagsize + wire.SizeVarint(uint64(v))
1144}
1145
1146// appendInt64 wire encodes a int64 pointer as a Int64.
1147func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1148 v := *p.Int64()
1149 b = wire.AppendVarint(b, wiretag)
1150 b = wire.AppendVarint(b, uint64(v))
1151 return b, nil
1152}
1153
Damien Neile91877d2019-06-27 10:54:42 -07001154// consumeInt64 wire decodes a int64 pointer as a Int64.
1155func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1156 if wtyp != wire.VarintType {
1157 return 0, errUnknown
1158 }
1159 v, n := wire.ConsumeVarint(b)
1160 if n < 0 {
1161 return 0, wire.ParseError(n)
1162 }
1163 *p.Int64() = int64(v)
1164 return n, nil
1165}
1166
Damien Neilc37adef2019-04-01 13:49:56 -07001167var coderInt64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001168 size: sizeInt64,
1169 marshal: appendInt64,
1170 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001171}
1172
1173// sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
1174// The zero value is not encoded.
1175func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1176 v := *p.Int64()
1177 if v == 0 {
1178 return 0
1179 }
1180 return tagsize + wire.SizeVarint(uint64(v))
1181}
1182
1183// appendInt64 wire encodes a int64 pointer as a Int64.
1184// The zero value is not encoded.
1185func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1186 v := *p.Int64()
1187 if v == 0 {
1188 return b, nil
1189 }
1190 b = wire.AppendVarint(b, wiretag)
1191 b = wire.AppendVarint(b, uint64(v))
1192 return b, nil
1193}
1194
1195var coderInt64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001196 size: sizeInt64NoZero,
1197 marshal: appendInt64NoZero,
1198 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001199}
1200
1201// sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
1202// It panics if the pointer is nil.
1203func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1204 v := **p.Int64Ptr()
1205 return tagsize + wire.SizeVarint(uint64(v))
1206}
1207
Damien Neile91877d2019-06-27 10:54:42 -07001208// appendInt64Ptr wire encodes a *int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001209// It panics if the pointer is nil.
1210func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1211 v := **p.Int64Ptr()
1212 b = wire.AppendVarint(b, wiretag)
1213 b = wire.AppendVarint(b, uint64(v))
1214 return b, nil
1215}
1216
Damien Neile91877d2019-06-27 10:54:42 -07001217// consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
1218func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1219 if wtyp != wire.VarintType {
1220 return 0, errUnknown
1221 }
1222 v, n := wire.ConsumeVarint(b)
1223 if n < 0 {
1224 return 0, wire.ParseError(n)
1225 }
1226 vp := p.Int64Ptr()
1227 if *vp == nil {
1228 *vp = new(int64)
1229 }
1230 **vp = int64(v)
1231 return n, nil
1232}
1233
Damien Neilc37adef2019-04-01 13:49:56 -07001234var coderInt64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001235 size: sizeInt64Ptr,
1236 marshal: appendInt64Ptr,
1237 unmarshal: consumeInt64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001238}
1239
1240// sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
1241func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1242 s := *p.Int64Slice()
1243 for _, v := range s {
1244 size += tagsize + wire.SizeVarint(uint64(v))
1245 }
1246 return size
1247}
1248
1249// appendInt64Slice encodes a []int64 pointer as a repeated Int64.
1250func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1251 s := *p.Int64Slice()
1252 for _, v := range s {
1253 b = wire.AppendVarint(b, wiretag)
1254 b = wire.AppendVarint(b, uint64(v))
1255 }
1256 return b, nil
1257}
1258
Damien Neile91877d2019-06-27 10:54:42 -07001259// consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
1260func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1261 sp := p.Int64Slice()
1262 if wtyp == wire.BytesType {
1263 s := *sp
1264 b, n = wire.ConsumeBytes(b)
1265 if n < 0 {
1266 return 0, wire.ParseError(n)
1267 }
1268 for len(b) > 0 {
1269 v, n := wire.ConsumeVarint(b)
1270 if n < 0 {
1271 return 0, wire.ParseError(n)
1272 }
1273 s = append(s, int64(v))
1274 b = b[n:]
1275 }
1276 *sp = s
1277 return n, nil
1278 }
1279 if wtyp != wire.VarintType {
1280 return 0, errUnknown
1281 }
1282 v, n := wire.ConsumeVarint(b)
1283 if n < 0 {
1284 return 0, wire.ParseError(n)
1285 }
1286 *sp = append(*sp, int64(v))
1287 return n, nil
1288}
1289
Damien Neilc37adef2019-04-01 13:49:56 -07001290var coderInt64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001291 size: sizeInt64Slice,
1292 marshal: appendInt64Slice,
1293 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001294}
1295
1296// sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
1297func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1298 s := *p.Int64Slice()
1299 if len(s) == 0 {
1300 return 0
1301 }
1302 n := 0
1303 for _, v := range s {
1304 n += wire.SizeVarint(uint64(v))
1305 }
1306 return tagsize + wire.SizeBytes(n)
1307}
1308
1309// appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
1310func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1311 s := *p.Int64Slice()
1312 if len(s) == 0 {
1313 return b, nil
1314 }
1315 b = wire.AppendVarint(b, wiretag)
1316 n := 0
1317 for _, v := range s {
1318 n += wire.SizeVarint(uint64(v))
1319 }
1320 b = wire.AppendVarint(b, uint64(n))
1321 for _, v := range s {
1322 b = wire.AppendVarint(b, uint64(v))
1323 }
1324 return b, nil
1325}
1326
1327var coderInt64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001328 size: sizeInt64PackedSlice,
1329 marshal: appendInt64PackedSlice,
1330 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001331}
1332
1333// sizeInt64Iface returns the size of wire encoding a int64 value as a Int64.
1334func sizeInt64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1335 v := ival.(int64)
1336 return tagsize + wire.SizeVarint(uint64(v))
1337}
1338
1339// appendInt64Iface encodes a int64 value as a Int64.
1340func appendInt64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1341 v := ival.(int64)
1342 b = wire.AppendVarint(b, wiretag)
1343 b = wire.AppendVarint(b, uint64(v))
1344 return b, nil
1345}
1346
Damien Neile91877d2019-06-27 10:54:42 -07001347// consumeInt64Iface decodes a int64 value as a Int64.
1348func consumeInt64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1349 if wtyp != wire.VarintType {
1350 return nil, 0, errUnknown
1351 }
1352 v, n := wire.ConsumeVarint(b)
1353 if n < 0 {
1354 return nil, 0, wire.ParseError(n)
1355 }
1356 return int64(v), n, nil
1357}
1358
Damien Neilc37adef2019-04-01 13:49:56 -07001359var coderInt64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001360 size: sizeInt64Iface,
1361 marshal: appendInt64Iface,
1362 unmarshal: consumeInt64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001363}
1364
1365// sizeInt64SliceIface returns the size of wire encoding a []int64 value as a repeated Int64.
1366func sizeInt64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1367 s := *ival.(*[]int64)
1368 for _, v := range s {
1369 size += tagsize + wire.SizeVarint(uint64(v))
1370 }
1371 return size
1372}
1373
1374// appendInt64SliceIface encodes a []int64 value as a repeated Int64.
1375func appendInt64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1376 s := *ival.(*[]int64)
1377 for _, v := range s {
1378 b = wire.AppendVarint(b, wiretag)
1379 b = wire.AppendVarint(b, uint64(v))
1380 }
1381 return b, nil
1382}
1383
Damien Neile91877d2019-06-27 10:54:42 -07001384// consumeInt64SliceIface wire decodes a []int64 value as a repeated Int64.
1385func consumeInt64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1386 sp := ival.(*[]int64)
1387 if wtyp == wire.BytesType {
1388 s := *sp
1389 b, n = wire.ConsumeBytes(b)
1390 if n < 0 {
1391 return nil, 0, wire.ParseError(n)
1392 }
1393 for len(b) > 0 {
1394 v, n := wire.ConsumeVarint(b)
1395 if n < 0 {
1396 return nil, 0, wire.ParseError(n)
1397 }
1398 s = append(s, int64(v))
1399 b = b[n:]
1400 }
1401 *sp = s
1402 return ival, n, nil
1403 }
1404 if wtyp != wire.VarintType {
1405 return nil, 0, errUnknown
1406 }
1407 v, n := wire.ConsumeVarint(b)
1408 if n < 0 {
1409 return nil, 0, wire.ParseError(n)
1410 }
1411 *sp = append(*sp, int64(v))
1412 return ival, n, nil
1413}
1414
Damien Neilc37adef2019-04-01 13:49:56 -07001415var coderInt64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001416 size: sizeInt64SliceIface,
1417 marshal: appendInt64SliceIface,
1418 unmarshal: consumeInt64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001419}
1420
1421// sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
1422func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
1423 v := *p.Int64()
1424 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1425}
1426
1427// appendSint64 wire encodes a int64 pointer as a Sint64.
1428func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1429 v := *p.Int64()
1430 b = wire.AppendVarint(b, wiretag)
1431 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1432 return b, nil
1433}
1434
Damien Neile91877d2019-06-27 10:54:42 -07001435// consumeSint64 wire decodes a int64 pointer as a Sint64.
1436func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1437 if wtyp != wire.VarintType {
1438 return 0, errUnknown
1439 }
1440 v, n := wire.ConsumeVarint(b)
1441 if n < 0 {
1442 return 0, wire.ParseError(n)
1443 }
1444 *p.Int64() = wire.DecodeZigZag(v)
1445 return n, nil
1446}
1447
Damien Neilc37adef2019-04-01 13:49:56 -07001448var coderSint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001449 size: sizeSint64,
1450 marshal: appendSint64,
1451 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001452}
1453
1454// sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
1455// The zero value is not encoded.
1456func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1457 v := *p.Int64()
1458 if v == 0 {
1459 return 0
1460 }
1461 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1462}
1463
1464// appendSint64 wire encodes a int64 pointer as a Sint64.
1465// The zero value is not encoded.
1466func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1467 v := *p.Int64()
1468 if v == 0 {
1469 return b, nil
1470 }
1471 b = wire.AppendVarint(b, wiretag)
1472 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1473 return b, nil
1474}
1475
1476var coderSint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001477 size: sizeSint64NoZero,
1478 marshal: appendSint64NoZero,
1479 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001480}
1481
1482// sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
1483// It panics if the pointer is nil.
1484func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1485 v := **p.Int64Ptr()
1486 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1487}
1488
Damien Neile91877d2019-06-27 10:54:42 -07001489// appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001490// It panics if the pointer is nil.
1491func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1492 v := **p.Int64Ptr()
1493 b = wire.AppendVarint(b, wiretag)
1494 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1495 return b, nil
1496}
1497
Damien Neile91877d2019-06-27 10:54:42 -07001498// consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
1499func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1500 if wtyp != wire.VarintType {
1501 return 0, errUnknown
1502 }
1503 v, n := wire.ConsumeVarint(b)
1504 if n < 0 {
1505 return 0, wire.ParseError(n)
1506 }
1507 vp := p.Int64Ptr()
1508 if *vp == nil {
1509 *vp = new(int64)
1510 }
1511 **vp = wire.DecodeZigZag(v)
1512 return n, nil
1513}
1514
Damien Neilc37adef2019-04-01 13:49:56 -07001515var coderSint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001516 size: sizeSint64Ptr,
1517 marshal: appendSint64Ptr,
1518 unmarshal: consumeSint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001519}
1520
1521// sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
1522func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1523 s := *p.Int64Slice()
1524 for _, v := range s {
1525 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1526 }
1527 return size
1528}
1529
1530// appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
1531func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1532 s := *p.Int64Slice()
1533 for _, v := range s {
1534 b = wire.AppendVarint(b, wiretag)
1535 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1536 }
1537 return b, nil
1538}
1539
Damien Neile91877d2019-06-27 10:54:42 -07001540// consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
1541func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1542 sp := p.Int64Slice()
1543 if wtyp == wire.BytesType {
1544 s := *sp
1545 b, n = wire.ConsumeBytes(b)
1546 if n < 0 {
1547 return 0, wire.ParseError(n)
1548 }
1549 for len(b) > 0 {
1550 v, n := wire.ConsumeVarint(b)
1551 if n < 0 {
1552 return 0, wire.ParseError(n)
1553 }
1554 s = append(s, wire.DecodeZigZag(v))
1555 b = b[n:]
1556 }
1557 *sp = s
1558 return n, nil
1559 }
1560 if wtyp != wire.VarintType {
1561 return 0, errUnknown
1562 }
1563 v, n := wire.ConsumeVarint(b)
1564 if n < 0 {
1565 return 0, wire.ParseError(n)
1566 }
1567 *sp = append(*sp, wire.DecodeZigZag(v))
1568 return n, nil
1569}
1570
Damien Neilc37adef2019-04-01 13:49:56 -07001571var coderSint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001572 size: sizeSint64Slice,
1573 marshal: appendSint64Slice,
1574 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001575}
1576
1577// sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
1578func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1579 s := *p.Int64Slice()
1580 if len(s) == 0 {
1581 return 0
1582 }
1583 n := 0
1584 for _, v := range s {
1585 n += wire.SizeVarint(wire.EncodeZigZag(v))
1586 }
1587 return tagsize + wire.SizeBytes(n)
1588}
1589
1590// appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
1591func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1592 s := *p.Int64Slice()
1593 if len(s) == 0 {
1594 return b, nil
1595 }
1596 b = wire.AppendVarint(b, wiretag)
1597 n := 0
1598 for _, v := range s {
1599 n += wire.SizeVarint(wire.EncodeZigZag(v))
1600 }
1601 b = wire.AppendVarint(b, uint64(n))
1602 for _, v := range s {
1603 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1604 }
1605 return b, nil
1606}
1607
1608var coderSint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001609 size: sizeSint64PackedSlice,
1610 marshal: appendSint64PackedSlice,
1611 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001612}
1613
1614// sizeSint64Iface returns the size of wire encoding a int64 value as a Sint64.
1615func sizeSint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1616 v := ival.(int64)
1617 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1618}
1619
1620// appendSint64Iface encodes a int64 value as a Sint64.
1621func appendSint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1622 v := ival.(int64)
1623 b = wire.AppendVarint(b, wiretag)
1624 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1625 return b, nil
1626}
1627
Damien Neile91877d2019-06-27 10:54:42 -07001628// consumeSint64Iface decodes a int64 value as a Sint64.
1629func consumeSint64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1630 if wtyp != wire.VarintType {
1631 return nil, 0, errUnknown
1632 }
1633 v, n := wire.ConsumeVarint(b)
1634 if n < 0 {
1635 return nil, 0, wire.ParseError(n)
1636 }
1637 return wire.DecodeZigZag(v), n, nil
1638}
1639
Damien Neilc37adef2019-04-01 13:49:56 -07001640var coderSint64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001641 size: sizeSint64Iface,
1642 marshal: appendSint64Iface,
1643 unmarshal: consumeSint64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001644}
1645
1646// sizeSint64SliceIface returns the size of wire encoding a []int64 value as a repeated Sint64.
1647func sizeSint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1648 s := *ival.(*[]int64)
1649 for _, v := range s {
1650 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1651 }
1652 return size
1653}
1654
1655// appendSint64SliceIface encodes a []int64 value as a repeated Sint64.
1656func appendSint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1657 s := *ival.(*[]int64)
1658 for _, v := range s {
1659 b = wire.AppendVarint(b, wiretag)
1660 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1661 }
1662 return b, nil
1663}
1664
Damien Neile91877d2019-06-27 10:54:42 -07001665// consumeSint64SliceIface wire decodes a []int64 value as a repeated Sint64.
1666func consumeSint64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1667 sp := ival.(*[]int64)
1668 if wtyp == wire.BytesType {
1669 s := *sp
1670 b, n = wire.ConsumeBytes(b)
1671 if n < 0 {
1672 return nil, 0, wire.ParseError(n)
1673 }
1674 for len(b) > 0 {
1675 v, n := wire.ConsumeVarint(b)
1676 if n < 0 {
1677 return nil, 0, wire.ParseError(n)
1678 }
1679 s = append(s, wire.DecodeZigZag(v))
1680 b = b[n:]
1681 }
1682 *sp = s
1683 return ival, n, nil
1684 }
1685 if wtyp != wire.VarintType {
1686 return nil, 0, errUnknown
1687 }
1688 v, n := wire.ConsumeVarint(b)
1689 if n < 0 {
1690 return nil, 0, wire.ParseError(n)
1691 }
1692 *sp = append(*sp, wire.DecodeZigZag(v))
1693 return ival, n, nil
1694}
1695
Damien Neilc37adef2019-04-01 13:49:56 -07001696var coderSint64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001697 size: sizeSint64SliceIface,
1698 marshal: appendSint64SliceIface,
1699 unmarshal: consumeSint64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001700}
1701
1702// sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
1703func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
1704 v := *p.Uint64()
1705 return tagsize + wire.SizeVarint(v)
1706}
1707
1708// appendUint64 wire encodes a uint64 pointer as a Uint64.
1709func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1710 v := *p.Uint64()
1711 b = wire.AppendVarint(b, wiretag)
1712 b = wire.AppendVarint(b, v)
1713 return b, nil
1714}
1715
Damien Neile91877d2019-06-27 10:54:42 -07001716// consumeUint64 wire decodes a uint64 pointer as a Uint64.
1717func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1718 if wtyp != wire.VarintType {
1719 return 0, errUnknown
1720 }
1721 v, n := wire.ConsumeVarint(b)
1722 if n < 0 {
1723 return 0, wire.ParseError(n)
1724 }
1725 *p.Uint64() = v
1726 return n, nil
1727}
1728
Damien Neilc37adef2019-04-01 13:49:56 -07001729var coderUint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001730 size: sizeUint64,
1731 marshal: appendUint64,
1732 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001733}
1734
1735// sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
1736// The zero value is not encoded.
1737func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1738 v := *p.Uint64()
1739 if v == 0 {
1740 return 0
1741 }
1742 return tagsize + wire.SizeVarint(v)
1743}
1744
1745// appendUint64 wire encodes a uint64 pointer as a Uint64.
1746// The zero value is not encoded.
1747func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1748 v := *p.Uint64()
1749 if v == 0 {
1750 return b, nil
1751 }
1752 b = wire.AppendVarint(b, wiretag)
1753 b = wire.AppendVarint(b, v)
1754 return b, nil
1755}
1756
1757var coderUint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001758 size: sizeUint64NoZero,
1759 marshal: appendUint64NoZero,
1760 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001761}
1762
1763// sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
1764// It panics if the pointer is nil.
1765func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1766 v := **p.Uint64Ptr()
1767 return tagsize + wire.SizeVarint(v)
1768}
1769
Damien Neile91877d2019-06-27 10:54:42 -07001770// appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001771// It panics if the pointer is nil.
1772func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1773 v := **p.Uint64Ptr()
1774 b = wire.AppendVarint(b, wiretag)
1775 b = wire.AppendVarint(b, v)
1776 return b, nil
1777}
1778
Damien Neile91877d2019-06-27 10:54:42 -07001779// consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
1780func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1781 if wtyp != wire.VarintType {
1782 return 0, errUnknown
1783 }
1784 v, n := wire.ConsumeVarint(b)
1785 if n < 0 {
1786 return 0, wire.ParseError(n)
1787 }
1788 vp := p.Uint64Ptr()
1789 if *vp == nil {
1790 *vp = new(uint64)
1791 }
1792 **vp = v
1793 return n, nil
1794}
1795
Damien Neilc37adef2019-04-01 13:49:56 -07001796var coderUint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001797 size: sizeUint64Ptr,
1798 marshal: appendUint64Ptr,
1799 unmarshal: consumeUint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001800}
1801
1802// sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
1803func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1804 s := *p.Uint64Slice()
1805 for _, v := range s {
1806 size += tagsize + wire.SizeVarint(v)
1807 }
1808 return size
1809}
1810
1811// appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
1812func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1813 s := *p.Uint64Slice()
1814 for _, v := range s {
1815 b = wire.AppendVarint(b, wiretag)
1816 b = wire.AppendVarint(b, v)
1817 }
1818 return b, nil
1819}
1820
Damien Neile91877d2019-06-27 10:54:42 -07001821// consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
1822func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1823 sp := p.Uint64Slice()
1824 if wtyp == wire.BytesType {
1825 s := *sp
1826 b, n = wire.ConsumeBytes(b)
1827 if n < 0 {
1828 return 0, wire.ParseError(n)
1829 }
1830 for len(b) > 0 {
1831 v, n := wire.ConsumeVarint(b)
1832 if n < 0 {
1833 return 0, wire.ParseError(n)
1834 }
1835 s = append(s, v)
1836 b = b[n:]
1837 }
1838 *sp = s
1839 return n, nil
1840 }
1841 if wtyp != wire.VarintType {
1842 return 0, errUnknown
1843 }
1844 v, n := wire.ConsumeVarint(b)
1845 if n < 0 {
1846 return 0, wire.ParseError(n)
1847 }
1848 *sp = append(*sp, v)
1849 return n, nil
1850}
1851
Damien Neilc37adef2019-04-01 13:49:56 -07001852var coderUint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001853 size: sizeUint64Slice,
1854 marshal: appendUint64Slice,
1855 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001856}
1857
1858// sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
1859func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1860 s := *p.Uint64Slice()
1861 if len(s) == 0 {
1862 return 0
1863 }
1864 n := 0
1865 for _, v := range s {
1866 n += wire.SizeVarint(v)
1867 }
1868 return tagsize + wire.SizeBytes(n)
1869}
1870
1871// appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
1872func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1873 s := *p.Uint64Slice()
1874 if len(s) == 0 {
1875 return b, nil
1876 }
1877 b = wire.AppendVarint(b, wiretag)
1878 n := 0
1879 for _, v := range s {
1880 n += wire.SizeVarint(v)
1881 }
1882 b = wire.AppendVarint(b, uint64(n))
1883 for _, v := range s {
1884 b = wire.AppendVarint(b, v)
1885 }
1886 return b, nil
1887}
1888
1889var coderUint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001890 size: sizeUint64PackedSlice,
1891 marshal: appendUint64PackedSlice,
1892 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001893}
1894
1895// sizeUint64Iface returns the size of wire encoding a uint64 value as a Uint64.
1896func sizeUint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
1897 v := ival.(uint64)
1898 return tagsize + wire.SizeVarint(v)
1899}
1900
1901// appendUint64Iface encodes a uint64 value as a Uint64.
1902func appendUint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1903 v := ival.(uint64)
1904 b = wire.AppendVarint(b, wiretag)
1905 b = wire.AppendVarint(b, v)
1906 return b, nil
1907}
1908
Damien Neile91877d2019-06-27 10:54:42 -07001909// consumeUint64Iface decodes a uint64 value as a Uint64.
1910func consumeUint64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
1911 if wtyp != wire.VarintType {
1912 return nil, 0, errUnknown
1913 }
1914 v, n := wire.ConsumeVarint(b)
1915 if n < 0 {
1916 return nil, 0, wire.ParseError(n)
1917 }
1918 return v, n, nil
1919}
1920
Damien Neilc37adef2019-04-01 13:49:56 -07001921var coderUint64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001922 size: sizeUint64Iface,
1923 marshal: appendUint64Iface,
1924 unmarshal: consumeUint64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07001925}
1926
1927// sizeUint64SliceIface returns the size of wire encoding a []uint64 value as a repeated Uint64.
1928func sizeUint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
1929 s := *ival.(*[]uint64)
1930 for _, v := range s {
1931 size += tagsize + wire.SizeVarint(v)
1932 }
1933 return size
1934}
1935
1936// appendUint64SliceIface encodes a []uint64 value as a repeated Uint64.
1937func appendUint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
1938 s := *ival.(*[]uint64)
1939 for _, v := range s {
1940 b = wire.AppendVarint(b, wiretag)
1941 b = wire.AppendVarint(b, v)
1942 }
1943 return b, nil
1944}
1945
Damien Neile91877d2019-06-27 10:54:42 -07001946// consumeUint64SliceIface wire decodes a []uint64 value as a repeated Uint64.
1947func consumeUint64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
1948 sp := ival.(*[]uint64)
1949 if wtyp == wire.BytesType {
1950 s := *sp
1951 b, n = wire.ConsumeBytes(b)
1952 if n < 0 {
1953 return nil, 0, wire.ParseError(n)
1954 }
1955 for len(b) > 0 {
1956 v, n := wire.ConsumeVarint(b)
1957 if n < 0 {
1958 return nil, 0, wire.ParseError(n)
1959 }
1960 s = append(s, v)
1961 b = b[n:]
1962 }
1963 *sp = s
1964 return ival, n, nil
1965 }
1966 if wtyp != wire.VarintType {
1967 return nil, 0, errUnknown
1968 }
1969 v, n := wire.ConsumeVarint(b)
1970 if n < 0 {
1971 return nil, 0, wire.ParseError(n)
1972 }
1973 *sp = append(*sp, v)
1974 return ival, n, nil
1975}
1976
Damien Neilc37adef2019-04-01 13:49:56 -07001977var coderUint64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001978 size: sizeUint64SliceIface,
1979 marshal: appendUint64SliceIface,
1980 unmarshal: consumeUint64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07001981}
1982
1983// sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
1984func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
1985
1986 return tagsize + wire.SizeFixed32()
1987}
1988
1989// appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
1990func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1991 v := *p.Int32()
1992 b = wire.AppendVarint(b, wiretag)
1993 b = wire.AppendFixed32(b, uint32(v))
1994 return b, nil
1995}
1996
Damien Neile91877d2019-06-27 10:54:42 -07001997// consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
1998func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
1999 if wtyp != wire.Fixed32Type {
2000 return 0, errUnknown
2001 }
2002 v, n := wire.ConsumeFixed32(b)
2003 if n < 0 {
2004 return 0, wire.ParseError(n)
2005 }
2006 *p.Int32() = int32(v)
2007 return n, nil
2008}
2009
Damien Neilc37adef2019-04-01 13:49:56 -07002010var coderSfixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002011 size: sizeSfixed32,
2012 marshal: appendSfixed32,
2013 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002014}
2015
2016// sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
2017// The zero value is not encoded.
2018func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2019 v := *p.Int32()
2020 if v == 0 {
2021 return 0
2022 }
2023 return tagsize + wire.SizeFixed32()
2024}
2025
2026// appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
2027// The zero value is not encoded.
2028func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2029 v := *p.Int32()
2030 if v == 0 {
2031 return b, nil
2032 }
2033 b = wire.AppendVarint(b, wiretag)
2034 b = wire.AppendFixed32(b, uint32(v))
2035 return b, nil
2036}
2037
2038var coderSfixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002039 size: sizeSfixed32NoZero,
2040 marshal: appendSfixed32NoZero,
2041 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002042}
2043
2044// sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
2045// It panics if the pointer is nil.
2046func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2047 return tagsize + wire.SizeFixed32()
2048}
2049
Damien Neile91877d2019-06-27 10:54:42 -07002050// appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002051// It panics if the pointer is nil.
2052func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2053 v := **p.Int32Ptr()
2054 b = wire.AppendVarint(b, wiretag)
2055 b = wire.AppendFixed32(b, uint32(v))
2056 return b, nil
2057}
2058
Damien Neile91877d2019-06-27 10:54:42 -07002059// consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
2060func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2061 if wtyp != wire.Fixed32Type {
2062 return 0, errUnknown
2063 }
2064 v, n := wire.ConsumeFixed32(b)
2065 if n < 0 {
2066 return 0, wire.ParseError(n)
2067 }
2068 vp := p.Int32Ptr()
2069 if *vp == nil {
2070 *vp = new(int32)
2071 }
2072 **vp = int32(v)
2073 return n, nil
2074}
2075
Damien Neilc37adef2019-04-01 13:49:56 -07002076var coderSfixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002077 size: sizeSfixed32Ptr,
2078 marshal: appendSfixed32Ptr,
2079 unmarshal: consumeSfixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002080}
2081
2082// sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
2083func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2084 s := *p.Int32Slice()
2085 size = len(s) * (tagsize + wire.SizeFixed32())
2086 return size
2087}
2088
2089// appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
2090func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2091 s := *p.Int32Slice()
2092 for _, v := range s {
2093 b = wire.AppendVarint(b, wiretag)
2094 b = wire.AppendFixed32(b, uint32(v))
2095 }
2096 return b, nil
2097}
2098
Damien Neile91877d2019-06-27 10:54:42 -07002099// consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
2100func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2101 sp := p.Int32Slice()
2102 if wtyp == wire.BytesType {
2103 s := *sp
2104 b, n = wire.ConsumeBytes(b)
2105 if n < 0 {
2106 return 0, wire.ParseError(n)
2107 }
2108 for len(b) > 0 {
2109 v, n := wire.ConsumeFixed32(b)
2110 if n < 0 {
2111 return 0, wire.ParseError(n)
2112 }
2113 s = append(s, int32(v))
2114 b = b[n:]
2115 }
2116 *sp = s
2117 return n, nil
2118 }
2119 if wtyp != wire.Fixed32Type {
2120 return 0, errUnknown
2121 }
2122 v, n := wire.ConsumeFixed32(b)
2123 if n < 0 {
2124 return 0, wire.ParseError(n)
2125 }
2126 *sp = append(*sp, int32(v))
2127 return n, nil
2128}
2129
Damien Neilc37adef2019-04-01 13:49:56 -07002130var coderSfixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002131 size: sizeSfixed32Slice,
2132 marshal: appendSfixed32Slice,
2133 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002134}
2135
2136// sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
2137func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2138 s := *p.Int32Slice()
2139 if len(s) == 0 {
2140 return 0
2141 }
2142 n := len(s) * wire.SizeFixed32()
2143 return tagsize + wire.SizeBytes(n)
2144}
2145
2146// appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
2147func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2148 s := *p.Int32Slice()
2149 if len(s) == 0 {
2150 return b, nil
2151 }
2152 b = wire.AppendVarint(b, wiretag)
2153 n := len(s) * wire.SizeFixed32()
2154 b = wire.AppendVarint(b, uint64(n))
2155 for _, v := range s {
2156 b = wire.AppendFixed32(b, uint32(v))
2157 }
2158 return b, nil
2159}
2160
2161var coderSfixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002162 size: sizeSfixed32PackedSlice,
2163 marshal: appendSfixed32PackedSlice,
2164 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002165}
2166
2167// sizeSfixed32Iface returns the size of wire encoding a int32 value as a Sfixed32.
2168func sizeSfixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2169 return tagsize + wire.SizeFixed32()
2170}
2171
2172// appendSfixed32Iface encodes a int32 value as a Sfixed32.
2173func appendSfixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2174 v := ival.(int32)
2175 b = wire.AppendVarint(b, wiretag)
2176 b = wire.AppendFixed32(b, uint32(v))
2177 return b, nil
2178}
2179
Damien Neile91877d2019-06-27 10:54:42 -07002180// consumeSfixed32Iface decodes a int32 value as a Sfixed32.
2181func consumeSfixed32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2182 if wtyp != wire.Fixed32Type {
2183 return nil, 0, errUnknown
2184 }
2185 v, n := wire.ConsumeFixed32(b)
2186 if n < 0 {
2187 return nil, 0, wire.ParseError(n)
2188 }
2189 return int32(v), n, nil
2190}
2191
Damien Neilc37adef2019-04-01 13:49:56 -07002192var coderSfixed32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002193 size: sizeSfixed32Iface,
2194 marshal: appendSfixed32Iface,
2195 unmarshal: consumeSfixed32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07002196}
2197
2198// sizeSfixed32SliceIface returns the size of wire encoding a []int32 value as a repeated Sfixed32.
2199func sizeSfixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2200 s := *ival.(*[]int32)
2201 size = len(s) * (tagsize + wire.SizeFixed32())
2202 return size
2203}
2204
2205// appendSfixed32SliceIface encodes a []int32 value as a repeated Sfixed32.
2206func appendSfixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2207 s := *ival.(*[]int32)
2208 for _, v := range s {
2209 b = wire.AppendVarint(b, wiretag)
2210 b = wire.AppendFixed32(b, uint32(v))
2211 }
2212 return b, nil
2213}
2214
Damien Neile91877d2019-06-27 10:54:42 -07002215// consumeSfixed32SliceIface wire decodes a []int32 value as a repeated Sfixed32.
2216func consumeSfixed32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2217 sp := ival.(*[]int32)
2218 if wtyp == wire.BytesType {
2219 s := *sp
2220 b, n = wire.ConsumeBytes(b)
2221 if n < 0 {
2222 return nil, 0, wire.ParseError(n)
2223 }
2224 for len(b) > 0 {
2225 v, n := wire.ConsumeFixed32(b)
2226 if n < 0 {
2227 return nil, 0, wire.ParseError(n)
2228 }
2229 s = append(s, int32(v))
2230 b = b[n:]
2231 }
2232 *sp = s
2233 return ival, n, nil
2234 }
2235 if wtyp != wire.Fixed32Type {
2236 return nil, 0, errUnknown
2237 }
2238 v, n := wire.ConsumeFixed32(b)
2239 if n < 0 {
2240 return nil, 0, wire.ParseError(n)
2241 }
2242 *sp = append(*sp, int32(v))
2243 return ival, n, nil
2244}
2245
Damien Neilc37adef2019-04-01 13:49:56 -07002246var coderSfixed32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002247 size: sizeSfixed32SliceIface,
2248 marshal: appendSfixed32SliceIface,
2249 unmarshal: consumeSfixed32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002250}
2251
2252// sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
2253func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
2254
2255 return tagsize + wire.SizeFixed32()
2256}
2257
2258// appendFixed32 wire encodes a uint32 pointer as a Fixed32.
2259func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2260 v := *p.Uint32()
2261 b = wire.AppendVarint(b, wiretag)
2262 b = wire.AppendFixed32(b, v)
2263 return b, nil
2264}
2265
Damien Neile91877d2019-06-27 10:54:42 -07002266// consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
2267func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2268 if wtyp != wire.Fixed32Type {
2269 return 0, errUnknown
2270 }
2271 v, n := wire.ConsumeFixed32(b)
2272 if n < 0 {
2273 return 0, wire.ParseError(n)
2274 }
2275 *p.Uint32() = v
2276 return n, nil
2277}
2278
Damien Neilc37adef2019-04-01 13:49:56 -07002279var coderFixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002280 size: sizeFixed32,
2281 marshal: appendFixed32,
2282 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002283}
2284
2285// sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
2286// The zero value is not encoded.
2287func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2288 v := *p.Uint32()
2289 if v == 0 {
2290 return 0
2291 }
2292 return tagsize + wire.SizeFixed32()
2293}
2294
2295// appendFixed32 wire encodes a uint32 pointer as a Fixed32.
2296// The zero value is not encoded.
2297func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2298 v := *p.Uint32()
2299 if v == 0 {
2300 return b, nil
2301 }
2302 b = wire.AppendVarint(b, wiretag)
2303 b = wire.AppendFixed32(b, v)
2304 return b, nil
2305}
2306
2307var coderFixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002308 size: sizeFixed32NoZero,
2309 marshal: appendFixed32NoZero,
2310 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002311}
2312
2313// sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
2314// It panics if the pointer is nil.
2315func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2316 return tagsize + wire.SizeFixed32()
2317}
2318
Damien Neile91877d2019-06-27 10:54:42 -07002319// appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002320// It panics if the pointer is nil.
2321func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2322 v := **p.Uint32Ptr()
2323 b = wire.AppendVarint(b, wiretag)
2324 b = wire.AppendFixed32(b, v)
2325 return b, nil
2326}
2327
Damien Neile91877d2019-06-27 10:54:42 -07002328// consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
2329func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2330 if wtyp != wire.Fixed32Type {
2331 return 0, errUnknown
2332 }
2333 v, n := wire.ConsumeFixed32(b)
2334 if n < 0 {
2335 return 0, wire.ParseError(n)
2336 }
2337 vp := p.Uint32Ptr()
2338 if *vp == nil {
2339 *vp = new(uint32)
2340 }
2341 **vp = v
2342 return n, nil
2343}
2344
Damien Neilc37adef2019-04-01 13:49:56 -07002345var coderFixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002346 size: sizeFixed32Ptr,
2347 marshal: appendFixed32Ptr,
2348 unmarshal: consumeFixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002349}
2350
2351// sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
2352func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2353 s := *p.Uint32Slice()
2354 size = len(s) * (tagsize + wire.SizeFixed32())
2355 return size
2356}
2357
2358// appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
2359func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2360 s := *p.Uint32Slice()
2361 for _, v := range s {
2362 b = wire.AppendVarint(b, wiretag)
2363 b = wire.AppendFixed32(b, v)
2364 }
2365 return b, nil
2366}
2367
Damien Neile91877d2019-06-27 10:54:42 -07002368// consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
2369func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2370 sp := p.Uint32Slice()
2371 if wtyp == wire.BytesType {
2372 s := *sp
2373 b, n = wire.ConsumeBytes(b)
2374 if n < 0 {
2375 return 0, wire.ParseError(n)
2376 }
2377 for len(b) > 0 {
2378 v, n := wire.ConsumeFixed32(b)
2379 if n < 0 {
2380 return 0, wire.ParseError(n)
2381 }
2382 s = append(s, v)
2383 b = b[n:]
2384 }
2385 *sp = s
2386 return n, nil
2387 }
2388 if wtyp != wire.Fixed32Type {
2389 return 0, errUnknown
2390 }
2391 v, n := wire.ConsumeFixed32(b)
2392 if n < 0 {
2393 return 0, wire.ParseError(n)
2394 }
2395 *sp = append(*sp, v)
2396 return n, nil
2397}
2398
Damien Neilc37adef2019-04-01 13:49:56 -07002399var coderFixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002400 size: sizeFixed32Slice,
2401 marshal: appendFixed32Slice,
2402 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002403}
2404
2405// sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
2406func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2407 s := *p.Uint32Slice()
2408 if len(s) == 0 {
2409 return 0
2410 }
2411 n := len(s) * wire.SizeFixed32()
2412 return tagsize + wire.SizeBytes(n)
2413}
2414
2415// appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
2416func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2417 s := *p.Uint32Slice()
2418 if len(s) == 0 {
2419 return b, nil
2420 }
2421 b = wire.AppendVarint(b, wiretag)
2422 n := len(s) * wire.SizeFixed32()
2423 b = wire.AppendVarint(b, uint64(n))
2424 for _, v := range s {
2425 b = wire.AppendFixed32(b, v)
2426 }
2427 return b, nil
2428}
2429
2430var coderFixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002431 size: sizeFixed32PackedSlice,
2432 marshal: appendFixed32PackedSlice,
2433 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002434}
2435
2436// sizeFixed32Iface returns the size of wire encoding a uint32 value as a Fixed32.
2437func sizeFixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2438 return tagsize + wire.SizeFixed32()
2439}
2440
2441// appendFixed32Iface encodes a uint32 value as a Fixed32.
2442func appendFixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2443 v := ival.(uint32)
2444 b = wire.AppendVarint(b, wiretag)
2445 b = wire.AppendFixed32(b, v)
2446 return b, nil
2447}
2448
Damien Neile91877d2019-06-27 10:54:42 -07002449// consumeFixed32Iface decodes a uint32 value as a Fixed32.
2450func consumeFixed32Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2451 if wtyp != wire.Fixed32Type {
2452 return nil, 0, errUnknown
2453 }
2454 v, n := wire.ConsumeFixed32(b)
2455 if n < 0 {
2456 return nil, 0, wire.ParseError(n)
2457 }
2458 return v, n, nil
2459}
2460
Damien Neilc37adef2019-04-01 13:49:56 -07002461var coderFixed32Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002462 size: sizeFixed32Iface,
2463 marshal: appendFixed32Iface,
2464 unmarshal: consumeFixed32Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07002465}
2466
2467// sizeFixed32SliceIface returns the size of wire encoding a []uint32 value as a repeated Fixed32.
2468func sizeFixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2469 s := *ival.(*[]uint32)
2470 size = len(s) * (tagsize + wire.SizeFixed32())
2471 return size
2472}
2473
2474// appendFixed32SliceIface encodes a []uint32 value as a repeated Fixed32.
2475func appendFixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2476 s := *ival.(*[]uint32)
2477 for _, v := range s {
2478 b = wire.AppendVarint(b, wiretag)
2479 b = wire.AppendFixed32(b, v)
2480 }
2481 return b, nil
2482}
2483
Damien Neile91877d2019-06-27 10:54:42 -07002484// consumeFixed32SliceIface wire decodes a []uint32 value as a repeated Fixed32.
2485func consumeFixed32SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2486 sp := ival.(*[]uint32)
2487 if wtyp == wire.BytesType {
2488 s := *sp
2489 b, n = wire.ConsumeBytes(b)
2490 if n < 0 {
2491 return nil, 0, wire.ParseError(n)
2492 }
2493 for len(b) > 0 {
2494 v, n := wire.ConsumeFixed32(b)
2495 if n < 0 {
2496 return nil, 0, wire.ParseError(n)
2497 }
2498 s = append(s, v)
2499 b = b[n:]
2500 }
2501 *sp = s
2502 return ival, n, nil
2503 }
2504 if wtyp != wire.Fixed32Type {
2505 return nil, 0, errUnknown
2506 }
2507 v, n := wire.ConsumeFixed32(b)
2508 if n < 0 {
2509 return nil, 0, wire.ParseError(n)
2510 }
2511 *sp = append(*sp, v)
2512 return ival, n, nil
2513}
2514
Damien Neilc37adef2019-04-01 13:49:56 -07002515var coderFixed32SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002516 size: sizeFixed32SliceIface,
2517 marshal: appendFixed32SliceIface,
2518 unmarshal: consumeFixed32SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002519}
2520
2521// sizeFloat returns the size of wire encoding a float32 pointer as a Float.
2522func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
2523
2524 return tagsize + wire.SizeFixed32()
2525}
2526
2527// appendFloat wire encodes a float32 pointer as a Float.
2528func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2529 v := *p.Float32()
2530 b = wire.AppendVarint(b, wiretag)
2531 b = wire.AppendFixed32(b, math.Float32bits(v))
2532 return b, nil
2533}
2534
Damien Neile91877d2019-06-27 10:54:42 -07002535// consumeFloat wire decodes a float32 pointer as a Float.
2536func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2537 if wtyp != wire.Fixed32Type {
2538 return 0, errUnknown
2539 }
2540 v, n := wire.ConsumeFixed32(b)
2541 if n < 0 {
2542 return 0, wire.ParseError(n)
2543 }
2544 *p.Float32() = math.Float32frombits(v)
2545 return n, nil
2546}
2547
Damien Neilc37adef2019-04-01 13:49:56 -07002548var coderFloat = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002549 size: sizeFloat,
2550 marshal: appendFloat,
2551 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07002552}
2553
2554// sizeFloat returns the size of wire encoding a float32 pointer as a Float.
2555// The zero value is not encoded.
2556func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2557 v := *p.Float32()
2558 if v == 0 && !math.Signbit(float64(v)) {
2559 return 0
2560 }
2561 return tagsize + wire.SizeFixed32()
2562}
2563
2564// appendFloat wire encodes a float32 pointer as a Float.
2565// The zero value is not encoded.
2566func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2567 v := *p.Float32()
2568 if v == 0 && !math.Signbit(float64(v)) {
2569 return b, nil
2570 }
2571 b = wire.AppendVarint(b, wiretag)
2572 b = wire.AppendFixed32(b, math.Float32bits(v))
2573 return b, nil
2574}
2575
2576var coderFloatNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002577 size: sizeFloatNoZero,
2578 marshal: appendFloatNoZero,
2579 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07002580}
2581
2582// sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
2583// It panics if the pointer is nil.
2584func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
2585 return tagsize + wire.SizeFixed32()
2586}
2587
Damien Neile91877d2019-06-27 10:54:42 -07002588// appendFloatPtr wire encodes a *float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07002589// It panics if the pointer is nil.
2590func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2591 v := **p.Float32Ptr()
2592 b = wire.AppendVarint(b, wiretag)
2593 b = wire.AppendFixed32(b, math.Float32bits(v))
2594 return b, nil
2595}
2596
Damien Neile91877d2019-06-27 10:54:42 -07002597// consumeFloatPtr wire decodes a *float32 pointer as a Float.
2598func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2599 if wtyp != wire.Fixed32Type {
2600 return 0, errUnknown
2601 }
2602 v, n := wire.ConsumeFixed32(b)
2603 if n < 0 {
2604 return 0, wire.ParseError(n)
2605 }
2606 vp := p.Float32Ptr()
2607 if *vp == nil {
2608 *vp = new(float32)
2609 }
2610 **vp = math.Float32frombits(v)
2611 return n, nil
2612}
2613
Damien Neilc37adef2019-04-01 13:49:56 -07002614var coderFloatPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002615 size: sizeFloatPtr,
2616 marshal: appendFloatPtr,
2617 unmarshal: consumeFloatPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07002618}
2619
2620// sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
2621func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2622 s := *p.Float32Slice()
2623 size = len(s) * (tagsize + wire.SizeFixed32())
2624 return size
2625}
2626
2627// appendFloatSlice encodes a []float32 pointer as a repeated Float.
2628func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2629 s := *p.Float32Slice()
2630 for _, v := range s {
2631 b = wire.AppendVarint(b, wiretag)
2632 b = wire.AppendFixed32(b, math.Float32bits(v))
2633 }
2634 return b, nil
2635}
2636
Damien Neile91877d2019-06-27 10:54:42 -07002637// consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
2638func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2639 sp := p.Float32Slice()
2640 if wtyp == wire.BytesType {
2641 s := *sp
2642 b, n = wire.ConsumeBytes(b)
2643 if n < 0 {
2644 return 0, wire.ParseError(n)
2645 }
2646 for len(b) > 0 {
2647 v, n := wire.ConsumeFixed32(b)
2648 if n < 0 {
2649 return 0, wire.ParseError(n)
2650 }
2651 s = append(s, math.Float32frombits(v))
2652 b = b[n:]
2653 }
2654 *sp = s
2655 return n, nil
2656 }
2657 if wtyp != wire.Fixed32Type {
2658 return 0, errUnknown
2659 }
2660 v, n := wire.ConsumeFixed32(b)
2661 if n < 0 {
2662 return 0, wire.ParseError(n)
2663 }
2664 *sp = append(*sp, math.Float32frombits(v))
2665 return n, nil
2666}
2667
Damien Neilc37adef2019-04-01 13:49:56 -07002668var coderFloatSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002669 size: sizeFloatSlice,
2670 marshal: appendFloatSlice,
2671 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07002672}
2673
2674// sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
2675func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2676 s := *p.Float32Slice()
2677 if len(s) == 0 {
2678 return 0
2679 }
2680 n := len(s) * wire.SizeFixed32()
2681 return tagsize + wire.SizeBytes(n)
2682}
2683
2684// appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
2685func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2686 s := *p.Float32Slice()
2687 if len(s) == 0 {
2688 return b, nil
2689 }
2690 b = wire.AppendVarint(b, wiretag)
2691 n := len(s) * wire.SizeFixed32()
2692 b = wire.AppendVarint(b, uint64(n))
2693 for _, v := range s {
2694 b = wire.AppendFixed32(b, math.Float32bits(v))
2695 }
2696 return b, nil
2697}
2698
2699var coderFloatPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002700 size: sizeFloatPackedSlice,
2701 marshal: appendFloatPackedSlice,
2702 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07002703}
2704
2705// sizeFloatIface returns the size of wire encoding a float32 value as a Float.
2706func sizeFloatIface(ival interface{}, tagsize int, _ marshalOptions) int {
2707 return tagsize + wire.SizeFixed32()
2708}
2709
2710// appendFloatIface encodes a float32 value as a Float.
2711func appendFloatIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2712 v := ival.(float32)
2713 b = wire.AppendVarint(b, wiretag)
2714 b = wire.AppendFixed32(b, math.Float32bits(v))
2715 return b, nil
2716}
2717
Damien Neile91877d2019-06-27 10:54:42 -07002718// consumeFloatIface decodes a float32 value as a Float.
2719func consumeFloatIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2720 if wtyp != wire.Fixed32Type {
2721 return nil, 0, errUnknown
2722 }
2723 v, n := wire.ConsumeFixed32(b)
2724 if n < 0 {
2725 return nil, 0, wire.ParseError(n)
2726 }
2727 return math.Float32frombits(v), n, nil
2728}
2729
Damien Neilc37adef2019-04-01 13:49:56 -07002730var coderFloatIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002731 size: sizeFloatIface,
2732 marshal: appendFloatIface,
2733 unmarshal: consumeFloatIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002734}
2735
2736// sizeFloatSliceIface returns the size of wire encoding a []float32 value as a repeated Float.
2737func sizeFloatSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
2738 s := *ival.(*[]float32)
2739 size = len(s) * (tagsize + wire.SizeFixed32())
2740 return size
2741}
2742
2743// appendFloatSliceIface encodes a []float32 value as a repeated Float.
2744func appendFloatSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2745 s := *ival.(*[]float32)
2746 for _, v := range s {
2747 b = wire.AppendVarint(b, wiretag)
2748 b = wire.AppendFixed32(b, math.Float32bits(v))
2749 }
2750 return b, nil
2751}
2752
Damien Neile91877d2019-06-27 10:54:42 -07002753// consumeFloatSliceIface wire decodes a []float32 value as a repeated Float.
2754func consumeFloatSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
2755 sp := ival.(*[]float32)
2756 if wtyp == wire.BytesType {
2757 s := *sp
2758 b, n = wire.ConsumeBytes(b)
2759 if n < 0 {
2760 return nil, 0, wire.ParseError(n)
2761 }
2762 for len(b) > 0 {
2763 v, n := wire.ConsumeFixed32(b)
2764 if n < 0 {
2765 return nil, 0, wire.ParseError(n)
2766 }
2767 s = append(s, math.Float32frombits(v))
2768 b = b[n:]
2769 }
2770 *sp = s
2771 return ival, n, nil
2772 }
2773 if wtyp != wire.Fixed32Type {
2774 return nil, 0, errUnknown
2775 }
2776 v, n := wire.ConsumeFixed32(b)
2777 if n < 0 {
2778 return nil, 0, wire.ParseError(n)
2779 }
2780 *sp = append(*sp, math.Float32frombits(v))
2781 return ival, n, nil
2782}
2783
Damien Neilc37adef2019-04-01 13:49:56 -07002784var coderFloatSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002785 size: sizeFloatSliceIface,
2786 marshal: appendFloatSliceIface,
2787 unmarshal: consumeFloatSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07002788}
2789
2790// sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
2791func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
2792
2793 return tagsize + wire.SizeFixed64()
2794}
2795
2796// appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
2797func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2798 v := *p.Int64()
2799 b = wire.AppendVarint(b, wiretag)
2800 b = wire.AppendFixed64(b, uint64(v))
2801 return b, nil
2802}
2803
Damien Neile91877d2019-06-27 10:54:42 -07002804// consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
2805func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2806 if wtyp != wire.Fixed64Type {
2807 return 0, errUnknown
2808 }
2809 v, n := wire.ConsumeFixed64(b)
2810 if n < 0 {
2811 return 0, wire.ParseError(n)
2812 }
2813 *p.Int64() = int64(v)
2814 return n, nil
2815}
2816
Damien Neilc37adef2019-04-01 13:49:56 -07002817var coderSfixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002818 size: sizeSfixed64,
2819 marshal: appendSfixed64,
2820 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07002821}
2822
2823// sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
2824// The zero value is not encoded.
2825func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2826 v := *p.Int64()
2827 if v == 0 {
2828 return 0
2829 }
2830 return tagsize + wire.SizeFixed64()
2831}
2832
2833// appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
2834// The zero value is not encoded.
2835func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2836 v := *p.Int64()
2837 if v == 0 {
2838 return b, nil
2839 }
2840 b = wire.AppendVarint(b, wiretag)
2841 b = wire.AppendFixed64(b, uint64(v))
2842 return b, nil
2843}
2844
2845var coderSfixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002846 size: sizeSfixed64NoZero,
2847 marshal: appendSfixed64NoZero,
2848 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07002849}
2850
2851// sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
2852// It panics if the pointer is nil.
2853func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2854 return tagsize + wire.SizeFixed64()
2855}
2856
Damien Neile91877d2019-06-27 10:54:42 -07002857// appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07002858// It panics if the pointer is nil.
2859func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2860 v := **p.Int64Ptr()
2861 b = wire.AppendVarint(b, wiretag)
2862 b = wire.AppendFixed64(b, uint64(v))
2863 return b, nil
2864}
2865
Damien Neile91877d2019-06-27 10:54:42 -07002866// consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
2867func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2868 if wtyp != wire.Fixed64Type {
2869 return 0, errUnknown
2870 }
2871 v, n := wire.ConsumeFixed64(b)
2872 if n < 0 {
2873 return 0, wire.ParseError(n)
2874 }
2875 vp := p.Int64Ptr()
2876 if *vp == nil {
2877 *vp = new(int64)
2878 }
2879 **vp = int64(v)
2880 return n, nil
2881}
2882
Damien Neilc37adef2019-04-01 13:49:56 -07002883var coderSfixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002884 size: sizeSfixed64Ptr,
2885 marshal: appendSfixed64Ptr,
2886 unmarshal: consumeSfixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002887}
2888
2889// sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
2890func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2891 s := *p.Int64Slice()
2892 size = len(s) * (tagsize + wire.SizeFixed64())
2893 return size
2894}
2895
2896// appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
2897func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2898 s := *p.Int64Slice()
2899 for _, v := range s {
2900 b = wire.AppendVarint(b, wiretag)
2901 b = wire.AppendFixed64(b, uint64(v))
2902 }
2903 return b, nil
2904}
2905
Damien Neile91877d2019-06-27 10:54:42 -07002906// consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
2907func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
2908 sp := p.Int64Slice()
2909 if wtyp == wire.BytesType {
2910 s := *sp
2911 b, n = wire.ConsumeBytes(b)
2912 if n < 0 {
2913 return 0, wire.ParseError(n)
2914 }
2915 for len(b) > 0 {
2916 v, n := wire.ConsumeFixed64(b)
2917 if n < 0 {
2918 return 0, wire.ParseError(n)
2919 }
2920 s = append(s, int64(v))
2921 b = b[n:]
2922 }
2923 *sp = s
2924 return n, nil
2925 }
2926 if wtyp != wire.Fixed64Type {
2927 return 0, errUnknown
2928 }
2929 v, n := wire.ConsumeFixed64(b)
2930 if n < 0 {
2931 return 0, wire.ParseError(n)
2932 }
2933 *sp = append(*sp, int64(v))
2934 return n, nil
2935}
2936
Damien Neilc37adef2019-04-01 13:49:56 -07002937var coderSfixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002938 size: sizeSfixed64Slice,
2939 marshal: appendSfixed64Slice,
2940 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002941}
2942
2943// sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
2944func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2945 s := *p.Int64Slice()
2946 if len(s) == 0 {
2947 return 0
2948 }
2949 n := len(s) * wire.SizeFixed64()
2950 return tagsize + wire.SizeBytes(n)
2951}
2952
2953// appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
2954func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2955 s := *p.Int64Slice()
2956 if len(s) == 0 {
2957 return b, nil
2958 }
2959 b = wire.AppendVarint(b, wiretag)
2960 n := len(s) * wire.SizeFixed64()
2961 b = wire.AppendVarint(b, uint64(n))
2962 for _, v := range s {
2963 b = wire.AppendFixed64(b, uint64(v))
2964 }
2965 return b, nil
2966}
2967
2968var coderSfixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002969 size: sizeSfixed64PackedSlice,
2970 marshal: appendSfixed64PackedSlice,
2971 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002972}
2973
2974// sizeSfixed64Iface returns the size of wire encoding a int64 value as a Sfixed64.
2975func sizeSfixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
2976 return tagsize + wire.SizeFixed64()
2977}
2978
2979// appendSfixed64Iface encodes a int64 value as a Sfixed64.
2980func appendSfixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
2981 v := ival.(int64)
2982 b = wire.AppendVarint(b, wiretag)
2983 b = wire.AppendFixed64(b, uint64(v))
2984 return b, nil
2985}
2986
Damien Neile91877d2019-06-27 10:54:42 -07002987// consumeSfixed64Iface decodes a int64 value as a Sfixed64.
2988func consumeSfixed64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
2989 if wtyp != wire.Fixed64Type {
2990 return nil, 0, errUnknown
2991 }
2992 v, n := wire.ConsumeFixed64(b)
2993 if n < 0 {
2994 return nil, 0, wire.ParseError(n)
2995 }
2996 return int64(v), n, nil
2997}
2998
Damien Neilc37adef2019-04-01 13:49:56 -07002999var coderSfixed64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003000 size: sizeSfixed64Iface,
3001 marshal: appendSfixed64Iface,
3002 unmarshal: consumeSfixed64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07003003}
3004
3005// sizeSfixed64SliceIface returns the size of wire encoding a []int64 value as a repeated Sfixed64.
3006func sizeSfixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3007 s := *ival.(*[]int64)
3008 size = len(s) * (tagsize + wire.SizeFixed64())
3009 return size
3010}
3011
3012// appendSfixed64SliceIface encodes a []int64 value as a repeated Sfixed64.
3013func appendSfixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3014 s := *ival.(*[]int64)
3015 for _, v := range s {
3016 b = wire.AppendVarint(b, wiretag)
3017 b = wire.AppendFixed64(b, uint64(v))
3018 }
3019 return b, nil
3020}
3021
Damien Neile91877d2019-06-27 10:54:42 -07003022// consumeSfixed64SliceIface wire decodes a []int64 value as a repeated Sfixed64.
3023func consumeSfixed64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3024 sp := ival.(*[]int64)
3025 if wtyp == wire.BytesType {
3026 s := *sp
3027 b, n = wire.ConsumeBytes(b)
3028 if n < 0 {
3029 return nil, 0, wire.ParseError(n)
3030 }
3031 for len(b) > 0 {
3032 v, n := wire.ConsumeFixed64(b)
3033 if n < 0 {
3034 return nil, 0, wire.ParseError(n)
3035 }
3036 s = append(s, int64(v))
3037 b = b[n:]
3038 }
3039 *sp = s
3040 return ival, n, nil
3041 }
3042 if wtyp != wire.Fixed64Type {
3043 return nil, 0, errUnknown
3044 }
3045 v, n := wire.ConsumeFixed64(b)
3046 if n < 0 {
3047 return nil, 0, wire.ParseError(n)
3048 }
3049 *sp = append(*sp, int64(v))
3050 return ival, n, nil
3051}
3052
Damien Neilc37adef2019-04-01 13:49:56 -07003053var coderSfixed64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003054 size: sizeSfixed64SliceIface,
3055 marshal: appendSfixed64SliceIface,
3056 unmarshal: consumeSfixed64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003057}
3058
3059// sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
3060func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
3061
3062 return tagsize + wire.SizeFixed64()
3063}
3064
3065// appendFixed64 wire encodes a uint64 pointer as a Fixed64.
3066func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3067 v := *p.Uint64()
3068 b = wire.AppendVarint(b, wiretag)
3069 b = wire.AppendFixed64(b, v)
3070 return b, nil
3071}
3072
Damien Neile91877d2019-06-27 10:54:42 -07003073// consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
3074func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3075 if wtyp != wire.Fixed64Type {
3076 return 0, errUnknown
3077 }
3078 v, n := wire.ConsumeFixed64(b)
3079 if n < 0 {
3080 return 0, wire.ParseError(n)
3081 }
3082 *p.Uint64() = v
3083 return n, nil
3084}
3085
Damien Neilc37adef2019-04-01 13:49:56 -07003086var coderFixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003087 size: sizeFixed64,
3088 marshal: appendFixed64,
3089 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003090}
3091
3092// sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
3093// The zero value is not encoded.
3094func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3095 v := *p.Uint64()
3096 if v == 0 {
3097 return 0
3098 }
3099 return tagsize + wire.SizeFixed64()
3100}
3101
3102// appendFixed64 wire encodes a uint64 pointer as a Fixed64.
3103// The zero value is not encoded.
3104func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3105 v := *p.Uint64()
3106 if v == 0 {
3107 return b, nil
3108 }
3109 b = wire.AppendVarint(b, wiretag)
3110 b = wire.AppendFixed64(b, v)
3111 return b, nil
3112}
3113
3114var coderFixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003115 size: sizeFixed64NoZero,
3116 marshal: appendFixed64NoZero,
3117 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003118}
3119
3120// sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
3121// It panics if the pointer is nil.
3122func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
3123 return tagsize + wire.SizeFixed64()
3124}
3125
Damien Neile91877d2019-06-27 10:54:42 -07003126// appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003127// It panics if the pointer is nil.
3128func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3129 v := **p.Uint64Ptr()
3130 b = wire.AppendVarint(b, wiretag)
3131 b = wire.AppendFixed64(b, v)
3132 return b, nil
3133}
3134
Damien Neile91877d2019-06-27 10:54:42 -07003135// consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
3136func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3137 if wtyp != wire.Fixed64Type {
3138 return 0, errUnknown
3139 }
3140 v, n := wire.ConsumeFixed64(b)
3141 if n < 0 {
3142 return 0, wire.ParseError(n)
3143 }
3144 vp := p.Uint64Ptr()
3145 if *vp == nil {
3146 *vp = new(uint64)
3147 }
3148 **vp = v
3149 return n, nil
3150}
3151
Damien Neilc37adef2019-04-01 13:49:56 -07003152var coderFixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003153 size: sizeFixed64Ptr,
3154 marshal: appendFixed64Ptr,
3155 unmarshal: consumeFixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07003156}
3157
3158// sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
3159func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
3160 s := *p.Uint64Slice()
3161 size = len(s) * (tagsize + wire.SizeFixed64())
3162 return size
3163}
3164
3165// appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
3166func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3167 s := *p.Uint64Slice()
3168 for _, v := range s {
3169 b = wire.AppendVarint(b, wiretag)
3170 b = wire.AppendFixed64(b, v)
3171 }
3172 return b, nil
3173}
3174
Damien Neile91877d2019-06-27 10:54:42 -07003175// consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
3176func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3177 sp := p.Uint64Slice()
3178 if wtyp == wire.BytesType {
3179 s := *sp
3180 b, n = wire.ConsumeBytes(b)
3181 if n < 0 {
3182 return 0, wire.ParseError(n)
3183 }
3184 for len(b) > 0 {
3185 v, n := wire.ConsumeFixed64(b)
3186 if n < 0 {
3187 return 0, wire.ParseError(n)
3188 }
3189 s = append(s, v)
3190 b = b[n:]
3191 }
3192 *sp = s
3193 return n, nil
3194 }
3195 if wtyp != wire.Fixed64Type {
3196 return 0, errUnknown
3197 }
3198 v, n := wire.ConsumeFixed64(b)
3199 if n < 0 {
3200 return 0, wire.ParseError(n)
3201 }
3202 *sp = append(*sp, v)
3203 return n, nil
3204}
3205
Damien Neilc37adef2019-04-01 13:49:56 -07003206var coderFixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003207 size: sizeFixed64Slice,
3208 marshal: appendFixed64Slice,
3209 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003210}
3211
3212// sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
3213func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3214 s := *p.Uint64Slice()
3215 if len(s) == 0 {
3216 return 0
3217 }
3218 n := len(s) * wire.SizeFixed64()
3219 return tagsize + wire.SizeBytes(n)
3220}
3221
3222// appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
3223func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3224 s := *p.Uint64Slice()
3225 if len(s) == 0 {
3226 return b, nil
3227 }
3228 b = wire.AppendVarint(b, wiretag)
3229 n := len(s) * wire.SizeFixed64()
3230 b = wire.AppendVarint(b, uint64(n))
3231 for _, v := range s {
3232 b = wire.AppendFixed64(b, v)
3233 }
3234 return b, nil
3235}
3236
3237var coderFixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003238 size: sizeFixed64PackedSlice,
3239 marshal: appendFixed64PackedSlice,
3240 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003241}
3242
3243// sizeFixed64Iface returns the size of wire encoding a uint64 value as a Fixed64.
3244func sizeFixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
3245 return tagsize + wire.SizeFixed64()
3246}
3247
3248// appendFixed64Iface encodes a uint64 value as a Fixed64.
3249func appendFixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3250 v := ival.(uint64)
3251 b = wire.AppendVarint(b, wiretag)
3252 b = wire.AppendFixed64(b, v)
3253 return b, nil
3254}
3255
Damien Neile91877d2019-06-27 10:54:42 -07003256// consumeFixed64Iface decodes a uint64 value as a Fixed64.
3257func consumeFixed64Iface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3258 if wtyp != wire.Fixed64Type {
3259 return nil, 0, errUnknown
3260 }
3261 v, n := wire.ConsumeFixed64(b)
3262 if n < 0 {
3263 return nil, 0, wire.ParseError(n)
3264 }
3265 return v, n, nil
3266}
3267
Damien Neilc37adef2019-04-01 13:49:56 -07003268var coderFixed64Iface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003269 size: sizeFixed64Iface,
3270 marshal: appendFixed64Iface,
3271 unmarshal: consumeFixed64Iface,
Damien Neilc37adef2019-04-01 13:49:56 -07003272}
3273
3274// sizeFixed64SliceIface returns the size of wire encoding a []uint64 value as a repeated Fixed64.
3275func sizeFixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3276 s := *ival.(*[]uint64)
3277 size = len(s) * (tagsize + wire.SizeFixed64())
3278 return size
3279}
3280
3281// appendFixed64SliceIface encodes a []uint64 value as a repeated Fixed64.
3282func appendFixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3283 s := *ival.(*[]uint64)
3284 for _, v := range s {
3285 b = wire.AppendVarint(b, wiretag)
3286 b = wire.AppendFixed64(b, v)
3287 }
3288 return b, nil
3289}
3290
Damien Neile91877d2019-06-27 10:54:42 -07003291// consumeFixed64SliceIface wire decodes a []uint64 value as a repeated Fixed64.
3292func consumeFixed64SliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3293 sp := ival.(*[]uint64)
3294 if wtyp == wire.BytesType {
3295 s := *sp
3296 b, n = wire.ConsumeBytes(b)
3297 if n < 0 {
3298 return nil, 0, wire.ParseError(n)
3299 }
3300 for len(b) > 0 {
3301 v, n := wire.ConsumeFixed64(b)
3302 if n < 0 {
3303 return nil, 0, wire.ParseError(n)
3304 }
3305 s = append(s, v)
3306 b = b[n:]
3307 }
3308 *sp = s
3309 return ival, n, nil
3310 }
3311 if wtyp != wire.Fixed64Type {
3312 return nil, 0, errUnknown
3313 }
3314 v, n := wire.ConsumeFixed64(b)
3315 if n < 0 {
3316 return nil, 0, wire.ParseError(n)
3317 }
3318 *sp = append(*sp, v)
3319 return ival, n, nil
3320}
3321
Damien Neilc37adef2019-04-01 13:49:56 -07003322var coderFixed64SliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003323 size: sizeFixed64SliceIface,
3324 marshal: appendFixed64SliceIface,
3325 unmarshal: consumeFixed64SliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003326}
3327
3328// sizeDouble returns the size of wire encoding a float64 pointer as a Double.
3329func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
3330
3331 return tagsize + wire.SizeFixed64()
3332}
3333
3334// appendDouble wire encodes a float64 pointer as a Double.
3335func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3336 v := *p.Float64()
3337 b = wire.AppendVarint(b, wiretag)
3338 b = wire.AppendFixed64(b, math.Float64bits(v))
3339 return b, nil
3340}
3341
Damien Neile91877d2019-06-27 10:54:42 -07003342// consumeDouble wire decodes a float64 pointer as a Double.
3343func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3344 if wtyp != wire.Fixed64Type {
3345 return 0, errUnknown
3346 }
3347 v, n := wire.ConsumeFixed64(b)
3348 if n < 0 {
3349 return 0, wire.ParseError(n)
3350 }
3351 *p.Float64() = math.Float64frombits(v)
3352 return n, nil
3353}
3354
Damien Neilc37adef2019-04-01 13:49:56 -07003355var coderDouble = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003356 size: sizeDouble,
3357 marshal: appendDouble,
3358 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07003359}
3360
3361// sizeDouble returns the size of wire encoding a float64 pointer as a Double.
3362// The zero value is not encoded.
3363func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3364 v := *p.Float64()
3365 if v == 0 && !math.Signbit(float64(v)) {
3366 return 0
3367 }
3368 return tagsize + wire.SizeFixed64()
3369}
3370
3371// appendDouble wire encodes a float64 pointer as a Double.
3372// The zero value is not encoded.
3373func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3374 v := *p.Float64()
3375 if v == 0 && !math.Signbit(float64(v)) {
3376 return b, nil
3377 }
3378 b = wire.AppendVarint(b, wiretag)
3379 b = wire.AppendFixed64(b, math.Float64bits(v))
3380 return b, nil
3381}
3382
3383var coderDoubleNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003384 size: sizeDoubleNoZero,
3385 marshal: appendDoubleNoZero,
3386 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07003387}
3388
3389// sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
3390// It panics if the pointer is nil.
3391func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
3392 return tagsize + wire.SizeFixed64()
3393}
3394
Damien Neile91877d2019-06-27 10:54:42 -07003395// appendDoublePtr wire encodes a *float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07003396// It panics if the pointer is nil.
3397func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3398 v := **p.Float64Ptr()
3399 b = wire.AppendVarint(b, wiretag)
3400 b = wire.AppendFixed64(b, math.Float64bits(v))
3401 return b, nil
3402}
3403
Damien Neile91877d2019-06-27 10:54:42 -07003404// consumeDoublePtr wire decodes a *float64 pointer as a Double.
3405func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3406 if wtyp != wire.Fixed64Type {
3407 return 0, errUnknown
3408 }
3409 v, n := wire.ConsumeFixed64(b)
3410 if n < 0 {
3411 return 0, wire.ParseError(n)
3412 }
3413 vp := p.Float64Ptr()
3414 if *vp == nil {
3415 *vp = new(float64)
3416 }
3417 **vp = math.Float64frombits(v)
3418 return n, nil
3419}
3420
Damien Neilc37adef2019-04-01 13:49:56 -07003421var coderDoublePtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003422 size: sizeDoublePtr,
3423 marshal: appendDoublePtr,
3424 unmarshal: consumeDoublePtr,
Damien Neilc37adef2019-04-01 13:49:56 -07003425}
3426
3427// sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
3428func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3429 s := *p.Float64Slice()
3430 size = len(s) * (tagsize + wire.SizeFixed64())
3431 return size
3432}
3433
3434// appendDoubleSlice encodes a []float64 pointer as a repeated Double.
3435func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3436 s := *p.Float64Slice()
3437 for _, v := range s {
3438 b = wire.AppendVarint(b, wiretag)
3439 b = wire.AppendFixed64(b, math.Float64bits(v))
3440 }
3441 return b, nil
3442}
3443
Damien Neile91877d2019-06-27 10:54:42 -07003444// consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
3445func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3446 sp := p.Float64Slice()
3447 if wtyp == wire.BytesType {
3448 s := *sp
3449 b, n = wire.ConsumeBytes(b)
3450 if n < 0 {
3451 return 0, wire.ParseError(n)
3452 }
3453 for len(b) > 0 {
3454 v, n := wire.ConsumeFixed64(b)
3455 if n < 0 {
3456 return 0, wire.ParseError(n)
3457 }
3458 s = append(s, math.Float64frombits(v))
3459 b = b[n:]
3460 }
3461 *sp = s
3462 return n, nil
3463 }
3464 if wtyp != wire.Fixed64Type {
3465 return 0, errUnknown
3466 }
3467 v, n := wire.ConsumeFixed64(b)
3468 if n < 0 {
3469 return 0, wire.ParseError(n)
3470 }
3471 *sp = append(*sp, math.Float64frombits(v))
3472 return n, nil
3473}
3474
Damien Neilc37adef2019-04-01 13:49:56 -07003475var coderDoubleSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003476 size: sizeDoubleSlice,
3477 marshal: appendDoubleSlice,
3478 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003479}
3480
3481// sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
3482func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3483 s := *p.Float64Slice()
3484 if len(s) == 0 {
3485 return 0
3486 }
3487 n := len(s) * wire.SizeFixed64()
3488 return tagsize + wire.SizeBytes(n)
3489}
3490
3491// appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
3492func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3493 s := *p.Float64Slice()
3494 if len(s) == 0 {
3495 return b, nil
3496 }
3497 b = wire.AppendVarint(b, wiretag)
3498 n := len(s) * wire.SizeFixed64()
3499 b = wire.AppendVarint(b, uint64(n))
3500 for _, v := range s {
3501 b = wire.AppendFixed64(b, math.Float64bits(v))
3502 }
3503 return b, nil
3504}
3505
3506var coderDoublePackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003507 size: sizeDoublePackedSlice,
3508 marshal: appendDoublePackedSlice,
3509 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003510}
3511
3512// sizeDoubleIface returns the size of wire encoding a float64 value as a Double.
3513func sizeDoubleIface(ival interface{}, tagsize int, _ marshalOptions) int {
3514 return tagsize + wire.SizeFixed64()
3515}
3516
3517// appendDoubleIface encodes a float64 value as a Double.
3518func appendDoubleIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3519 v := ival.(float64)
3520 b = wire.AppendVarint(b, wiretag)
3521 b = wire.AppendFixed64(b, math.Float64bits(v))
3522 return b, nil
3523}
3524
Damien Neile91877d2019-06-27 10:54:42 -07003525// consumeDoubleIface decodes a float64 value as a Double.
3526func consumeDoubleIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3527 if wtyp != wire.Fixed64Type {
3528 return nil, 0, errUnknown
3529 }
3530 v, n := wire.ConsumeFixed64(b)
3531 if n < 0 {
3532 return nil, 0, wire.ParseError(n)
3533 }
3534 return math.Float64frombits(v), n, nil
3535}
3536
Damien Neilc37adef2019-04-01 13:49:56 -07003537var coderDoubleIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003538 size: sizeDoubleIface,
3539 marshal: appendDoubleIface,
3540 unmarshal: consumeDoubleIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003541}
3542
3543// sizeDoubleSliceIface returns the size of wire encoding a []float64 value as a repeated Double.
3544func sizeDoubleSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3545 s := *ival.(*[]float64)
3546 size = len(s) * (tagsize + wire.SizeFixed64())
3547 return size
3548}
3549
3550// appendDoubleSliceIface encodes a []float64 value as a repeated Double.
3551func appendDoubleSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3552 s := *ival.(*[]float64)
3553 for _, v := range s {
3554 b = wire.AppendVarint(b, wiretag)
3555 b = wire.AppendFixed64(b, math.Float64bits(v))
3556 }
3557 return b, nil
3558}
3559
Damien Neile91877d2019-06-27 10:54:42 -07003560// consumeDoubleSliceIface wire decodes a []float64 value as a repeated Double.
3561func consumeDoubleSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3562 sp := ival.(*[]float64)
3563 if wtyp == wire.BytesType {
3564 s := *sp
3565 b, n = wire.ConsumeBytes(b)
3566 if n < 0 {
3567 return nil, 0, wire.ParseError(n)
3568 }
3569 for len(b) > 0 {
3570 v, n := wire.ConsumeFixed64(b)
3571 if n < 0 {
3572 return nil, 0, wire.ParseError(n)
3573 }
3574 s = append(s, math.Float64frombits(v))
3575 b = b[n:]
3576 }
3577 *sp = s
3578 return ival, n, nil
3579 }
3580 if wtyp != wire.Fixed64Type {
3581 return nil, 0, errUnknown
3582 }
3583 v, n := wire.ConsumeFixed64(b)
3584 if n < 0 {
3585 return nil, 0, wire.ParseError(n)
3586 }
3587 *sp = append(*sp, math.Float64frombits(v))
3588 return ival, n, nil
3589}
3590
Damien Neilc37adef2019-04-01 13:49:56 -07003591var coderDoubleSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003592 size: sizeDoubleSliceIface,
3593 marshal: appendDoubleSliceIface,
3594 unmarshal: consumeDoubleSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003595}
3596
3597// sizeString returns the size of wire encoding a string pointer as a String.
3598func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
3599 v := *p.String()
Damien Neilcedb5952019-06-21 12:04:07 -07003600 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003601}
3602
3603// appendString wire encodes a string pointer as a String.
3604func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3605 v := *p.String()
3606 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003607 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003608 return b, nil
3609}
3610
Damien Neile91877d2019-06-27 10:54:42 -07003611// consumeString wire decodes a string pointer as a String.
3612func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3613 if wtyp != wire.BytesType {
3614 return 0, errUnknown
3615 }
3616 v, n := wire.ConsumeString(b)
3617 if n < 0 {
3618 return 0, wire.ParseError(n)
3619 }
3620 *p.String() = v
3621 return n, nil
3622}
3623
Damien Neilc37adef2019-04-01 13:49:56 -07003624var coderString = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003625 size: sizeString,
3626 marshal: appendString,
3627 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07003628}
3629
3630// sizeString returns the size of wire encoding a string pointer as a String.
3631// The zero value is not encoded.
3632func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3633 v := *p.String()
3634 if len(v) == 0 {
3635 return 0
3636 }
Damien Neilcedb5952019-06-21 12:04:07 -07003637 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003638}
3639
3640// appendString wire encodes a string pointer as a String.
3641// The zero value is not encoded.
3642func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3643 v := *p.String()
3644 if len(v) == 0 {
3645 return b, nil
3646 }
3647 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003648 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003649 return b, nil
3650}
3651
3652var coderStringNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003653 size: sizeStringNoZero,
3654 marshal: appendStringNoZero,
3655 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07003656}
3657
3658// sizeStringPtr returns the size of wire encoding a *string pointer as a String.
3659// It panics if the pointer is nil.
3660func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
3661 v := **p.StringPtr()
Damien Neilcedb5952019-06-21 12:04:07 -07003662 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003663}
3664
Damien Neile91877d2019-06-27 10:54:42 -07003665// appendStringPtr wire encodes a *string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07003666// It panics if the pointer is nil.
3667func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3668 v := **p.StringPtr()
3669 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003670 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003671 return b, nil
3672}
3673
Damien Neile91877d2019-06-27 10:54:42 -07003674// consumeStringPtr wire decodes a *string pointer as a String.
3675func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3676 if wtyp != wire.BytesType {
3677 return 0, errUnknown
3678 }
3679 v, n := wire.ConsumeString(b)
3680 if n < 0 {
3681 return 0, wire.ParseError(n)
3682 }
3683 vp := p.StringPtr()
3684 if *vp == nil {
3685 *vp = new(string)
3686 }
3687 **vp = v
3688 return n, nil
3689}
3690
Damien Neilc37adef2019-04-01 13:49:56 -07003691var coderStringPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003692 size: sizeStringPtr,
3693 marshal: appendStringPtr,
3694 unmarshal: consumeStringPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07003695}
3696
3697// sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
3698func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3699 s := *p.StringSlice()
3700 for _, v := range s {
Damien Neilcedb5952019-06-21 12:04:07 -07003701 size += tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003702 }
3703 return size
3704}
3705
3706// appendStringSlice encodes a []string pointer as a repeated String.
3707func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3708 s := *p.StringSlice()
3709 for _, v := range s {
3710 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003711 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003712 }
3713 return b, nil
3714}
3715
Damien Neile91877d2019-06-27 10:54:42 -07003716// consumeStringSlice wire decodes a []string pointer as a repeated String.
3717func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3718 sp := p.StringSlice()
3719 if wtyp != wire.BytesType {
3720 return 0, errUnknown
3721 }
3722 v, n := wire.ConsumeString(b)
3723 if n < 0 {
3724 return 0, wire.ParseError(n)
3725 }
3726 *sp = append(*sp, v)
3727 return n, nil
3728}
3729
Damien Neilc37adef2019-04-01 13:49:56 -07003730var coderStringSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003731 size: sizeStringSlice,
3732 marshal: appendStringSlice,
3733 unmarshal: consumeStringSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003734}
3735
3736// sizeStringIface returns the size of wire encoding a string value as a String.
3737func sizeStringIface(ival interface{}, tagsize int, _ marshalOptions) int {
3738 v := ival.(string)
Damien Neilcedb5952019-06-21 12:04:07 -07003739 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003740}
3741
3742// appendStringIface encodes a string value as a String.
3743func appendStringIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3744 v := ival.(string)
3745 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003746 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003747 return b, nil
3748}
3749
Damien Neile91877d2019-06-27 10:54:42 -07003750// consumeStringIface decodes a string value as a String.
3751func consumeStringIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3752 if wtyp != wire.BytesType {
3753 return nil, 0, errUnknown
3754 }
3755 v, n := wire.ConsumeString(b)
3756 if n < 0 {
3757 return nil, 0, wire.ParseError(n)
3758 }
3759 return v, n, nil
3760}
3761
Damien Neilc37adef2019-04-01 13:49:56 -07003762var coderStringIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003763 size: sizeStringIface,
3764 marshal: appendStringIface,
3765 unmarshal: consumeStringIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003766}
3767
3768// sizeStringSliceIface returns the size of wire encoding a []string value as a repeated String.
3769func sizeStringSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3770 s := *ival.(*[]string)
3771 for _, v := range s {
Damien Neilcedb5952019-06-21 12:04:07 -07003772 size += tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07003773 }
3774 return size
3775}
3776
3777// appendStringSliceIface encodes a []string value as a repeated String.
3778func appendStringSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3779 s := *ival.(*[]string)
3780 for _, v := range s {
3781 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07003782 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07003783 }
3784 return b, nil
3785}
3786
Damien Neile91877d2019-06-27 10:54:42 -07003787// consumeStringSliceIface wire decodes a []string value as a repeated String.
3788func consumeStringSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3789 sp := ival.(*[]string)
3790 if wtyp != wire.BytesType {
3791 return nil, 0, errUnknown
3792 }
3793 v, n := wire.ConsumeString(b)
3794 if n < 0 {
3795 return nil, 0, wire.ParseError(n)
3796 }
3797 *sp = append(*sp, v)
3798 return ival, n, nil
3799}
3800
Damien Neilc37adef2019-04-01 13:49:56 -07003801var coderStringSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003802 size: sizeStringSliceIface,
3803 marshal: appendStringSliceIface,
3804 unmarshal: consumeStringSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003805}
3806
3807// sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
3808func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
3809 v := *p.Bytes()
3810 return tagsize + wire.SizeBytes(len(v))
3811}
3812
3813// appendBytes wire encodes a []byte pointer as a Bytes.
3814func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3815 v := *p.Bytes()
3816 b = wire.AppendVarint(b, wiretag)
3817 b = wire.AppendBytes(b, v)
3818 return b, nil
3819}
3820
Damien Neile91877d2019-06-27 10:54:42 -07003821// consumeBytes wire decodes a []byte pointer as a Bytes.
3822func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3823 if wtyp != wire.BytesType {
3824 return 0, errUnknown
3825 }
3826 v, n := wire.ConsumeBytes(b)
3827 if n < 0 {
3828 return 0, wire.ParseError(n)
3829 }
3830 *p.Bytes() = append(([]byte)(nil), v...)
3831 return n, nil
3832}
3833
Damien Neilc37adef2019-04-01 13:49:56 -07003834var coderBytes = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003835 size: sizeBytes,
3836 marshal: appendBytes,
3837 unmarshal: consumeBytes,
Damien Neilc37adef2019-04-01 13:49:56 -07003838}
3839
3840// sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
3841// The zero value is not encoded.
3842func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3843 v := *p.Bytes()
3844 if len(v) == 0 {
3845 return 0
3846 }
3847 return tagsize + wire.SizeBytes(len(v))
3848}
3849
3850// appendBytes wire encodes a []byte pointer as a Bytes.
3851// The zero value is not encoded.
3852func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3853 v := *p.Bytes()
3854 if len(v) == 0 {
3855 return b, nil
3856 }
3857 b = wire.AppendVarint(b, wiretag)
3858 b = wire.AppendBytes(b, v)
3859 return b, nil
3860}
3861
3862var coderBytesNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003863 size: sizeBytesNoZero,
3864 marshal: appendBytesNoZero,
3865 unmarshal: consumeBytes,
Damien Neilc37adef2019-04-01 13:49:56 -07003866}
3867
3868// sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
3869func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3870 s := *p.BytesSlice()
3871 for _, v := range s {
3872 size += tagsize + wire.SizeBytes(len(v))
3873 }
3874 return size
3875}
3876
3877// appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
3878func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3879 s := *p.BytesSlice()
3880 for _, v := range s {
3881 b = wire.AppendVarint(b, wiretag)
3882 b = wire.AppendBytes(b, v)
3883 }
3884 return b, nil
3885}
3886
Damien Neile91877d2019-06-27 10:54:42 -07003887// consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
3888func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
3889 sp := p.BytesSlice()
3890 if wtyp != wire.BytesType {
3891 return 0, errUnknown
3892 }
3893 v, n := wire.ConsumeBytes(b)
3894 if n < 0 {
3895 return 0, wire.ParseError(n)
3896 }
3897 *sp = append(*sp, append(([]byte)(nil), v...))
3898 return n, nil
3899}
3900
Damien Neilc37adef2019-04-01 13:49:56 -07003901var coderBytesSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003902 size: sizeBytesSlice,
3903 marshal: appendBytesSlice,
3904 unmarshal: consumeBytesSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003905}
3906
3907// sizeBytesIface returns the size of wire encoding a []byte value as a Bytes.
3908func sizeBytesIface(ival interface{}, tagsize int, _ marshalOptions) int {
3909 v := ival.([]byte)
3910 return tagsize + wire.SizeBytes(len(v))
3911}
3912
3913// appendBytesIface encodes a []byte value as a Bytes.
3914func appendBytesIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3915 v := ival.([]byte)
3916 b = wire.AppendVarint(b, wiretag)
3917 b = wire.AppendBytes(b, v)
3918 return b, nil
3919}
3920
Damien Neile91877d2019-06-27 10:54:42 -07003921// consumeBytesIface decodes a []byte value as a Bytes.
3922func consumeBytesIface(b []byte, _ interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (interface{}, int, error) {
3923 if wtyp != wire.BytesType {
3924 return nil, 0, errUnknown
3925 }
3926 v, n := wire.ConsumeBytes(b)
3927 if n < 0 {
3928 return nil, 0, wire.ParseError(n)
3929 }
3930 return append(([]byte)(nil), v...), n, nil
3931}
3932
Damien Neilc37adef2019-04-01 13:49:56 -07003933var coderBytesIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003934 size: sizeBytesIface,
3935 marshal: appendBytesIface,
3936 unmarshal: consumeBytesIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003937}
3938
3939// sizeBytesSliceIface returns the size of wire encoding a [][]byte value as a repeated Bytes.
3940func sizeBytesSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
3941 s := *ival.(*[][]byte)
3942 for _, v := range s {
3943 size += tagsize + wire.SizeBytes(len(v))
3944 }
3945 return size
3946}
3947
3948// appendBytesSliceIface encodes a [][]byte value as a repeated Bytes.
3949func appendBytesSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
3950 s := *ival.(*[][]byte)
3951 for _, v := range s {
3952 b = wire.AppendVarint(b, wiretag)
3953 b = wire.AppendBytes(b, v)
3954 }
3955 return b, nil
3956}
3957
Damien Neile91877d2019-06-27 10:54:42 -07003958// consumeBytesSliceIface wire decodes a [][]byte value as a repeated Bytes.
3959func consumeBytesSliceIface(b []byte, ival interface{}, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ interface{}, n int, err error) {
3960 sp := ival.(*[][]byte)
3961 if wtyp != wire.BytesType {
3962 return nil, 0, errUnknown
3963 }
3964 v, n := wire.ConsumeBytes(b)
3965 if n < 0 {
3966 return nil, 0, wire.ParseError(n)
3967 }
3968 *sp = append(*sp, append(([]byte)(nil), v...))
3969 return ival, n, nil
3970}
3971
Damien Neilc37adef2019-04-01 13:49:56 -07003972var coderBytesSliceIface = ifaceCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003973 size: sizeBytesSliceIface,
3974 marshal: appendBytesSliceIface,
3975 unmarshal: consumeBytesSliceIface,
Damien Neilc37adef2019-04-01 13:49:56 -07003976}
3977
3978var wireTypes = map[protoreflect.Kind]wire.Type{
3979 protoreflect.BoolKind: wire.VarintType,
3980 protoreflect.EnumKind: wire.VarintType,
3981 protoreflect.Int32Kind: wire.VarintType,
3982 protoreflect.Sint32Kind: wire.VarintType,
3983 protoreflect.Uint32Kind: wire.VarintType,
3984 protoreflect.Int64Kind: wire.VarintType,
3985 protoreflect.Sint64Kind: wire.VarintType,
3986 protoreflect.Uint64Kind: wire.VarintType,
3987 protoreflect.Sfixed32Kind: wire.Fixed32Type,
3988 protoreflect.Fixed32Kind: wire.Fixed32Type,
3989 protoreflect.FloatKind: wire.Fixed32Type,
3990 protoreflect.Sfixed64Kind: wire.Fixed64Type,
3991 protoreflect.Fixed64Kind: wire.Fixed64Type,
3992 protoreflect.DoubleKind: wire.Fixed64Type,
3993 protoreflect.StringKind: wire.BytesType,
3994 protoreflect.BytesKind: wire.BytesType,
3995 protoreflect.MessageKind: wire.BytesType,
3996 protoreflect.GroupKind: wire.StartGroupType,
3997}