github.com/gogo/protobuf@v1.3.2/test/oneofembed/oneofembed.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: oneofembed.proto 3 4 package proto 5 6 import ( 7 bytes "bytes" 8 fmt "fmt" 9 _ "github.com/gogo/protobuf/gogoproto" 10 proto "github.com/gogo/protobuf/proto" 11 math "math" 12 ) 13 14 // Reference imports to suppress errors if they are not otherwise used. 15 var _ = proto.Marshal 16 var _ = fmt.Errorf 17 var _ = math.Inf 18 19 // This is a compile-time assertion to ensure that this generated file 20 // is compatible with the proto package it is being compiled against. 21 // A compilation error at this line likely means your copy of the 22 // proto package needs to be updated. 23 const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 24 25 type Foo struct { 26 *Bar `protobuf:"bytes,1,opt,name=bar,proto3,embedded=bar" json:"bar,omitempty"` 27 XXX_NoUnkeyedLiteral struct{} `json:"-"` 28 XXX_unrecognized []byte `json:"-"` 29 XXX_sizecache int32 `json:"-"` 30 } 31 32 func (m *Foo) Reset() { *m = Foo{} } 33 func (m *Foo) String() string { return proto.CompactTextString(m) } 34 func (*Foo) ProtoMessage() {} 35 func (*Foo) Descriptor() ([]byte, []int) { 36 return fileDescriptor_70b95aca3b5d76ed, []int{0} 37 } 38 func (m *Foo) XXX_Unmarshal(b []byte) error { 39 return xxx_messageInfo_Foo.Unmarshal(m, b) 40 } 41 func (m *Foo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 42 return xxx_messageInfo_Foo.Marshal(b, m, deterministic) 43 } 44 func (m *Foo) XXX_Merge(src proto.Message) { 45 xxx_messageInfo_Foo.Merge(m, src) 46 } 47 func (m *Foo) XXX_Size() int { 48 return xxx_messageInfo_Foo.Size(m) 49 } 50 func (m *Foo) XXX_DiscardUnknown() { 51 xxx_messageInfo_Foo.DiscardUnknown(m) 52 } 53 54 var xxx_messageInfo_Foo proto.InternalMessageInfo 55 56 type Bar struct { 57 // Types that are valid to be assigned to Pick: 58 // *Bar_A 59 // *Bar_B 60 Pick isBar_Pick `protobuf_oneof:"pick"` 61 XXX_NoUnkeyedLiteral struct{} `json:"-"` 62 XXX_unrecognized []byte `json:"-"` 63 XXX_sizecache int32 `json:"-"` 64 } 65 66 func (m *Bar) Reset() { *m = Bar{} } 67 func (m *Bar) String() string { return proto.CompactTextString(m) } 68 func (*Bar) ProtoMessage() {} 69 func (*Bar) Descriptor() ([]byte, []int) { 70 return fileDescriptor_70b95aca3b5d76ed, []int{1} 71 } 72 func (m *Bar) XXX_Unmarshal(b []byte) error { 73 return xxx_messageInfo_Bar.Unmarshal(m, b) 74 } 75 func (m *Bar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 76 return xxx_messageInfo_Bar.Marshal(b, m, deterministic) 77 } 78 func (m *Bar) XXX_Merge(src proto.Message) { 79 xxx_messageInfo_Bar.Merge(m, src) 80 } 81 func (m *Bar) XXX_Size() int { 82 return xxx_messageInfo_Bar.Size(m) 83 } 84 func (m *Bar) XXX_DiscardUnknown() { 85 xxx_messageInfo_Bar.DiscardUnknown(m) 86 } 87 88 var xxx_messageInfo_Bar proto.InternalMessageInfo 89 90 type isBar_Pick interface { 91 isBar_Pick() 92 Equal(interface{}) bool 93 Compare(interface{}) int 94 } 95 96 type Bar_A struct { 97 A bool `protobuf:"varint,11,opt,name=a,proto3,oneof" json:"a,omitempty"` 98 } 99 type Bar_B struct { 100 B bool `protobuf:"varint,12,opt,name=b,proto3,oneof" json:"b,omitempty"` 101 } 102 103 func (*Bar_A) isBar_Pick() {} 104 func (*Bar_B) isBar_Pick() {} 105 106 func (m *Bar) GetPick() isBar_Pick { 107 if m != nil { 108 return m.Pick 109 } 110 return nil 111 } 112 113 func (m *Bar) GetA() bool { 114 if x, ok := m.GetPick().(*Bar_A); ok { 115 return x.A 116 } 117 return false 118 } 119 120 func (m *Bar) GetB() bool { 121 if x, ok := m.GetPick().(*Bar_B); ok { 122 return x.B 123 } 124 return false 125 } 126 127 // XXX_OneofWrappers is for the internal use of the proto package. 128 func (*Bar) XXX_OneofWrappers() []interface{} { 129 return []interface{}{ 130 (*Bar_A)(nil), 131 (*Bar_B)(nil), 132 } 133 } 134 135 func init() { 136 proto.RegisterType((*Foo)(nil), "proto.Foo") 137 proto.RegisterType((*Bar)(nil), "proto.Bar") 138 } 139 140 func init() { proto.RegisterFile("oneofembed.proto", fileDescriptor_70b95aca3b5d76ed) } 141 142 var fileDescriptor_70b95aca3b5d76ed = []byte{ 143 // 175 bytes of a gzipped FileDescriptorProto 144 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0xcf, 0x4b, 0xcd, 145 0x4f, 0x4b, 0xcd, 0x4d, 0x4a, 0x4d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 146 0x52, 0xba, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0xe9, 147 0xf9, 0xfa, 0x60, 0xe1, 0xa4, 0xd2, 0x34, 0x30, 0x0f, 0xcc, 0x01, 0xb3, 0x20, 0xba, 0x94, 0x34, 148 0xb9, 0x98, 0xdd, 0xf2, 0xf3, 0x85, 0x94, 0xb8, 0x98, 0x93, 0x12, 0x8b, 0x24, 0x18, 0x15, 0x18, 149 0x35, 0xb8, 0x8d, 0xb8, 0x20, 0x72, 0x7a, 0x4e, 0x89, 0x45, 0x4e, 0x2c, 0x17, 0xee, 0xc9, 0x33, 150 0x06, 0x81, 0x24, 0x95, 0x74, 0xb9, 0x98, 0x9d, 0x12, 0x8b, 0x84, 0xf8, 0xb8, 0x18, 0x13, 0x25, 151 0xb8, 0x15, 0x18, 0x35, 0x38, 0x3c, 0x18, 0x82, 0x18, 0x13, 0x41, 0xfc, 0x24, 0x09, 0x1e, 0x18, 152 0x3f, 0xc9, 0x89, 0x8d, 0x8b, 0xa5, 0x20, 0x33, 0x39, 0xdb, 0x49, 0xe0, 0xc7, 0x43, 0x39, 0xc6, 153 0x15, 0x8f, 0xe4, 0x18, 0x77, 0x3c, 0x92, 0x63, 0x5c, 0xf1, 0x58, 0x8e, 0x31, 0x89, 0x0d, 0x6c, 154 0xac, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x9f, 0x49, 0x0a, 0xbc, 0x00, 0x00, 0x00, 155 } 156 157 func (this *Foo) Compare(that interface{}) int { 158 if that == nil { 159 if this == nil { 160 return 0 161 } 162 return 1 163 } 164 165 that1, ok := that.(*Foo) 166 if !ok { 167 that2, ok := that.(Foo) 168 if ok { 169 that1 = &that2 170 } else { 171 return 1 172 } 173 } 174 if that1 == nil { 175 if this == nil { 176 return 0 177 } 178 return 1 179 } else if this == nil { 180 return -1 181 } 182 if c := this.Bar.Compare(that1.Bar); c != 0 { 183 return c 184 } 185 if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { 186 return c 187 } 188 return 0 189 } 190 func (this *Bar) Compare(that interface{}) int { 191 if that == nil { 192 if this == nil { 193 return 0 194 } 195 return 1 196 } 197 198 that1, ok := that.(*Bar) 199 if !ok { 200 that2, ok := that.(Bar) 201 if ok { 202 that1 = &that2 203 } else { 204 return 1 205 } 206 } 207 if that1 == nil { 208 if this == nil { 209 return 0 210 } 211 return 1 212 } else if this == nil { 213 return -1 214 } 215 if that1.Pick == nil { 216 if this.Pick != nil { 217 return 1 218 } 219 } else if this.Pick == nil { 220 return -1 221 } else { 222 thisType := -1 223 switch this.Pick.(type) { 224 case *Bar_A: 225 thisType = 0 226 case *Bar_B: 227 thisType = 1 228 default: 229 panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Pick)) 230 } 231 that1Type := -1 232 switch that1.Pick.(type) { 233 case *Bar_A: 234 that1Type = 0 235 case *Bar_B: 236 that1Type = 1 237 default: 238 panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.Pick)) 239 } 240 if thisType == that1Type { 241 if c := this.Pick.Compare(that1.Pick); c != 0 { 242 return c 243 } 244 } else if thisType < that1Type { 245 return -1 246 } else if thisType > that1Type { 247 return 1 248 } 249 } 250 if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { 251 return c 252 } 253 return 0 254 } 255 func (this *Bar_A) Compare(that interface{}) int { 256 if that == nil { 257 if this == nil { 258 return 0 259 } 260 return 1 261 } 262 263 that1, ok := that.(*Bar_A) 264 if !ok { 265 that2, ok := that.(Bar_A) 266 if ok { 267 that1 = &that2 268 } else { 269 return 1 270 } 271 } 272 if that1 == nil { 273 if this == nil { 274 return 0 275 } 276 return 1 277 } else if this == nil { 278 return -1 279 } 280 if this.A != that1.A { 281 if !this.A { 282 return -1 283 } 284 return 1 285 } 286 return 0 287 } 288 func (this *Bar_B) Compare(that interface{}) int { 289 if that == nil { 290 if this == nil { 291 return 0 292 } 293 return 1 294 } 295 296 that1, ok := that.(*Bar_B) 297 if !ok { 298 that2, ok := that.(Bar_B) 299 if ok { 300 that1 = &that2 301 } else { 302 return 1 303 } 304 } 305 if that1 == nil { 306 if this == nil { 307 return 0 308 } 309 return 1 310 } else if this == nil { 311 return -1 312 } 313 if this.B != that1.B { 314 if !this.B { 315 return -1 316 } 317 return 1 318 } 319 return 0 320 } 321 func (this *Foo) Equal(that interface{}) bool { 322 if that == nil { 323 return this == nil 324 } 325 326 that1, ok := that.(*Foo) 327 if !ok { 328 that2, ok := that.(Foo) 329 if ok { 330 that1 = &that2 331 } else { 332 return false 333 } 334 } 335 if that1 == nil { 336 return this == nil 337 } else if this == nil { 338 return false 339 } 340 if !this.Bar.Equal(that1.Bar) { 341 return false 342 } 343 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { 344 return false 345 } 346 return true 347 } 348 func (this *Bar) Equal(that interface{}) bool { 349 if that == nil { 350 return this == nil 351 } 352 353 that1, ok := that.(*Bar) 354 if !ok { 355 that2, ok := that.(Bar) 356 if ok { 357 that1 = &that2 358 } else { 359 return false 360 } 361 } 362 if that1 == nil { 363 return this == nil 364 } else if this == nil { 365 return false 366 } 367 if that1.Pick == nil { 368 if this.Pick != nil { 369 return false 370 } 371 } else if this.Pick == nil { 372 return false 373 } else if !this.Pick.Equal(that1.Pick) { 374 return false 375 } 376 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { 377 return false 378 } 379 return true 380 } 381 func (this *Bar_A) Equal(that interface{}) bool { 382 if that == nil { 383 return this == nil 384 } 385 386 that1, ok := that.(*Bar_A) 387 if !ok { 388 that2, ok := that.(Bar_A) 389 if ok { 390 that1 = &that2 391 } else { 392 return false 393 } 394 } 395 if that1 == nil { 396 return this == nil 397 } else if this == nil { 398 return false 399 } 400 if this.A != that1.A { 401 return false 402 } 403 return true 404 } 405 func (this *Bar_B) Equal(that interface{}) bool { 406 if that == nil { 407 return this == nil 408 } 409 410 that1, ok := that.(*Bar_B) 411 if !ok { 412 that2, ok := that.(Bar_B) 413 if ok { 414 that1 = &that2 415 } else { 416 return false 417 } 418 } 419 if that1 == nil { 420 return this == nil 421 } else if this == nil { 422 return false 423 } 424 if this.B != that1.B { 425 return false 426 } 427 return true 428 } 429 func NewPopulatedFoo(r randyOneofembed, easy bool) *Foo { 430 this := &Foo{} 431 if r.Intn(5) != 0 { 432 this.Bar = NewPopulatedBar(r, easy) 433 } 434 if !easy && r.Intn(10) != 0 { 435 this.XXX_unrecognized = randUnrecognizedOneofembed(r, 2) 436 } 437 return this 438 } 439 440 func NewPopulatedBar(r randyOneofembed, easy bool) *Bar { 441 this := &Bar{} 442 oneofNumber_Pick := []int32{11, 12}[r.Intn(2)] 443 switch oneofNumber_Pick { 444 case 11: 445 this.Pick = NewPopulatedBar_A(r, easy) 446 case 12: 447 this.Pick = NewPopulatedBar_B(r, easy) 448 } 449 if !easy && r.Intn(10) != 0 { 450 this.XXX_unrecognized = randUnrecognizedOneofembed(r, 13) 451 } 452 return this 453 } 454 455 func NewPopulatedBar_A(r randyOneofembed, easy bool) *Bar_A { 456 this := &Bar_A{} 457 this.A = bool(bool(r.Intn(2) == 0)) 458 return this 459 } 460 func NewPopulatedBar_B(r randyOneofembed, easy bool) *Bar_B { 461 this := &Bar_B{} 462 this.B = bool(bool(r.Intn(2) == 0)) 463 return this 464 } 465 466 type randyOneofembed interface { 467 Float32() float32 468 Float64() float64 469 Int63() int64 470 Int31() int32 471 Uint32() uint32 472 Intn(n int) int 473 } 474 475 func randUTF8RuneOneofembed(r randyOneofembed) rune { 476 ru := r.Intn(62) 477 if ru < 10 { 478 return rune(ru + 48) 479 } else if ru < 36 { 480 return rune(ru + 55) 481 } 482 return rune(ru + 61) 483 } 484 func randStringOneofembed(r randyOneofembed) string { 485 v1 := r.Intn(100) 486 tmps := make([]rune, v1) 487 for i := 0; i < v1; i++ { 488 tmps[i] = randUTF8RuneOneofembed(r) 489 } 490 return string(tmps) 491 } 492 func randUnrecognizedOneofembed(r randyOneofembed, maxFieldNumber int) (dAtA []byte) { 493 l := r.Intn(5) 494 for i := 0; i < l; i++ { 495 wire := r.Intn(4) 496 if wire == 3 { 497 wire = 5 498 } 499 fieldNumber := maxFieldNumber + r.Intn(100) 500 dAtA = randFieldOneofembed(dAtA, r, fieldNumber, wire) 501 } 502 return dAtA 503 } 504 func randFieldOneofembed(dAtA []byte, r randyOneofembed, fieldNumber int, wire int) []byte { 505 key := uint32(fieldNumber)<<3 | uint32(wire) 506 switch wire { 507 case 0: 508 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(key)) 509 v2 := r.Int63() 510 if r.Intn(2) == 0 { 511 v2 *= -1 512 } 513 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(v2)) 514 case 1: 515 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(key)) 516 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))) 517 case 2: 518 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(key)) 519 ll := r.Intn(100) 520 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(ll)) 521 for j := 0; j < ll; j++ { 522 dAtA = append(dAtA, byte(r.Intn(256))) 523 } 524 default: 525 dAtA = encodeVarintPopulateOneofembed(dAtA, uint64(key)) 526 dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) 527 } 528 return dAtA 529 } 530 func encodeVarintPopulateOneofembed(dAtA []byte, v uint64) []byte { 531 for v >= 1<<7 { 532 dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) 533 v >>= 7 534 } 535 dAtA = append(dAtA, uint8(v)) 536 return dAtA 537 }