1
2
3
4 package test
5
6 import (
7 bytes "bytes"
8 fmt "fmt"
9 _ "github.com/gogo/protobuf/gogoproto"
10 proto "github.com/gogo/protobuf/proto"
11 io "io"
12 math "math"
13 math_bits "math/bits"
14 reflect "reflect"
15 strings "strings"
16 )
17
18
19 var _ = proto.Marshal
20 var _ = fmt.Errorf
21 var _ = math.Inf
22
23
24
25
26
27 const _ = proto.GoGoProtoPackageIsVersion3
28
29 type OneofTest struct {
30
31
32 Union isOneofTest_Union `protobuf_oneof:"union"`
33 XXX_NoUnkeyedLiteral struct{} `json:"-"`
34 XXX_unrecognized []byte `json:"-"`
35 XXX_sizecache int32 `json:"-"`
36 }
37
38 func (m *OneofTest) Reset() { *m = OneofTest{} }
39 func (m *OneofTest) String() string { return proto.CompactTextString(m) }
40 func (*OneofTest) ProtoMessage() {}
41 func (*OneofTest) Descriptor() ([]byte, []int) {
42 return fileDescriptor_fbf4e8d164dccde1, []int{0}
43 }
44 func (m *OneofTest) XXX_Unmarshal(b []byte) error {
45 return m.Unmarshal(b)
46 }
47 func (m *OneofTest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
48 if deterministic {
49 return xxx_messageInfo_OneofTest.Marshal(b, m, deterministic)
50 } else {
51 b = b[:cap(b)]
52 n, err := m.MarshalToSizedBuffer(b)
53 if err != nil {
54 return nil, err
55 }
56 return b[:n], nil
57 }
58 }
59 func (m *OneofTest) XXX_Merge(src proto.Message) {
60 xxx_messageInfo_OneofTest.Merge(m, src)
61 }
62 func (m *OneofTest) XXX_Size() int {
63 return m.Size()
64 }
65 func (m *OneofTest) XXX_DiscardUnknown() {
66 xxx_messageInfo_OneofTest.DiscardUnknown(m)
67 }
68
69 var xxx_messageInfo_OneofTest proto.InternalMessageInfo
70
71 const Default_OneofTest_I int32 = 4
72
73 type isOneofTest_Union interface {
74 isOneofTest_Union()
75 Equal(interface{}) bool
76 MarshalTo([]byte) (int, error)
77 Size() int
78 Compare(interface{}) int
79 }
80
81 type OneofTest_I struct {
82 I int32 `protobuf:"varint,1,opt,name=i,oneof,def=4" json:"i,omitempty"`
83 }
84
85 func (*OneofTest_I) isOneofTest_Union() {}
86
87 func (m *OneofTest) GetUnion() isOneofTest_Union {
88 if m != nil {
89 return m.Union
90 }
91 return nil
92 }
93
94 func (m *OneofTest) GetI() int32 {
95 if x, ok := m.GetUnion().(*OneofTest_I); ok {
96 return x.I
97 }
98 return Default_OneofTest_I
99 }
100
101
102 func (*OneofTest) XXX_OneofWrappers() []interface{} {
103 return []interface{}{
104 (*OneofTest_I)(nil),
105 }
106 }
107
108 func init() {
109 proto.RegisterType((*OneofTest)(nil), "test.OneofTest")
110 }
111
112 func init() { proto.RegisterFile("issue322.proto", fileDescriptor_fbf4e8d164dccde1) }
113
114 var fileDescriptor_fbf4e8d164dccde1 = []byte{
115
116 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x2c, 0x2e, 0x2e,
117 0x4d, 0x35, 0x36, 0x32, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x29, 0x49, 0x2d, 0x2e,
118 0x91, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f,
119 0xcf, 0xd7, 0x07, 0x4b, 0x26, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, 0x05, 0xd1, 0xa4, 0xa4,
120 0xce, 0xc5, 0xe9, 0x9f, 0x97, 0x9a, 0x9f, 0x16, 0x92, 0x5a, 0x5c, 0x22, 0x24, 0xc8, 0xc5, 0x98,
121 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6a, 0xc5, 0x68, 0xe2, 0xc1, 0x10, 0xc4, 0x98, 0xe9, 0xc4,
122 0xce, 0xc5, 0x5a, 0x9a, 0x97, 0x99, 0x9f, 0xe7, 0xa4, 0xf0, 0xe1, 0xa1, 0x1c, 0xe3, 0x8f, 0x87,
123 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0xee, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85,
124 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xae, 0x78, 0x2c, 0xc7, 0x08, 0x08, 0x00, 0x00, 0xff,
125 0xff, 0x42, 0xe9, 0xae, 0x78, 0x90, 0x00, 0x00, 0x00,
126 }
127
128 func (this *OneofTest) Compare(that interface{}) int {
129 if that == nil {
130 if this == nil {
131 return 0
132 }
133 return 1
134 }
135
136 that1, ok := that.(*OneofTest)
137 if !ok {
138 that2, ok := that.(OneofTest)
139 if ok {
140 that1 = &that2
141 } else {
142 return 1
143 }
144 }
145 if that1 == nil {
146 if this == nil {
147 return 0
148 }
149 return 1
150 } else if this == nil {
151 return -1
152 }
153 if that1.Union == nil {
154 if this.Union != nil {
155 return 1
156 }
157 } else if this.Union == nil {
158 return -1
159 } else {
160 thisType := -1
161 switch this.Union.(type) {
162 case *OneofTest_I:
163 thisType = 0
164 default:
165 panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Union))
166 }
167 that1Type := -1
168 switch that1.Union.(type) {
169 case *OneofTest_I:
170 that1Type = 0
171 default:
172 panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.Union))
173 }
174 if thisType == that1Type {
175 if c := this.Union.Compare(that1.Union); c != 0 {
176 return c
177 }
178 } else if thisType < that1Type {
179 return -1
180 } else if thisType > that1Type {
181 return 1
182 }
183 }
184 if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
185 return c
186 }
187 return 0
188 }
189 func (this *OneofTest_I) Compare(that interface{}) int {
190 if that == nil {
191 if this == nil {
192 return 0
193 }
194 return 1
195 }
196
197 that1, ok := that.(*OneofTest_I)
198 if !ok {
199 that2, ok := that.(OneofTest_I)
200 if ok {
201 that1 = &that2
202 } else {
203 return 1
204 }
205 }
206 if that1 == nil {
207 if this == nil {
208 return 0
209 }
210 return 1
211 } else if this == nil {
212 return -1
213 }
214 if this.I != that1.I {
215 if this.I < that1.I {
216 return -1
217 }
218 return 1
219 }
220 return 0
221 }
222 func (this *OneofTest) Equal(that interface{}) bool {
223 if that == nil {
224 return this == nil
225 }
226
227 that1, ok := that.(*OneofTest)
228 if !ok {
229 that2, ok := that.(OneofTest)
230 if ok {
231 that1 = &that2
232 } else {
233 return false
234 }
235 }
236 if that1 == nil {
237 return this == nil
238 } else if this == nil {
239 return false
240 }
241 if that1.Union == nil {
242 if this.Union != nil {
243 return false
244 }
245 } else if this.Union == nil {
246 return false
247 } else if !this.Union.Equal(that1.Union) {
248 return false
249 }
250 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
251 return false
252 }
253 return true
254 }
255 func (this *OneofTest_I) Equal(that interface{}) bool {
256 if that == nil {
257 return this == nil
258 }
259
260 that1, ok := that.(*OneofTest_I)
261 if !ok {
262 that2, ok := that.(OneofTest_I)
263 if ok {
264 that1 = &that2
265 } else {
266 return false
267 }
268 }
269 if that1 == nil {
270 return this == nil
271 } else if this == nil {
272 return false
273 }
274 if this.I != that1.I {
275 return false
276 }
277 return true
278 }
279 func (this *OneofTest) GoString() string {
280 if this == nil {
281 return "nil"
282 }
283 s := make([]string, 0, 5)
284 s = append(s, "&test.OneofTest{")
285 if this.Union != nil {
286 s = append(s, "Union: "+fmt.Sprintf("%#v", this.Union)+",\n")
287 }
288 if this.XXX_unrecognized != nil {
289 s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
290 }
291 s = append(s, "}")
292 return strings.Join(s, "")
293 }
294 func (this *OneofTest_I) GoString() string {
295 if this == nil {
296 return "nil"
297 }
298 s := strings.Join([]string{`&test.OneofTest_I{` +
299 `I:` + fmt.Sprintf("%#v", this.I) + `}`}, ", ")
300 return s
301 }
302 func valueToGoStringIssue322(v interface{}, typ string) string {
303 rv := reflect.ValueOf(v)
304 if rv.IsNil() {
305 return "nil"
306 }
307 pv := reflect.Indirect(rv).Interface()
308 return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
309 }
310 func (m *OneofTest) Marshal() (dAtA []byte, err error) {
311 size := m.Size()
312 dAtA = make([]byte, size)
313 n, err := m.MarshalToSizedBuffer(dAtA[:size])
314 if err != nil {
315 return nil, err
316 }
317 return dAtA[:n], nil
318 }
319
320 func (m *OneofTest) MarshalTo(dAtA []byte) (int, error) {
321 size := m.Size()
322 return m.MarshalToSizedBuffer(dAtA[:size])
323 }
324
325 func (m *OneofTest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
326 i := len(dAtA)
327 _ = i
328 var l int
329 _ = l
330 if m.XXX_unrecognized != nil {
331 i -= len(m.XXX_unrecognized)
332 copy(dAtA[i:], m.XXX_unrecognized)
333 }
334 if m.Union != nil {
335 {
336 size := m.Union.Size()
337 i -= size
338 if _, err := m.Union.MarshalTo(dAtA[i:]); err != nil {
339 return 0, err
340 }
341 }
342 }
343 return len(dAtA) - i, nil
344 }
345
346 func (m *OneofTest_I) MarshalTo(dAtA []byte) (int, error) {
347 size := m.Size()
348 return m.MarshalToSizedBuffer(dAtA[:size])
349 }
350
351 func (m *OneofTest_I) MarshalToSizedBuffer(dAtA []byte) (int, error) {
352 i := len(dAtA)
353 i = encodeVarintIssue322(dAtA, i, uint64(m.I))
354 i--
355 dAtA[i] = 0x8
356 return len(dAtA) - i, nil
357 }
358 func encodeVarintIssue322(dAtA []byte, offset int, v uint64) int {
359 offset -= sovIssue322(v)
360 base := offset
361 for v >= 1<<7 {
362 dAtA[offset] = uint8(v&0x7f | 0x80)
363 v >>= 7
364 offset++
365 }
366 dAtA[offset] = uint8(v)
367 return base
368 }
369 func NewPopulatedOneofTest(r randyIssue322, easy bool) *OneofTest {
370 this := &OneofTest{}
371 oneofNumber_Union := []int32{1}[r.Intn(1)]
372 switch oneofNumber_Union {
373 case 1:
374 this.Union = NewPopulatedOneofTest_I(r, easy)
375 }
376 if !easy && r.Intn(10) != 0 {
377 this.XXX_unrecognized = randUnrecognizedIssue322(r, 2)
378 }
379 return this
380 }
381
382 func NewPopulatedOneofTest_I(r randyIssue322, easy bool) *OneofTest_I {
383 this := &OneofTest_I{}
384 this.I = int32(r.Int31())
385 if r.Intn(2) == 0 {
386 this.I *= -1
387 }
388 return this
389 }
390
391 type randyIssue322 interface {
392 Float32() float32
393 Float64() float64
394 Int63() int64
395 Int31() int32
396 Uint32() uint32
397 Intn(n int) int
398 }
399
400 func randUTF8RuneIssue322(r randyIssue322) rune {
401 ru := r.Intn(62)
402 if ru < 10 {
403 return rune(ru + 48)
404 } else if ru < 36 {
405 return rune(ru + 55)
406 }
407 return rune(ru + 61)
408 }
409 func randStringIssue322(r randyIssue322) string {
410 v1 := r.Intn(100)
411 tmps := make([]rune, v1)
412 for i := 0; i < v1; i++ {
413 tmps[i] = randUTF8RuneIssue322(r)
414 }
415 return string(tmps)
416 }
417 func randUnrecognizedIssue322(r randyIssue322, maxFieldNumber int) (dAtA []byte) {
418 l := r.Intn(5)
419 for i := 0; i < l; i++ {
420 wire := r.Intn(4)
421 if wire == 3 {
422 wire = 5
423 }
424 fieldNumber := maxFieldNumber + r.Intn(100)
425 dAtA = randFieldIssue322(dAtA, r, fieldNumber, wire)
426 }
427 return dAtA
428 }
429 func randFieldIssue322(dAtA []byte, r randyIssue322, fieldNumber int, wire int) []byte {
430 key := uint32(fieldNumber)<<3 | uint32(wire)
431 switch wire {
432 case 0:
433 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(key))
434 v2 := r.Int63()
435 if r.Intn(2) == 0 {
436 v2 *= -1
437 }
438 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(v2))
439 case 1:
440 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(key))
441 dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
442 case 2:
443 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(key))
444 ll := r.Intn(100)
445 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(ll))
446 for j := 0; j < ll; j++ {
447 dAtA = append(dAtA, byte(r.Intn(256)))
448 }
449 default:
450 dAtA = encodeVarintPopulateIssue322(dAtA, uint64(key))
451 dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
452 }
453 return dAtA
454 }
455 func encodeVarintPopulateIssue322(dAtA []byte, v uint64) []byte {
456 for v >= 1<<7 {
457 dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
458 v >>= 7
459 }
460 dAtA = append(dAtA, uint8(v))
461 return dAtA
462 }
463 func (m *OneofTest) Size() (n int) {
464 if m == nil {
465 return 0
466 }
467 var l int
468 _ = l
469 if m.Union != nil {
470 n += m.Union.Size()
471 }
472 if m.XXX_unrecognized != nil {
473 n += len(m.XXX_unrecognized)
474 }
475 return n
476 }
477
478 func (m *OneofTest_I) Size() (n int) {
479 if m == nil {
480 return 0
481 }
482 var l int
483 _ = l
484 n += 1 + sovIssue322(uint64(m.I))
485 return n
486 }
487
488 func sovIssue322(x uint64) (n int) {
489 return (math_bits.Len64(x|1) + 6) / 7
490 }
491 func sozIssue322(x uint64) (n int) {
492 return sovIssue322(uint64((x << 1) ^ uint64((int64(x) >> 63))))
493 }
494 func (m *OneofTest) Unmarshal(dAtA []byte) error {
495 l := len(dAtA)
496 iNdEx := 0
497 for iNdEx < l {
498 preIndex := iNdEx
499 var wire uint64
500 for shift := uint(0); ; shift += 7 {
501 if shift >= 64 {
502 return ErrIntOverflowIssue322
503 }
504 if iNdEx >= l {
505 return io.ErrUnexpectedEOF
506 }
507 b := dAtA[iNdEx]
508 iNdEx++
509 wire |= uint64(b&0x7F) << shift
510 if b < 0x80 {
511 break
512 }
513 }
514 fieldNum := int32(wire >> 3)
515 wireType := int(wire & 0x7)
516 if wireType == 4 {
517 return fmt.Errorf("proto: OneofTest: wiretype end group for non-group")
518 }
519 if fieldNum <= 0 {
520 return fmt.Errorf("proto: OneofTest: illegal tag %d (wire type %d)", fieldNum, wire)
521 }
522 switch fieldNum {
523 case 1:
524 if wireType != 0 {
525 return fmt.Errorf("proto: wrong wireType = %d for field I", wireType)
526 }
527 var v int32
528 for shift := uint(0); ; shift += 7 {
529 if shift >= 64 {
530 return ErrIntOverflowIssue322
531 }
532 if iNdEx >= l {
533 return io.ErrUnexpectedEOF
534 }
535 b := dAtA[iNdEx]
536 iNdEx++
537 v |= int32(b&0x7F) << shift
538 if b < 0x80 {
539 break
540 }
541 }
542 m.Union = &OneofTest_I{v}
543 default:
544 iNdEx = preIndex
545 skippy, err := skipIssue322(dAtA[iNdEx:])
546 if err != nil {
547 return err
548 }
549 if (skippy < 0) || (iNdEx+skippy) < 0 {
550 return ErrInvalidLengthIssue322
551 }
552 if (iNdEx + skippy) > l {
553 return io.ErrUnexpectedEOF
554 }
555 m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
556 iNdEx += skippy
557 }
558 }
559
560 if iNdEx > l {
561 return io.ErrUnexpectedEOF
562 }
563 return nil
564 }
565 func skipIssue322(dAtA []byte) (n int, err error) {
566 l := len(dAtA)
567 iNdEx := 0
568 depth := 0
569 for iNdEx < l {
570 var wire uint64
571 for shift := uint(0); ; shift += 7 {
572 if shift >= 64 {
573 return 0, ErrIntOverflowIssue322
574 }
575 if iNdEx >= l {
576 return 0, io.ErrUnexpectedEOF
577 }
578 b := dAtA[iNdEx]
579 iNdEx++
580 wire |= (uint64(b) & 0x7F) << shift
581 if b < 0x80 {
582 break
583 }
584 }
585 wireType := int(wire & 0x7)
586 switch wireType {
587 case 0:
588 for shift := uint(0); ; shift += 7 {
589 if shift >= 64 {
590 return 0, ErrIntOverflowIssue322
591 }
592 if iNdEx >= l {
593 return 0, io.ErrUnexpectedEOF
594 }
595 iNdEx++
596 if dAtA[iNdEx-1] < 0x80 {
597 break
598 }
599 }
600 case 1:
601 iNdEx += 8
602 case 2:
603 var length int
604 for shift := uint(0); ; shift += 7 {
605 if shift >= 64 {
606 return 0, ErrIntOverflowIssue322
607 }
608 if iNdEx >= l {
609 return 0, io.ErrUnexpectedEOF
610 }
611 b := dAtA[iNdEx]
612 iNdEx++
613 length |= (int(b) & 0x7F) << shift
614 if b < 0x80 {
615 break
616 }
617 }
618 if length < 0 {
619 return 0, ErrInvalidLengthIssue322
620 }
621 iNdEx += length
622 case 3:
623 depth++
624 case 4:
625 if depth == 0 {
626 return 0, ErrUnexpectedEndOfGroupIssue322
627 }
628 depth--
629 case 5:
630 iNdEx += 4
631 default:
632 return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
633 }
634 if iNdEx < 0 {
635 return 0, ErrInvalidLengthIssue322
636 }
637 if depth == 0 {
638 return iNdEx, nil
639 }
640 }
641 return 0, io.ErrUnexpectedEOF
642 }
643
644 var (
645 ErrInvalidLengthIssue322 = fmt.Errorf("proto: negative length found during unmarshaling")
646 ErrIntOverflowIssue322 = fmt.Errorf("proto: integer overflow")
647 ErrUnexpectedEndOfGroupIssue322 = fmt.Errorf("proto: unexpected end of group")
648 )
649
View as plain text