github.com/gogo/protobuf@v1.3.2/test/protosize/protosize.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: protosize.proto 3 4 package protosize 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 ) 15 16 // Reference imports to suppress errors if they are not otherwise used. 17 var _ = proto.Marshal 18 var _ = fmt.Errorf 19 var _ = math.Inf 20 21 // This is a compile-time assertion to ensure that this generated file 22 // is compatible with the proto package it is being compiled against. 23 // A compilation error at this line likely means your copy of the 24 // proto package needs to be updated. 25 const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 26 27 type SizeMessage struct { 28 Size *int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` 29 ProtoSize_ *int64 `protobuf:"varint,2,opt,name=proto_size,json=protoSize" json:"proto_size,omitempty"` 30 Equal_ *bool `protobuf:"varint,3,opt,name=Equal" json:"Equal,omitempty"` 31 String_ *string `protobuf:"bytes,4,opt,name=String" json:"String,omitempty"` 32 XXX_NoUnkeyedLiteral struct{} `json:"-"` 33 XXX_unrecognized []byte `json:"-"` 34 XXX_sizecache int32 `json:"-"` 35 } 36 37 func (m *SizeMessage) Reset() { *m = SizeMessage{} } 38 func (m *SizeMessage) String() string { return proto.CompactTextString(m) } 39 func (*SizeMessage) ProtoMessage() {} 40 func (*SizeMessage) Descriptor() ([]byte, []int) { 41 return fileDescriptor_16520eec64ed25c4, []int{0} 42 } 43 func (m *SizeMessage) XXX_Unmarshal(b []byte) error { 44 return m.Unmarshal(b) 45 } 46 func (m *SizeMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 47 if deterministic { 48 return xxx_messageInfo_SizeMessage.Marshal(b, m, deterministic) 49 } else { 50 b = b[:cap(b)] 51 n, err := m.MarshalToSizedBuffer(b) 52 if err != nil { 53 return nil, err 54 } 55 return b[:n], nil 56 } 57 } 58 func (m *SizeMessage) XXX_Merge(src proto.Message) { 59 xxx_messageInfo_SizeMessage.Merge(m, src) 60 } 61 func (m *SizeMessage) XXX_Size() int { 62 return m.ProtoSize() 63 } 64 func (m *SizeMessage) XXX_DiscardUnknown() { 65 xxx_messageInfo_SizeMessage.DiscardUnknown(m) 66 } 67 68 var xxx_messageInfo_SizeMessage proto.InternalMessageInfo 69 70 func (m *SizeMessage) GetSize() int64 { 71 if m != nil && m.Size != nil { 72 return *m.Size 73 } 74 return 0 75 } 76 77 func (m *SizeMessage) GetProtoSize_() int64 { 78 if m != nil && m.ProtoSize_ != nil { 79 return *m.ProtoSize_ 80 } 81 return 0 82 } 83 84 func (m *SizeMessage) GetEqual_() bool { 85 if m != nil && m.Equal_ != nil { 86 return *m.Equal_ 87 } 88 return false 89 } 90 91 func (m *SizeMessage) GetString_() string { 92 if m != nil && m.String_ != nil { 93 return *m.String_ 94 } 95 return "" 96 } 97 98 func init() { 99 proto.RegisterType((*SizeMessage)(nil), "protosize.SizeMessage") 100 } 101 102 func init() { proto.RegisterFile("protosize.proto", fileDescriptor_16520eec64ed25c4) } 103 104 var fileDescriptor_16520eec64ed25c4 = []byte{ 105 // 182 bytes of a gzipped FileDescriptorProto 106 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0x28, 0xca, 0x2f, 107 0xc9, 0x2f, 0xce, 0xac, 0x4a, 0xd5, 0x03, 0xb3, 0x84, 0x38, 0xe1, 0x02, 0x52, 0xba, 0xe9, 0x99, 108 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0xfa, 0x60, 0xa9, 109 0xa4, 0xd2, 0x34, 0x30, 0x0f, 0xcc, 0x01, 0xb3, 0x20, 0x3a, 0x95, 0xf2, 0xb8, 0xb8, 0x83, 0x33, 110 0xab, 0x52, 0x7d, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0x84, 0xb8, 0x58, 0x40, 0xa6, 0x48, 111 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x81, 0xd9, 0x42, 0xb2, 0x5c, 0x5c, 0x60, 0xb5, 0xf1, 0x60, 112 0x19, 0x26, 0xb0, 0x0c, 0xc4, 0x42, 0x90, 0x4e, 0x21, 0x11, 0x2e, 0x56, 0xd7, 0xc2, 0xd2, 0xc4, 113 0x1c, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x08, 0x47, 0x48, 0x8c, 0x8b, 0x2d, 0xb8, 0xa4, 114 0x28, 0x33, 0x2f, 0x5d, 0x82, 0x45, 0x81, 0x51, 0x83, 0x33, 0x08, 0xca, 0x73, 0x92, 0xf8, 0xf1, 115 0x50, 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x1d, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 116 0xf0, 0x48, 0x8e, 0x71, 0xc1, 0x63, 0x39, 0x46, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xf7, 117 0x87, 0xb3, 0xd5, 0x00, 0x00, 0x00, 118 } 119 120 func (this *SizeMessage) Equal(that interface{}) bool { 121 if that == nil { 122 return this == nil 123 } 124 125 that1, ok := that.(*SizeMessage) 126 if !ok { 127 that2, ok := that.(SizeMessage) 128 if ok { 129 that1 = &that2 130 } else { 131 return false 132 } 133 } 134 if that1 == nil { 135 return this == nil 136 } else if this == nil { 137 return false 138 } 139 if this.Size != nil && that1.Size != nil { 140 if *this.Size != *that1.Size { 141 return false 142 } 143 } else if this.Size != nil { 144 return false 145 } else if that1.Size != nil { 146 return false 147 } 148 if this.ProtoSize_ != nil && that1.ProtoSize_ != nil { 149 if *this.ProtoSize_ != *that1.ProtoSize_ { 150 return false 151 } 152 } else if this.ProtoSize_ != nil { 153 return false 154 } else if that1.ProtoSize_ != nil { 155 return false 156 } 157 if this.Equal_ != nil && that1.Equal_ != nil { 158 if *this.Equal_ != *that1.Equal_ { 159 return false 160 } 161 } else if this.Equal_ != nil { 162 return false 163 } else if that1.Equal_ != nil { 164 return false 165 } 166 if this.String_ != nil && that1.String_ != nil { 167 if *this.String_ != *that1.String_ { 168 return false 169 } 170 } else if this.String_ != nil { 171 return false 172 } else if that1.String_ != nil { 173 return false 174 } 175 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { 176 return false 177 } 178 return true 179 } 180 func (m *SizeMessage) Marshal() (dAtA []byte, err error) { 181 size := m.ProtoSize() 182 dAtA = make([]byte, size) 183 n, err := m.MarshalToSizedBuffer(dAtA[:size]) 184 if err != nil { 185 return nil, err 186 } 187 return dAtA[:n], nil 188 } 189 190 func (m *SizeMessage) MarshalTo(dAtA []byte) (int, error) { 191 size := m.ProtoSize() 192 return m.MarshalToSizedBuffer(dAtA[:size]) 193 } 194 195 func (m *SizeMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { 196 i := len(dAtA) 197 _ = i 198 var l int 199 _ = l 200 if m.XXX_unrecognized != nil { 201 i -= len(m.XXX_unrecognized) 202 copy(dAtA[i:], m.XXX_unrecognized) 203 } 204 if m.String_ != nil { 205 i -= len(*m.String_) 206 copy(dAtA[i:], *m.String_) 207 i = encodeVarintProtosize(dAtA, i, uint64(len(*m.String_))) 208 i-- 209 dAtA[i] = 0x22 210 } 211 if m.Equal_ != nil { 212 i-- 213 if *m.Equal_ { 214 dAtA[i] = 1 215 } else { 216 dAtA[i] = 0 217 } 218 i-- 219 dAtA[i] = 0x18 220 } 221 if m.ProtoSize_ != nil { 222 i = encodeVarintProtosize(dAtA, i, uint64(*m.ProtoSize_)) 223 i-- 224 dAtA[i] = 0x10 225 } 226 if m.Size != nil { 227 i = encodeVarintProtosize(dAtA, i, uint64(*m.Size)) 228 i-- 229 dAtA[i] = 0x8 230 } 231 return len(dAtA) - i, nil 232 } 233 234 func encodeVarintProtosize(dAtA []byte, offset int, v uint64) int { 235 offset -= sovProtosize(v) 236 base := offset 237 for v >= 1<<7 { 238 dAtA[offset] = uint8(v&0x7f | 0x80) 239 v >>= 7 240 offset++ 241 } 242 dAtA[offset] = uint8(v) 243 return base 244 } 245 func NewPopulatedSizeMessage(r randyProtosize, easy bool) *SizeMessage { 246 this := &SizeMessage{} 247 if r.Intn(5) != 0 { 248 v1 := int64(r.Int63()) 249 if r.Intn(2) == 0 { 250 v1 *= -1 251 } 252 this.Size = &v1 253 } 254 if r.Intn(5) != 0 { 255 v2 := int64(r.Int63()) 256 if r.Intn(2) == 0 { 257 v2 *= -1 258 } 259 this.ProtoSize_ = &v2 260 } 261 if r.Intn(5) != 0 { 262 v3 := bool(bool(r.Intn(2) == 0)) 263 this.Equal_ = &v3 264 } 265 if r.Intn(5) != 0 { 266 v4 := string(randStringProtosize(r)) 267 this.String_ = &v4 268 } 269 if !easy && r.Intn(10) != 0 { 270 this.XXX_unrecognized = randUnrecognizedProtosize(r, 5) 271 } 272 return this 273 } 274 275 type randyProtosize interface { 276 Float32() float32 277 Float64() float64 278 Int63() int64 279 Int31() int32 280 Uint32() uint32 281 Intn(n int) int 282 } 283 284 func randUTF8RuneProtosize(r randyProtosize) rune { 285 ru := r.Intn(62) 286 if ru < 10 { 287 return rune(ru + 48) 288 } else if ru < 36 { 289 return rune(ru + 55) 290 } 291 return rune(ru + 61) 292 } 293 func randStringProtosize(r randyProtosize) string { 294 v5 := r.Intn(100) 295 tmps := make([]rune, v5) 296 for i := 0; i < v5; i++ { 297 tmps[i] = randUTF8RuneProtosize(r) 298 } 299 return string(tmps) 300 } 301 func randUnrecognizedProtosize(r randyProtosize, maxFieldNumber int) (dAtA []byte) { 302 l := r.Intn(5) 303 for i := 0; i < l; i++ { 304 wire := r.Intn(4) 305 if wire == 3 { 306 wire = 5 307 } 308 fieldNumber := maxFieldNumber + r.Intn(100) 309 dAtA = randFieldProtosize(dAtA, r, fieldNumber, wire) 310 } 311 return dAtA 312 } 313 func randFieldProtosize(dAtA []byte, r randyProtosize, fieldNumber int, wire int) []byte { 314 key := uint32(fieldNumber)<<3 | uint32(wire) 315 switch wire { 316 case 0: 317 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(key)) 318 v6 := r.Int63() 319 if r.Intn(2) == 0 { 320 v6 *= -1 321 } 322 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(v6)) 323 case 1: 324 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(key)) 325 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))) 326 case 2: 327 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(key)) 328 ll := r.Intn(100) 329 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(ll)) 330 for j := 0; j < ll; j++ { 331 dAtA = append(dAtA, byte(r.Intn(256))) 332 } 333 default: 334 dAtA = encodeVarintPopulateProtosize(dAtA, uint64(key)) 335 dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) 336 } 337 return dAtA 338 } 339 func encodeVarintPopulateProtosize(dAtA []byte, v uint64) []byte { 340 for v >= 1<<7 { 341 dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) 342 v >>= 7 343 } 344 dAtA = append(dAtA, uint8(v)) 345 return dAtA 346 } 347 func (m *SizeMessage) ProtoSize() (n int) { 348 if m == nil { 349 return 0 350 } 351 var l int 352 _ = l 353 if m.Size != nil { 354 n += 1 + sovProtosize(uint64(*m.Size)) 355 } 356 if m.ProtoSize_ != nil { 357 n += 1 + sovProtosize(uint64(*m.ProtoSize_)) 358 } 359 if m.Equal_ != nil { 360 n += 2 361 } 362 if m.String_ != nil { 363 l = len(*m.String_) 364 n += 1 + l + sovProtosize(uint64(l)) 365 } 366 if m.XXX_unrecognized != nil { 367 n += len(m.XXX_unrecognized) 368 } 369 return n 370 } 371 372 func sovProtosize(x uint64) (n int) { 373 return (math_bits.Len64(x|1) + 6) / 7 374 } 375 func sozProtosize(x uint64) (n int) { 376 return sovProtosize(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 377 } 378 func (m *SizeMessage) Unmarshal(dAtA []byte) error { 379 l := len(dAtA) 380 iNdEx := 0 381 for iNdEx < l { 382 preIndex := iNdEx 383 var wire uint64 384 for shift := uint(0); ; shift += 7 { 385 if shift >= 64 { 386 return ErrIntOverflowProtosize 387 } 388 if iNdEx >= l { 389 return io.ErrUnexpectedEOF 390 } 391 b := dAtA[iNdEx] 392 iNdEx++ 393 wire |= uint64(b&0x7F) << shift 394 if b < 0x80 { 395 break 396 } 397 } 398 fieldNum := int32(wire >> 3) 399 wireType := int(wire & 0x7) 400 if wireType == 4 { 401 return fmt.Errorf("proto: SizeMessage: wiretype end group for non-group") 402 } 403 if fieldNum <= 0 { 404 return fmt.Errorf("proto: SizeMessage: illegal tag %d (wire type %d)", fieldNum, wire) 405 } 406 switch fieldNum { 407 case 1: 408 if wireType != 0 { 409 return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) 410 } 411 var v int64 412 for shift := uint(0); ; shift += 7 { 413 if shift >= 64 { 414 return ErrIntOverflowProtosize 415 } 416 if iNdEx >= l { 417 return io.ErrUnexpectedEOF 418 } 419 b := dAtA[iNdEx] 420 iNdEx++ 421 v |= int64(b&0x7F) << shift 422 if b < 0x80 { 423 break 424 } 425 } 426 m.Size = &v 427 case 2: 428 if wireType != 0 { 429 return fmt.Errorf("proto: wrong wireType = %d for field ProtoSize_", wireType) 430 } 431 var v int64 432 for shift := uint(0); ; shift += 7 { 433 if shift >= 64 { 434 return ErrIntOverflowProtosize 435 } 436 if iNdEx >= l { 437 return io.ErrUnexpectedEOF 438 } 439 b := dAtA[iNdEx] 440 iNdEx++ 441 v |= int64(b&0x7F) << shift 442 if b < 0x80 { 443 break 444 } 445 } 446 m.ProtoSize_ = &v 447 case 3: 448 if wireType != 0 { 449 return fmt.Errorf("proto: wrong wireType = %d for field Equal_", wireType) 450 } 451 var v int 452 for shift := uint(0); ; shift += 7 { 453 if shift >= 64 { 454 return ErrIntOverflowProtosize 455 } 456 if iNdEx >= l { 457 return io.ErrUnexpectedEOF 458 } 459 b := dAtA[iNdEx] 460 iNdEx++ 461 v |= int(b&0x7F) << shift 462 if b < 0x80 { 463 break 464 } 465 } 466 b := bool(v != 0) 467 m.Equal_ = &b 468 case 4: 469 if wireType != 2 { 470 return fmt.Errorf("proto: wrong wireType = %d for field String_", wireType) 471 } 472 var stringLen uint64 473 for shift := uint(0); ; shift += 7 { 474 if shift >= 64 { 475 return ErrIntOverflowProtosize 476 } 477 if iNdEx >= l { 478 return io.ErrUnexpectedEOF 479 } 480 b := dAtA[iNdEx] 481 iNdEx++ 482 stringLen |= uint64(b&0x7F) << shift 483 if b < 0x80 { 484 break 485 } 486 } 487 intStringLen := int(stringLen) 488 if intStringLen < 0 { 489 return ErrInvalidLengthProtosize 490 } 491 postIndex := iNdEx + intStringLen 492 if postIndex < 0 { 493 return ErrInvalidLengthProtosize 494 } 495 if postIndex > l { 496 return io.ErrUnexpectedEOF 497 } 498 s := string(dAtA[iNdEx:postIndex]) 499 m.String_ = &s 500 iNdEx = postIndex 501 default: 502 iNdEx = preIndex 503 skippy, err := skipProtosize(dAtA[iNdEx:]) 504 if err != nil { 505 return err 506 } 507 if (skippy < 0) || (iNdEx+skippy) < 0 { 508 return ErrInvalidLengthProtosize 509 } 510 if (iNdEx + skippy) > l { 511 return io.ErrUnexpectedEOF 512 } 513 m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) 514 iNdEx += skippy 515 } 516 } 517 518 if iNdEx > l { 519 return io.ErrUnexpectedEOF 520 } 521 return nil 522 } 523 func skipProtosize(dAtA []byte) (n int, err error) { 524 l := len(dAtA) 525 iNdEx := 0 526 depth := 0 527 for iNdEx < l { 528 var wire uint64 529 for shift := uint(0); ; shift += 7 { 530 if shift >= 64 { 531 return 0, ErrIntOverflowProtosize 532 } 533 if iNdEx >= l { 534 return 0, io.ErrUnexpectedEOF 535 } 536 b := dAtA[iNdEx] 537 iNdEx++ 538 wire |= (uint64(b) & 0x7F) << shift 539 if b < 0x80 { 540 break 541 } 542 } 543 wireType := int(wire & 0x7) 544 switch wireType { 545 case 0: 546 for shift := uint(0); ; shift += 7 { 547 if shift >= 64 { 548 return 0, ErrIntOverflowProtosize 549 } 550 if iNdEx >= l { 551 return 0, io.ErrUnexpectedEOF 552 } 553 iNdEx++ 554 if dAtA[iNdEx-1] < 0x80 { 555 break 556 } 557 } 558 case 1: 559 iNdEx += 8 560 case 2: 561 var length int 562 for shift := uint(0); ; shift += 7 { 563 if shift >= 64 { 564 return 0, ErrIntOverflowProtosize 565 } 566 if iNdEx >= l { 567 return 0, io.ErrUnexpectedEOF 568 } 569 b := dAtA[iNdEx] 570 iNdEx++ 571 length |= (int(b) & 0x7F) << shift 572 if b < 0x80 { 573 break 574 } 575 } 576 if length < 0 { 577 return 0, ErrInvalidLengthProtosize 578 } 579 iNdEx += length 580 case 3: 581 depth++ 582 case 4: 583 if depth == 0 { 584 return 0, ErrUnexpectedEndOfGroupProtosize 585 } 586 depth-- 587 case 5: 588 iNdEx += 4 589 default: 590 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 591 } 592 if iNdEx < 0 { 593 return 0, ErrInvalidLengthProtosize 594 } 595 if depth == 0 { 596 return iNdEx, nil 597 } 598 } 599 return 0, io.ErrUnexpectedEOF 600 } 601 602 var ( 603 ErrInvalidLengthProtosize = fmt.Errorf("proto: negative length found during unmarshaling") 604 ErrIntOverflowProtosize = fmt.Errorf("proto: integer overflow") 605 ErrUnexpectedEndOfGroupProtosize = fmt.Errorf("proto: unexpected end of group") 606 )