github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/kitex_gen/example/k-example.go (about) 1 // Code generated by Kitex v0.0.3. DO NOT EDIT. 2 3 package example 4 5 import ( 6 "bytes" 7 "fmt" 8 "reflect" 9 "strings" 10 11 "github.com/apache/thrift/lib/go/thrift" 12 13 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" 14 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/deep" 15 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/ref" 16 "github.com/cloudwego/kitex/pkg/protocol/bthrift" 17 ) 18 19 // unused protection 20 var ( 21 _ = fmt.Formatter(nil) 22 _ = (*bytes.Buffer)(nil) 23 _ = (*strings.Builder)(nil) 24 _ = reflect.Type(nil) 25 _ = thrift.TProtocol(nil) 26 _ = bthrift.BinaryWriter(nil) 27 _ = base.KitexUnusedProtection 28 _ = deep.KitexUnusedProtection 29 _ = ref.KitexUnusedProtection 30 ) 31 32 func (p *ExampleReq) FastRead(buf []byte) (int, error) { 33 var err error 34 var offset int 35 var l int 36 var fieldTypeId thrift.TType 37 var fieldId int16 38 var issetBase bool = false 39 _, l, err = bthrift.Binary.ReadStructBegin(buf) 40 offset += l 41 if err != nil { 42 goto ReadStructBeginError 43 } 44 45 for { 46 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 47 offset += l 48 if err != nil { 49 goto ReadFieldBeginError 50 } 51 if fieldTypeId == thrift.STOP { 52 break 53 } 54 switch fieldId { 55 case 1: 56 if fieldTypeId == thrift.STRING { 57 l, err = p.FastReadField1(buf[offset:]) 58 offset += l 59 if err != nil { 60 goto ReadFieldError 61 } 62 } else { 63 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 64 offset += l 65 if err != nil { 66 goto SkipFieldError 67 } 68 } 69 case 3: 70 if fieldTypeId == thrift.I32 { 71 l, err = p.FastReadField3(buf[offset:]) 72 offset += l 73 if err != nil { 74 goto ReadFieldError 75 } 76 } else { 77 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 78 offset += l 79 if err != nil { 80 goto SkipFieldError 81 } 82 } 83 case 255: 84 if fieldTypeId == thrift.STRUCT { 85 l, err = p.FastReadField255(buf[offset:]) 86 offset += l 87 if err != nil { 88 goto ReadFieldError 89 } 90 issetBase = true 91 } else { 92 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 93 offset += l 94 if err != nil { 95 goto SkipFieldError 96 } 97 } 98 case 32767: 99 if fieldTypeId == thrift.DOUBLE { 100 l, err = p.FastReadField32767(buf[offset:]) 101 offset += l 102 if err != nil { 103 goto ReadFieldError 104 } 105 } else { 106 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 107 offset += l 108 if err != nil { 109 goto SkipFieldError 110 } 111 } 112 default: 113 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 114 offset += l 115 if err != nil { 116 goto SkipFieldError 117 } 118 } 119 120 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 121 offset += l 122 if err != nil { 123 goto ReadFieldEndError 124 } 125 } 126 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 127 offset += l 128 if err != nil { 129 goto ReadStructEndError 130 } 131 132 if !issetBase { 133 fieldId = 255 134 goto RequiredFieldNotSetError 135 } 136 return offset, nil 137 ReadStructBeginError: 138 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 139 ReadFieldBeginError: 140 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 141 ReadFieldError: 142 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) 143 SkipFieldError: 144 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 145 ReadFieldEndError: 146 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 147 ReadStructEndError: 148 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 149 RequiredFieldNotSetError: 150 return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) 151 } 152 153 func (p *ExampleReq) FastReadField1(buf []byte) (int, error) { 154 offset := 0 155 156 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 157 return offset, err 158 } else { 159 offset += l 160 p.Msg = &v 161 162 } 163 return offset, nil 164 } 165 166 func (p *ExampleReq) FastReadField3(buf []byte) (int, error) { 167 offset := 0 168 169 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 170 return offset, err 171 } else { 172 offset += l 173 174 p.InnerBase = v 175 176 } 177 return offset, nil 178 } 179 180 func (p *ExampleReq) FastReadField255(buf []byte) (int, error) { 181 offset := 0 182 p.Base = base.NewBase() 183 if l, err := p.Base.FastRead(buf[offset:]); err != nil { 184 return offset, err 185 } else { 186 offset += l 187 } 188 return offset, nil 189 } 190 191 func (p *ExampleReq) FastReadField32767(buf []byte) (int, error) { 192 offset := 0 193 194 if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { 195 return offset, err 196 } else { 197 offset += l 198 199 p.Subfix = v 200 201 } 202 return offset, nil 203 } 204 205 // for compatibility 206 func (p *ExampleReq) FastWrite(buf []byte) int { 207 return 0 208 } 209 210 func (p *ExampleReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 211 offset := 0 212 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleReq") 213 if p != nil { 214 offset += p.fastWriteField3(buf[offset:], binaryWriter) 215 offset += p.fastWriteField32767(buf[offset:], binaryWriter) 216 offset += p.fastWriteField1(buf[offset:], binaryWriter) 217 offset += p.fastWriteField255(buf[offset:], binaryWriter) 218 } 219 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 220 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 221 return offset 222 } 223 224 func (p *ExampleReq) BLength() int { 225 l := 0 226 l += bthrift.Binary.StructBeginLength("ExampleReq") 227 if p != nil { 228 l += p.field1Length() 229 l += p.field3Length() 230 l += p.field255Length() 231 l += p.field32767Length() 232 } 233 l += bthrift.Binary.FieldStopLength() 234 l += bthrift.Binary.StructEndLength() 235 return l 236 } 237 238 func (p *ExampleReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 239 offset := 0 240 if p.IsSetMsg() { 241 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) 242 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) 243 244 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 245 } 246 return offset 247 } 248 249 func (p *ExampleReq) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { 250 offset := 0 251 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.I32, 3) 252 offset += bthrift.Binary.WriteI32(buf[offset:], p.InnerBase) 253 254 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 255 return offset 256 } 257 258 func (p *ExampleReq) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { 259 offset := 0 260 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) 261 offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) 262 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 263 return offset 264 } 265 266 func (p *ExampleReq) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { 267 offset := 0 268 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) 269 offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) 270 271 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 272 return offset 273 } 274 275 func (p *ExampleReq) field1Length() int { 276 l := 0 277 if p.IsSetMsg() { 278 l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) 279 l += bthrift.Binary.StringLengthNocopy(*p.Msg) 280 281 l += bthrift.Binary.FieldEndLength() 282 } 283 return l 284 } 285 286 func (p *ExampleReq) field3Length() int { 287 l := 0 288 l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.I32, 3) 289 l += bthrift.Binary.I32Length(p.InnerBase) 290 291 l += bthrift.Binary.FieldEndLength() 292 return l 293 } 294 295 func (p *ExampleReq) field255Length() int { 296 l := 0 297 l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) 298 l += p.Base.BLength() 299 l += bthrift.Binary.FieldEndLength() 300 return l 301 } 302 303 func (p *ExampleReq) field32767Length() int { 304 l := 0 305 l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) 306 l += bthrift.Binary.DoubleLength(p.Subfix) 307 308 l += bthrift.Binary.FieldEndLength() 309 return l 310 } 311 312 func (p *ExampleToSnakeCase) FastRead(buf []byte) (int, error) { 313 var err error 314 var offset int 315 var l int 316 var fieldTypeId thrift.TType 317 var fieldId int16 318 var issetBase bool = false 319 _, l, err = bthrift.Binary.ReadStructBegin(buf) 320 offset += l 321 if err != nil { 322 goto ReadStructBeginError 323 } 324 325 for { 326 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 327 offset += l 328 if err != nil { 329 goto ReadFieldBeginError 330 } 331 if fieldTypeId == thrift.STOP { 332 break 333 } 334 switch fieldId { 335 case 1: 336 if fieldTypeId == thrift.STRING { 337 l, err = p.FastReadField1(buf[offset:]) 338 offset += l 339 if err != nil { 340 goto ReadFieldError 341 } 342 } else { 343 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 344 offset += l 345 if err != nil { 346 goto SkipFieldError 347 } 348 } 349 case 2: 350 if fieldTypeId == thrift.LIST { 351 l, err = p.FastReadField2(buf[offset:]) 352 offset += l 353 if err != nil { 354 goto ReadFieldError 355 } 356 } else { 357 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 358 offset += l 359 if err != nil { 360 goto SkipFieldError 361 } 362 } 363 case 3: 364 if fieldTypeId == thrift.I32 { 365 l, err = p.FastReadField3(buf[offset:]) 366 offset += l 367 if err != nil { 368 goto ReadFieldError 369 } 370 } else { 371 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 372 offset += l 373 if err != nil { 374 goto SkipFieldError 375 } 376 } 377 case 255: 378 if fieldTypeId == thrift.STRUCT { 379 l, err = p.FastReadField255(buf[offset:]) 380 offset += l 381 if err != nil { 382 goto ReadFieldError 383 } 384 issetBase = true 385 } else { 386 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 387 offset += l 388 if err != nil { 389 goto SkipFieldError 390 } 391 } 392 default: 393 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 394 offset += l 395 if err != nil { 396 goto SkipFieldError 397 } 398 } 399 400 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 401 offset += l 402 if err != nil { 403 goto ReadFieldEndError 404 } 405 } 406 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 407 offset += l 408 if err != nil { 409 goto ReadStructEndError 410 } 411 412 if !issetBase { 413 fieldId = 255 414 goto RequiredFieldNotSetError 415 } 416 return offset, nil 417 ReadStructBeginError: 418 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 419 ReadFieldBeginError: 420 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 421 ReadFieldError: 422 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleToSnakeCase[fieldId]), err) 423 SkipFieldError: 424 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 425 ReadFieldEndError: 426 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 427 ReadStructEndError: 428 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 429 RequiredFieldNotSetError: 430 return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleToSnakeCase[fieldId])) 431 } 432 433 func (p *ExampleToSnakeCase) FastReadField1(buf []byte) (int, error) { 434 offset := 0 435 436 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 437 return offset, err 438 } else { 439 offset += l 440 p.Msg = &v 441 442 } 443 return offset, nil 444 } 445 446 func (p *ExampleToSnakeCase) FastReadField2(buf []byte) (int, error) { 447 offset := 0 448 449 _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) 450 offset += l 451 if err != nil { 452 return offset, err 453 } 454 p.ReqList = make([]string, 0, size) 455 for i := 0; i < size; i++ { 456 var _elem string 457 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 458 return offset, err 459 } else { 460 offset += l 461 462 _elem = v 463 464 } 465 466 p.ReqList = append(p.ReqList, _elem) 467 } 468 if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { 469 return offset, err 470 } else { 471 offset += l 472 } 473 return offset, nil 474 } 475 476 func (p *ExampleToSnakeCase) FastReadField3(buf []byte) (int, error) { 477 offset := 0 478 479 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 480 return offset, err 481 } else { 482 offset += l 483 484 p.InnerBase = v 485 486 } 487 return offset, nil 488 } 489 490 func (p *ExampleToSnakeCase) FastReadField255(buf []byte) (int, error) { 491 offset := 0 492 p.Base = base.NewBase() 493 if l, err := p.Base.FastRead(buf[offset:]); err != nil { 494 return offset, err 495 } else { 496 offset += l 497 } 498 return offset, nil 499 } 500 501 // for compatibility 502 func (p *ExampleToSnakeCase) FastWrite(buf []byte) int { 503 return 0 504 } 505 506 func (p *ExampleToSnakeCase) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 507 offset := 0 508 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase") 509 if p != nil { 510 offset += p.fastWriteField3(buf[offset:], binaryWriter) 511 offset += p.fastWriteField1(buf[offset:], binaryWriter) 512 offset += p.fastWriteField2(buf[offset:], binaryWriter) 513 offset += p.fastWriteField255(buf[offset:], binaryWriter) 514 } 515 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 516 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 517 return offset 518 } 519 520 func (p *ExampleToSnakeCase) BLength() int { 521 l := 0 522 l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase") 523 if p != nil { 524 l += p.field1Length() 525 l += p.field2Length() 526 l += p.field3Length() 527 l += p.field255Length() 528 } 529 l += bthrift.Binary.FieldStopLength() 530 l += bthrift.Binary.StructEndLength() 531 return l 532 } 533 534 func (p *ExampleToSnakeCase) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 535 offset := 0 536 if p.IsSetMsg() { 537 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) 538 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) 539 540 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 541 } 542 return offset 543 } 544 545 func (p *ExampleToSnakeCase) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { 546 offset := 0 547 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req_list", thrift.LIST, 2) 548 offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.ReqList)) 549 for _, v := range p.ReqList { 550 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) 551 552 } 553 offset += bthrift.Binary.WriteListEnd(buf[offset:]) 554 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 555 return offset 556 } 557 558 func (p *ExampleToSnakeCase) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { 559 offset := 0 560 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.I32, 3) 561 offset += bthrift.Binary.WriteI32(buf[offset:], p.InnerBase) 562 563 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 564 return offset 565 } 566 567 func (p *ExampleToSnakeCase) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { 568 offset := 0 569 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) 570 offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) 571 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 572 return offset 573 } 574 575 func (p *ExampleToSnakeCase) field1Length() int { 576 l := 0 577 if p.IsSetMsg() { 578 l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) 579 l += bthrift.Binary.StringLengthNocopy(*p.Msg) 580 581 l += bthrift.Binary.FieldEndLength() 582 } 583 return l 584 } 585 586 func (p *ExampleToSnakeCase) field2Length() int { 587 l := 0 588 l += bthrift.Binary.FieldBeginLength("req_list", thrift.LIST, 2) 589 l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.ReqList)) 590 for _, v := range p.ReqList { 591 l += bthrift.Binary.StringLengthNocopy(v) 592 593 } 594 l += bthrift.Binary.ListEndLength() 595 l += bthrift.Binary.FieldEndLength() 596 return l 597 } 598 599 func (p *ExampleToSnakeCase) field3Length() int { 600 l := 0 601 l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.I32, 3) 602 l += bthrift.Binary.I32Length(p.InnerBase) 603 604 l += bthrift.Binary.FieldEndLength() 605 return l 606 } 607 608 func (p *ExampleToSnakeCase) field255Length() int { 609 l := 0 610 l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) 611 l += p.Base.BLength() 612 l += bthrift.Binary.FieldEndLength() 613 return l 614 } 615 616 func (p *ExampleResp) FastRead(buf []byte) (int, error) { 617 var err error 618 var offset int 619 var l int 620 var fieldTypeId thrift.TType 621 var fieldId int16 622 var issetRequiredField bool = false 623 _, l, err = bthrift.Binary.ReadStructBegin(buf) 624 offset += l 625 if err != nil { 626 goto ReadStructBeginError 627 } 628 629 for { 630 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 631 offset += l 632 if err != nil { 633 goto ReadFieldBeginError 634 } 635 if fieldTypeId == thrift.STOP { 636 break 637 } 638 switch fieldId { 639 case 1: 640 if fieldTypeId == thrift.STRING { 641 l, err = p.FastReadField1(buf[offset:]) 642 offset += l 643 if err != nil { 644 goto ReadFieldError 645 } 646 } else { 647 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 648 offset += l 649 if err != nil { 650 goto SkipFieldError 651 } 652 } 653 case 2: 654 if fieldTypeId == thrift.STRING { 655 l, err = p.FastReadField2(buf[offset:]) 656 offset += l 657 if err != nil { 658 goto ReadFieldError 659 } 660 issetRequiredField = true 661 } else { 662 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 663 offset += l 664 if err != nil { 665 goto SkipFieldError 666 } 667 } 668 case 32767: 669 if fieldTypeId == thrift.STRUCT { 670 l, err = p.FastReadField32767(buf[offset:]) 671 offset += l 672 if err != nil { 673 goto ReadFieldError 674 } 675 } else { 676 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 677 offset += l 678 if err != nil { 679 goto SkipFieldError 680 } 681 } 682 default: 683 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 684 offset += l 685 if err != nil { 686 goto SkipFieldError 687 } 688 } 689 690 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 691 offset += l 692 if err != nil { 693 goto ReadFieldEndError 694 } 695 } 696 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 697 offset += l 698 if err != nil { 699 goto ReadStructEndError 700 } 701 702 if !issetRequiredField { 703 fieldId = 2 704 goto RequiredFieldNotSetError 705 } 706 return offset, nil 707 ReadStructBeginError: 708 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 709 ReadFieldBeginError: 710 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 711 ReadFieldError: 712 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) 713 SkipFieldError: 714 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 715 ReadFieldEndError: 716 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 717 ReadStructEndError: 718 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 719 RequiredFieldNotSetError: 720 return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) 721 } 722 723 func (p *ExampleResp) FastReadField1(buf []byte) (int, error) { 724 offset := 0 725 726 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 727 return offset, err 728 } else { 729 offset += l 730 p.Msg = &v 731 732 } 733 return offset, nil 734 } 735 736 func (p *ExampleResp) FastReadField2(buf []byte) (int, error) { 737 offset := 0 738 739 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 740 return offset, err 741 } else { 742 offset += l 743 744 p.RequiredField = v 745 746 } 747 return offset, nil 748 } 749 750 func (p *ExampleResp) FastReadField32767(buf []byte) (int, error) { 751 offset := 0 752 p.BaseResp = base.NewBaseResp() 753 if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { 754 return offset, err 755 } else { 756 offset += l 757 } 758 return offset, nil 759 } 760 761 // for compatibility 762 func (p *ExampleResp) FastWrite(buf []byte) int { 763 return 0 764 } 765 766 func (p *ExampleResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 767 offset := 0 768 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleResp") 769 if p != nil { 770 offset += p.fastWriteField1(buf[offset:], binaryWriter) 771 offset += p.fastWriteField2(buf[offset:], binaryWriter) 772 offset += p.fastWriteField32767(buf[offset:], binaryWriter) 773 } 774 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 775 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 776 return offset 777 } 778 779 func (p *ExampleResp) BLength() int { 780 l := 0 781 l += bthrift.Binary.StructBeginLength("ExampleResp") 782 if p != nil { 783 l += p.field1Length() 784 l += p.field2Length() 785 l += p.field32767Length() 786 } 787 l += bthrift.Binary.FieldStopLength() 788 l += bthrift.Binary.StructEndLength() 789 return l 790 } 791 792 func (p *ExampleResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 793 offset := 0 794 if p.IsSetMsg() { 795 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) 796 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) 797 798 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 799 } 800 return offset 801 } 802 803 func (p *ExampleResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { 804 offset := 0 805 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required_field", thrift.STRING, 2) 806 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RequiredField) 807 808 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 809 return offset 810 } 811 812 func (p *ExampleResp) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { 813 offset := 0 814 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BaseResp", thrift.STRUCT, 32767) 815 offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) 816 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 817 return offset 818 } 819 820 func (p *ExampleResp) field1Length() int { 821 l := 0 822 if p.IsSetMsg() { 823 l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) 824 l += bthrift.Binary.StringLengthNocopy(*p.Msg) 825 826 l += bthrift.Binary.FieldEndLength() 827 } 828 return l 829 } 830 831 func (p *ExampleResp) field2Length() int { 832 l := 0 833 l += bthrift.Binary.FieldBeginLength("required_field", thrift.STRING, 2) 834 l += bthrift.Binary.StringLengthNocopy(p.RequiredField) 835 836 l += bthrift.Binary.FieldEndLength() 837 return l 838 } 839 840 func (p *ExampleResp) field32767Length() int { 841 l := 0 842 l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 32767) 843 l += p.BaseResp.BLength() 844 l += bthrift.Binary.FieldEndLength() 845 return l 846 } 847 848 func (p *A) FastRead(buf []byte) (int, error) { 849 var err error 850 var offset int 851 var l int 852 var fieldTypeId thrift.TType 853 var fieldId int16 854 _, l, err = bthrift.Binary.ReadStructBegin(buf) 855 offset += l 856 if err != nil { 857 goto ReadStructBeginError 858 } 859 860 for { 861 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 862 offset += l 863 if err != nil { 864 goto ReadFieldBeginError 865 } 866 if fieldTypeId == thrift.STOP { 867 break 868 } 869 switch fieldId { 870 case 1: 871 if fieldTypeId == thrift.STRING { 872 l, err = p.FastReadField1(buf[offset:]) 873 offset += l 874 if err != nil { 875 goto ReadFieldError 876 } 877 } else { 878 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 879 offset += l 880 if err != nil { 881 goto SkipFieldError 882 } 883 } 884 case 2: 885 if fieldTypeId == thrift.I32 { 886 l, err = p.FastReadField2(buf[offset:]) 887 offset += l 888 if err != nil { 889 goto ReadFieldError 890 } 891 } else { 892 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 893 offset += l 894 if err != nil { 895 goto SkipFieldError 896 } 897 } 898 default: 899 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 900 offset += l 901 if err != nil { 902 goto SkipFieldError 903 } 904 } 905 906 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 907 offset += l 908 if err != nil { 909 goto ReadFieldEndError 910 } 911 } 912 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 913 offset += l 914 if err != nil { 915 goto ReadStructEndError 916 } 917 918 return offset, nil 919 ReadStructBeginError: 920 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 921 ReadFieldBeginError: 922 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 923 ReadFieldError: 924 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_A[fieldId]), err) 925 SkipFieldError: 926 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 927 ReadFieldEndError: 928 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 929 ReadStructEndError: 930 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 931 } 932 933 func (p *A) FastReadField1(buf []byte) (int, error) { 934 offset := 0 935 936 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 937 return offset, err 938 } else { 939 offset += l 940 941 p.Self = v 942 943 } 944 return offset, nil 945 } 946 947 func (p *A) FastReadField2(buf []byte) (int, error) { 948 offset := 0 949 950 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 951 return offset, err 952 } else { 953 offset += l 954 955 p.Foo = FOO(v) 956 957 } 958 return offset, nil 959 } 960 961 // for compatibility 962 func (p *A) FastWrite(buf []byte) int { 963 return 0 964 } 965 966 func (p *A) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 967 offset := 0 968 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "A") 969 if p != nil { 970 offset += p.fastWriteField1(buf[offset:], binaryWriter) 971 offset += p.fastWriteField2(buf[offset:], binaryWriter) 972 } 973 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 974 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 975 return offset 976 } 977 978 func (p *A) BLength() int { 979 l := 0 980 l += bthrift.Binary.StructBeginLength("A") 981 if p != nil { 982 l += p.field1Length() 983 l += p.field2Length() 984 } 985 l += bthrift.Binary.FieldStopLength() 986 l += bthrift.Binary.StructEndLength() 987 return l 988 } 989 990 func (p *A) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 991 offset := 0 992 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "self", thrift.STRING, 1) 993 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Self) 994 995 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 996 return offset 997 } 998 999 func (p *A) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1000 offset := 0 1001 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "foo", thrift.I32, 2) 1002 offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Foo)) 1003 1004 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1005 return offset 1006 } 1007 1008 func (p *A) field1Length() int { 1009 l := 0 1010 l += bthrift.Binary.FieldBeginLength("self", thrift.STRING, 1) 1011 l += bthrift.Binary.StringLengthNocopy(p.Self) 1012 1013 l += bthrift.Binary.FieldEndLength() 1014 return l 1015 } 1016 1017 func (p *A) field2Length() int { 1018 l := 0 1019 l += bthrift.Binary.FieldBeginLength("foo", thrift.I32, 2) 1020 l += bthrift.Binary.I32Length(int32(p.Foo)) 1021 1022 l += bthrift.Binary.FieldEndLength() 1023 return l 1024 } 1025 1026 func (p *ExampleDefaultValue) FastRead(buf []byte) (int, error) { 1027 var err error 1028 var offset int 1029 var l int 1030 var fieldTypeId thrift.TType 1031 var fieldId int16 1032 _, l, err = bthrift.Binary.ReadStructBegin(buf) 1033 offset += l 1034 if err != nil { 1035 goto ReadStructBeginError 1036 } 1037 1038 for { 1039 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 1040 offset += l 1041 if err != nil { 1042 goto ReadFieldBeginError 1043 } 1044 if fieldTypeId == thrift.STOP { 1045 break 1046 } 1047 switch fieldId { 1048 case 1: 1049 if fieldTypeId == thrift.STRING { 1050 l, err = p.FastReadField1(buf[offset:]) 1051 offset += l 1052 if err != nil { 1053 goto ReadFieldError 1054 } 1055 } else { 1056 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1057 offset += l 1058 if err != nil { 1059 goto SkipFieldError 1060 } 1061 } 1062 case 2: 1063 if fieldTypeId == thrift.I32 { 1064 l, err = p.FastReadField2(buf[offset:]) 1065 offset += l 1066 if err != nil { 1067 goto ReadFieldError 1068 } 1069 } else { 1070 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1071 offset += l 1072 if err != nil { 1073 goto SkipFieldError 1074 } 1075 } 1076 case 3: 1077 if fieldTypeId == thrift.DOUBLE { 1078 l, err = p.FastReadField3(buf[offset:]) 1079 offset += l 1080 if err != nil { 1081 goto ReadFieldError 1082 } 1083 } else { 1084 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1085 offset += l 1086 if err != nil { 1087 goto SkipFieldError 1088 } 1089 } 1090 case 4: 1091 if fieldTypeId == thrift.BOOL { 1092 l, err = p.FastReadField4(buf[offset:]) 1093 offset += l 1094 if err != nil { 1095 goto ReadFieldError 1096 } 1097 } else { 1098 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1099 offset += l 1100 if err != nil { 1101 goto SkipFieldError 1102 } 1103 } 1104 case 5: 1105 if fieldTypeId == thrift.LIST { 1106 l, err = p.FastReadField5(buf[offset:]) 1107 offset += l 1108 if err != nil { 1109 goto ReadFieldError 1110 } 1111 } else { 1112 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1113 offset += l 1114 if err != nil { 1115 goto SkipFieldError 1116 } 1117 } 1118 case 6: 1119 if fieldTypeId == thrift.MAP { 1120 l, err = p.FastReadField6(buf[offset:]) 1121 offset += l 1122 if err != nil { 1123 goto ReadFieldError 1124 } 1125 } else { 1126 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1127 offset += l 1128 if err != nil { 1129 goto SkipFieldError 1130 } 1131 } 1132 case 7: 1133 if fieldTypeId == thrift.SET { 1134 l, err = p.FastReadField7(buf[offset:]) 1135 offset += l 1136 if err != nil { 1137 goto ReadFieldError 1138 } 1139 } else { 1140 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1141 offset += l 1142 if err != nil { 1143 goto SkipFieldError 1144 } 1145 } 1146 case 8: 1147 if fieldTypeId == thrift.STRING { 1148 l, err = p.FastReadField8(buf[offset:]) 1149 offset += l 1150 if err != nil { 1151 goto ReadFieldError 1152 } 1153 } else { 1154 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1155 offset += l 1156 if err != nil { 1157 goto SkipFieldError 1158 } 1159 } 1160 case 9: 1161 if fieldTypeId == thrift.I32 { 1162 l, err = p.FastReadField9(buf[offset:]) 1163 offset += l 1164 if err != nil { 1165 goto ReadFieldError 1166 } 1167 } else { 1168 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1169 offset += l 1170 if err != nil { 1171 goto SkipFieldError 1172 } 1173 } 1174 default: 1175 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1176 offset += l 1177 if err != nil { 1178 goto SkipFieldError 1179 } 1180 } 1181 1182 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 1183 offset += l 1184 if err != nil { 1185 goto ReadFieldEndError 1186 } 1187 } 1188 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 1189 offset += l 1190 if err != nil { 1191 goto ReadStructEndError 1192 } 1193 1194 return offset, nil 1195 ReadStructBeginError: 1196 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 1197 ReadFieldBeginError: 1198 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 1199 ReadFieldError: 1200 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDefaultValue[fieldId]), err) 1201 SkipFieldError: 1202 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 1203 ReadFieldEndError: 1204 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 1205 ReadStructEndError: 1206 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1207 } 1208 1209 func (p *ExampleDefaultValue) FastReadField1(buf []byte) (int, error) { 1210 offset := 0 1211 1212 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1213 return offset, err 1214 } else { 1215 offset += l 1216 1217 p.String_ = v 1218 1219 } 1220 return offset, nil 1221 } 1222 1223 func (p *ExampleDefaultValue) FastReadField2(buf []byte) (int, error) { 1224 offset := 0 1225 1226 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 1227 return offset, err 1228 } else { 1229 offset += l 1230 1231 p.Int = v 1232 1233 } 1234 return offset, nil 1235 } 1236 1237 func (p *ExampleDefaultValue) FastReadField3(buf []byte) (int, error) { 1238 offset := 0 1239 1240 if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { 1241 return offset, err 1242 } else { 1243 offset += l 1244 1245 p.Double = v 1246 1247 } 1248 return offset, nil 1249 } 1250 1251 func (p *ExampleDefaultValue) FastReadField4(buf []byte) (int, error) { 1252 offset := 0 1253 1254 if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { 1255 return offset, err 1256 } else { 1257 offset += l 1258 1259 p.Bool = v 1260 1261 } 1262 return offset, nil 1263 } 1264 1265 func (p *ExampleDefaultValue) FastReadField5(buf []byte) (int, error) { 1266 offset := 0 1267 1268 _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) 1269 offset += l 1270 if err != nil { 1271 return offset, err 1272 } 1273 p.List = make([]string, 0, size) 1274 for i := 0; i < size; i++ { 1275 var _elem string 1276 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1277 return offset, err 1278 } else { 1279 offset += l 1280 1281 _elem = v 1282 1283 } 1284 1285 p.List = append(p.List, _elem) 1286 } 1287 if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { 1288 return offset, err 1289 } else { 1290 offset += l 1291 } 1292 return offset, nil 1293 } 1294 1295 func (p *ExampleDefaultValue) FastReadField6(buf []byte) (int, error) { 1296 offset := 0 1297 1298 _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) 1299 offset += l 1300 if err != nil { 1301 return offset, err 1302 } 1303 p.Map = make(map[string]string, size) 1304 for i := 0; i < size; i++ { 1305 var _key string 1306 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1307 return offset, err 1308 } else { 1309 offset += l 1310 1311 _key = v 1312 1313 } 1314 1315 var _val string 1316 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1317 return offset, err 1318 } else { 1319 offset += l 1320 1321 _val = v 1322 1323 } 1324 1325 p.Map[_key] = _val 1326 } 1327 if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { 1328 return offset, err 1329 } else { 1330 offset += l 1331 } 1332 return offset, nil 1333 } 1334 1335 func (p *ExampleDefaultValue) FastReadField7(buf []byte) (int, error) { 1336 offset := 0 1337 1338 _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) 1339 offset += l 1340 if err != nil { 1341 return offset, err 1342 } 1343 p.Set = make([]string, 0, size) 1344 for i := 0; i < size; i++ { 1345 var _elem string 1346 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1347 return offset, err 1348 } else { 1349 offset += l 1350 1351 _elem = v 1352 1353 } 1354 1355 p.Set = append(p.Set, _elem) 1356 } 1357 if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { 1358 return offset, err 1359 } else { 1360 offset += l 1361 } 1362 return offset, nil 1363 } 1364 1365 func (p *ExampleDefaultValue) FastReadField8(buf []byte) (int, error) { 1366 offset := 0 1367 1368 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1369 return offset, err 1370 } else { 1371 offset += l 1372 1373 p.ConstString = v 1374 1375 } 1376 return offset, nil 1377 } 1378 1379 func (p *ExampleDefaultValue) FastReadField9(buf []byte) (int, error) { 1380 offset := 0 1381 1382 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 1383 return offset, err 1384 } else { 1385 offset += l 1386 1387 p.Enum = FOO(v) 1388 1389 } 1390 return offset, nil 1391 } 1392 1393 // for compatibility 1394 func (p *ExampleDefaultValue) FastWrite(buf []byte) int { 1395 return 0 1396 } 1397 1398 func (p *ExampleDefaultValue) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1399 offset := 0 1400 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue") 1401 if p != nil { 1402 offset += p.fastWriteField2(buf[offset:], binaryWriter) 1403 offset += p.fastWriteField3(buf[offset:], binaryWriter) 1404 offset += p.fastWriteField4(buf[offset:], binaryWriter) 1405 offset += p.fastWriteField1(buf[offset:], binaryWriter) 1406 offset += p.fastWriteField5(buf[offset:], binaryWriter) 1407 offset += p.fastWriteField6(buf[offset:], binaryWriter) 1408 offset += p.fastWriteField7(buf[offset:], binaryWriter) 1409 offset += p.fastWriteField8(buf[offset:], binaryWriter) 1410 offset += p.fastWriteField9(buf[offset:], binaryWriter) 1411 } 1412 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 1413 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 1414 return offset 1415 } 1416 1417 func (p *ExampleDefaultValue) BLength() int { 1418 l := 0 1419 l += bthrift.Binary.StructBeginLength("ExampleDefaultValue") 1420 if p != nil { 1421 l += p.field1Length() 1422 l += p.field2Length() 1423 l += p.field3Length() 1424 l += p.field4Length() 1425 l += p.field5Length() 1426 l += p.field6Length() 1427 l += p.field7Length() 1428 l += p.field8Length() 1429 l += p.field9Length() 1430 } 1431 l += bthrift.Binary.FieldStopLength() 1432 l += bthrift.Binary.StructEndLength() 1433 return l 1434 } 1435 1436 func (p *ExampleDefaultValue) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1437 offset := 0 1438 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 1) 1439 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) 1440 1441 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1442 return offset 1443 } 1444 1445 func (p *ExampleDefaultValue) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1446 offset := 0 1447 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int", thrift.I32, 2) 1448 offset += bthrift.Binary.WriteI32(buf[offset:], p.Int) 1449 1450 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1451 return offset 1452 } 1453 1454 func (p *ExampleDefaultValue) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1455 offset := 0 1456 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 3) 1457 offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) 1458 1459 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1460 return offset 1461 } 1462 1463 func (p *ExampleDefaultValue) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1464 offset := 0 1465 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 4) 1466 offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) 1467 1468 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1469 return offset 1470 } 1471 1472 func (p *ExampleDefaultValue) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1473 offset := 0 1474 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "List", thrift.LIST, 5) 1475 offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.List)) 1476 for _, v := range p.List { 1477 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) 1478 1479 } 1480 offset += bthrift.Binary.WriteListEnd(buf[offset:]) 1481 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1482 return offset 1483 } 1484 1485 func (p *ExampleDefaultValue) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1486 offset := 0 1487 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Map", thrift.MAP, 6) 1488 offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Map)) 1489 for k, v := range p.Map { 1490 1491 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) 1492 1493 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) 1494 1495 } 1496 offset += bthrift.Binary.WriteMapEnd(buf[offset:]) 1497 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1498 return offset 1499 } 1500 1501 func (p *ExampleDefaultValue) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1502 offset := 0 1503 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Set", thrift.SET, 7) 1504 offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.STRING, len(p.Set)) 1505 1506 for i := 0; i < len(p.Set); i++ { 1507 for j := i + 1; j < len(p.Set); j++ { 1508 if func(tgt, src string) bool { 1509 if strings.Compare(tgt, src) != 0 { 1510 return false 1511 } 1512 return true 1513 }(p.Set[i], p.Set[j]) { 1514 panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Set[i])) 1515 } 1516 } 1517 } 1518 for _, v := range p.Set { 1519 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) 1520 1521 } 1522 offset += bthrift.Binary.WriteSetEnd(buf[offset:]) 1523 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1524 return offset 1525 } 1526 1527 func (p *ExampleDefaultValue) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1528 offset := 0 1529 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ConstString", thrift.STRING, 8) 1530 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.ConstString) 1531 1532 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1533 return offset 1534 } 1535 1536 func (p *ExampleDefaultValue) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1537 offset := 0 1538 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Enum", thrift.I32, 9) 1539 offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Enum)) 1540 1541 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1542 return offset 1543 } 1544 1545 func (p *ExampleDefaultValue) field1Length() int { 1546 l := 0 1547 l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 1) 1548 l += bthrift.Binary.StringLengthNocopy(p.String_) 1549 1550 l += bthrift.Binary.FieldEndLength() 1551 return l 1552 } 1553 1554 func (p *ExampleDefaultValue) field2Length() int { 1555 l := 0 1556 l += bthrift.Binary.FieldBeginLength("Int", thrift.I32, 2) 1557 l += bthrift.Binary.I32Length(p.Int) 1558 1559 l += bthrift.Binary.FieldEndLength() 1560 return l 1561 } 1562 1563 func (p *ExampleDefaultValue) field3Length() int { 1564 l := 0 1565 l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 3) 1566 l += bthrift.Binary.DoubleLength(p.Double) 1567 1568 l += bthrift.Binary.FieldEndLength() 1569 return l 1570 } 1571 1572 func (p *ExampleDefaultValue) field4Length() int { 1573 l := 0 1574 l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 4) 1575 l += bthrift.Binary.BoolLength(p.Bool) 1576 1577 l += bthrift.Binary.FieldEndLength() 1578 return l 1579 } 1580 1581 func (p *ExampleDefaultValue) field5Length() int { 1582 l := 0 1583 l += bthrift.Binary.FieldBeginLength("List", thrift.LIST, 5) 1584 l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.List)) 1585 for _, v := range p.List { 1586 l += bthrift.Binary.StringLengthNocopy(v) 1587 1588 } 1589 l += bthrift.Binary.ListEndLength() 1590 l += bthrift.Binary.FieldEndLength() 1591 return l 1592 } 1593 1594 func (p *ExampleDefaultValue) field6Length() int { 1595 l := 0 1596 l += bthrift.Binary.FieldBeginLength("Map", thrift.MAP, 6) 1597 l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Map)) 1598 for k, v := range p.Map { 1599 1600 l += bthrift.Binary.StringLengthNocopy(k) 1601 1602 l += bthrift.Binary.StringLengthNocopy(v) 1603 1604 } 1605 l += bthrift.Binary.MapEndLength() 1606 l += bthrift.Binary.FieldEndLength() 1607 return l 1608 } 1609 1610 func (p *ExampleDefaultValue) field7Length() int { 1611 l := 0 1612 l += bthrift.Binary.FieldBeginLength("Set", thrift.SET, 7) 1613 l += bthrift.Binary.SetBeginLength(thrift.STRING, len(p.Set)) 1614 1615 for i := 0; i < len(p.Set); i++ { 1616 for j := i + 1; j < len(p.Set); j++ { 1617 if func(tgt, src string) bool { 1618 if strings.Compare(tgt, src) != 0 { 1619 return false 1620 } 1621 return true 1622 }(p.Set[i], p.Set[j]) { 1623 panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Set[i])) 1624 } 1625 } 1626 } 1627 for _, v := range p.Set { 1628 l += bthrift.Binary.StringLengthNocopy(v) 1629 1630 } 1631 l += bthrift.Binary.SetEndLength() 1632 l += bthrift.Binary.FieldEndLength() 1633 return l 1634 } 1635 1636 func (p *ExampleDefaultValue) field8Length() int { 1637 l := 0 1638 l += bthrift.Binary.FieldBeginLength("ConstString", thrift.STRING, 8) 1639 l += bthrift.Binary.StringLengthNocopy(p.ConstString) 1640 1641 l += bthrift.Binary.FieldEndLength() 1642 return l 1643 } 1644 1645 func (p *ExampleDefaultValue) field9Length() int { 1646 l := 0 1647 l += bthrift.Binary.FieldBeginLength("Enum", thrift.I32, 9) 1648 l += bthrift.Binary.I32Length(int32(p.Enum)) 1649 1650 l += bthrift.Binary.FieldEndLength() 1651 return l 1652 } 1653 1654 func (p *DeepRef) FastRead(buf []byte) (int, error) { 1655 var err error 1656 var offset int 1657 var l int 1658 var fieldTypeId thrift.TType 1659 var fieldId int16 1660 _, l, err = bthrift.Binary.ReadStructBegin(buf) 1661 offset += l 1662 if err != nil { 1663 goto ReadStructBeginError 1664 } 1665 1666 for { 1667 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 1668 offset += l 1669 if err != nil { 1670 goto ReadFieldBeginError 1671 } 1672 if fieldTypeId == thrift.STOP { 1673 break 1674 } 1675 switch fieldId { 1676 case 1: 1677 if fieldTypeId == thrift.STRUCT { 1678 l, err = p.FastReadField1(buf[offset:]) 1679 offset += l 1680 if err != nil { 1681 goto ReadFieldError 1682 } 1683 } else { 1684 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1685 offset += l 1686 if err != nil { 1687 goto SkipFieldError 1688 } 1689 } 1690 default: 1691 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1692 offset += l 1693 if err != nil { 1694 goto SkipFieldError 1695 } 1696 } 1697 1698 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 1699 offset += l 1700 if err != nil { 1701 goto ReadFieldEndError 1702 } 1703 } 1704 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 1705 offset += l 1706 if err != nil { 1707 goto ReadStructEndError 1708 } 1709 1710 return offset, nil 1711 ReadStructBeginError: 1712 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 1713 ReadFieldBeginError: 1714 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 1715 ReadFieldError: 1716 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DeepRef[fieldId]), err) 1717 SkipFieldError: 1718 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 1719 ReadFieldEndError: 1720 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 1721 ReadStructEndError: 1722 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1723 } 1724 1725 func (p *DeepRef) FastReadField1(buf []byte) (int, error) { 1726 offset := 0 1727 p.DeepRef = deep.NewTestStruct() 1728 if l, err := p.DeepRef.FastRead(buf[offset:]); err != nil { 1729 return offset, err 1730 } else { 1731 offset += l 1732 } 1733 return offset, nil 1734 } 1735 1736 // for compatibility 1737 func (p *DeepRef) FastWrite(buf []byte) int { 1738 return 0 1739 } 1740 1741 func (p *DeepRef) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1742 offset := 0 1743 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeepRef") 1744 if p != nil { 1745 offset += p.fastWriteField1(buf[offset:], binaryWriter) 1746 } 1747 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 1748 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 1749 return offset 1750 } 1751 1752 func (p *DeepRef) BLength() int { 1753 l := 0 1754 l += bthrift.Binary.StructBeginLength("DeepRef") 1755 if p != nil { 1756 l += p.field1Length() 1757 } 1758 l += bthrift.Binary.FieldStopLength() 1759 l += bthrift.Binary.StructEndLength() 1760 return l 1761 } 1762 1763 func (p *DeepRef) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1764 offset := 0 1765 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DeepRef", thrift.STRUCT, 1) 1766 offset += p.DeepRef.FastWriteNocopy(buf[offset:], binaryWriter) 1767 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1768 return offset 1769 } 1770 1771 func (p *DeepRef) field1Length() int { 1772 l := 0 1773 l += bthrift.Binary.FieldBeginLength("DeepRef", thrift.STRUCT, 1) 1774 l += p.DeepRef.BLength() 1775 l += bthrift.Binary.FieldEndLength() 1776 return l 1777 } 1778 1779 func (p *Exception) FastRead(buf []byte) (int, error) { 1780 var err error 1781 var offset int 1782 var l int 1783 var fieldTypeId thrift.TType 1784 var fieldId int16 1785 _, l, err = bthrift.Binary.ReadStructBegin(buf) 1786 offset += l 1787 if err != nil { 1788 goto ReadStructBeginError 1789 } 1790 1791 for { 1792 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 1793 offset += l 1794 if err != nil { 1795 goto ReadFieldBeginError 1796 } 1797 if fieldTypeId == thrift.STOP { 1798 break 1799 } 1800 switch fieldId { 1801 case 1: 1802 if fieldTypeId == thrift.I32 { 1803 l, err = p.FastReadField1(buf[offset:]) 1804 offset += l 1805 if err != nil { 1806 goto ReadFieldError 1807 } 1808 } else { 1809 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1810 offset += l 1811 if err != nil { 1812 goto SkipFieldError 1813 } 1814 } 1815 case 255: 1816 if fieldTypeId == thrift.STRING { 1817 l, err = p.FastReadField255(buf[offset:]) 1818 offset += l 1819 if err != nil { 1820 goto ReadFieldError 1821 } 1822 } else { 1823 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1824 offset += l 1825 if err != nil { 1826 goto SkipFieldError 1827 } 1828 } 1829 default: 1830 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1831 offset += l 1832 if err != nil { 1833 goto SkipFieldError 1834 } 1835 } 1836 1837 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 1838 offset += l 1839 if err != nil { 1840 goto ReadFieldEndError 1841 } 1842 } 1843 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 1844 offset += l 1845 if err != nil { 1846 goto ReadStructEndError 1847 } 1848 1849 return offset, nil 1850 ReadStructBeginError: 1851 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 1852 ReadFieldBeginError: 1853 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 1854 ReadFieldError: 1855 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) 1856 SkipFieldError: 1857 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 1858 ReadFieldEndError: 1859 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 1860 ReadStructEndError: 1861 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1862 } 1863 1864 func (p *Exception) FastReadField1(buf []byte) (int, error) { 1865 offset := 0 1866 1867 if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { 1868 return offset, err 1869 } else { 1870 offset += l 1871 1872 p.Code = v 1873 1874 } 1875 return offset, nil 1876 } 1877 1878 func (p *Exception) FastReadField255(buf []byte) (int, error) { 1879 offset := 0 1880 1881 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 1882 return offset, err 1883 } else { 1884 offset += l 1885 1886 p.Msg = v 1887 1888 } 1889 return offset, nil 1890 } 1891 1892 // for compatibility 1893 func (p *Exception) FastWrite(buf []byte) int { 1894 return 0 1895 } 1896 1897 func (p *Exception) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1898 offset := 0 1899 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Exception") 1900 if p != nil { 1901 offset += p.fastWriteField1(buf[offset:], binaryWriter) 1902 offset += p.fastWriteField255(buf[offset:], binaryWriter) 1903 } 1904 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 1905 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 1906 return offset 1907 } 1908 1909 func (p *Exception) BLength() int { 1910 l := 0 1911 l += bthrift.Binary.StructBeginLength("Exception") 1912 if p != nil { 1913 l += p.field1Length() 1914 l += p.field255Length() 1915 } 1916 l += bthrift.Binary.FieldStopLength() 1917 l += bthrift.Binary.StructEndLength() 1918 return l 1919 } 1920 1921 func (p *Exception) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1922 offset := 0 1923 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) 1924 offset += bthrift.Binary.WriteI32(buf[offset:], p.Code) 1925 1926 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1927 return offset 1928 } 1929 1930 func (p *Exception) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { 1931 offset := 0 1932 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 255) 1933 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) 1934 1935 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 1936 return offset 1937 } 1938 1939 func (p *Exception) field1Length() int { 1940 l := 0 1941 l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) 1942 l += bthrift.Binary.I32Length(p.Code) 1943 1944 l += bthrift.Binary.FieldEndLength() 1945 return l 1946 } 1947 1948 func (p *Exception) field255Length() int { 1949 l := 0 1950 l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 255) 1951 l += bthrift.Binary.StringLengthNocopy(p.Msg) 1952 1953 l += bthrift.Binary.FieldEndLength() 1954 return l 1955 } 1956 1957 func (p *ExampleServiceExampleDeepRefArgs) FastRead(buf []byte) (int, error) { 1958 var err error 1959 var offset int 1960 var l int 1961 var fieldTypeId thrift.TType 1962 var fieldId int16 1963 _, l, err = bthrift.Binary.ReadStructBegin(buf) 1964 offset += l 1965 if err != nil { 1966 goto ReadStructBeginError 1967 } 1968 1969 for { 1970 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 1971 offset += l 1972 if err != nil { 1973 goto ReadFieldBeginError 1974 } 1975 if fieldTypeId == thrift.STOP { 1976 break 1977 } 1978 switch fieldId { 1979 case 1: 1980 if fieldTypeId == thrift.STRUCT { 1981 l, err = p.FastReadField1(buf[offset:]) 1982 offset += l 1983 if err != nil { 1984 goto ReadFieldError 1985 } 1986 } else { 1987 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1988 offset += l 1989 if err != nil { 1990 goto SkipFieldError 1991 } 1992 } 1993 default: 1994 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 1995 offset += l 1996 if err != nil { 1997 goto SkipFieldError 1998 } 1999 } 2000 2001 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2002 offset += l 2003 if err != nil { 2004 goto ReadFieldEndError 2005 } 2006 } 2007 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2008 offset += l 2009 if err != nil { 2010 goto ReadStructEndError 2011 } 2012 2013 return offset, nil 2014 ReadStructBeginError: 2015 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2016 ReadFieldBeginError: 2017 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2018 ReadFieldError: 2019 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefArgs[fieldId]), err) 2020 SkipFieldError: 2021 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2022 ReadFieldEndError: 2023 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2024 ReadStructEndError: 2025 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2026 } 2027 2028 func (p *ExampleServiceExampleDeepRefArgs) FastReadField1(buf []byte) (int, error) { 2029 offset := 0 2030 p.Req = NewDeepRef() 2031 if l, err := p.Req.FastRead(buf[offset:]); err != nil { 2032 return offset, err 2033 } else { 2034 offset += l 2035 } 2036 return offset, nil 2037 } 2038 2039 // for compatibility 2040 func (p *ExampleServiceExampleDeepRefArgs) FastWrite(buf []byte) int { 2041 return 0 2042 } 2043 2044 func (p *ExampleServiceExampleDeepRefArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2045 offset := 0 2046 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDeepRef_args") 2047 if p != nil { 2048 offset += p.fastWriteField1(buf[offset:], binaryWriter) 2049 } 2050 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2051 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2052 return offset 2053 } 2054 2055 func (p *ExampleServiceExampleDeepRefArgs) BLength() int { 2056 l := 0 2057 l += bthrift.Binary.StructBeginLength("ExampleDeepRef_args") 2058 if p != nil { 2059 l += p.field1Length() 2060 } 2061 l += bthrift.Binary.FieldStopLength() 2062 l += bthrift.Binary.StructEndLength() 2063 return l 2064 } 2065 2066 func (p *ExampleServiceExampleDeepRefArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2067 offset := 0 2068 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) 2069 offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) 2070 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2071 return offset 2072 } 2073 2074 func (p *ExampleServiceExampleDeepRefArgs) field1Length() int { 2075 l := 0 2076 l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) 2077 l += p.Req.BLength() 2078 l += bthrift.Binary.FieldEndLength() 2079 return l 2080 } 2081 2082 func (p *ExampleServiceExampleDeepRefResult) FastRead(buf []byte) (int, error) { 2083 var err error 2084 var offset int 2085 var l int 2086 var fieldTypeId thrift.TType 2087 var fieldId int16 2088 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2089 offset += l 2090 if err != nil { 2091 goto ReadStructBeginError 2092 } 2093 2094 for { 2095 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2096 offset += l 2097 if err != nil { 2098 goto ReadFieldBeginError 2099 } 2100 if fieldTypeId == thrift.STOP { 2101 break 2102 } 2103 switch fieldId { 2104 case 0: 2105 if fieldTypeId == thrift.STRUCT { 2106 l, err = p.FastReadField0(buf[offset:]) 2107 offset += l 2108 if err != nil { 2109 goto ReadFieldError 2110 } 2111 } else { 2112 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2113 offset += l 2114 if err != nil { 2115 goto SkipFieldError 2116 } 2117 } 2118 default: 2119 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2120 offset += l 2121 if err != nil { 2122 goto SkipFieldError 2123 } 2124 } 2125 2126 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2127 offset += l 2128 if err != nil { 2129 goto ReadFieldEndError 2130 } 2131 } 2132 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2133 offset += l 2134 if err != nil { 2135 goto ReadStructEndError 2136 } 2137 2138 return offset, nil 2139 ReadStructBeginError: 2140 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2141 ReadFieldBeginError: 2142 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2143 ReadFieldError: 2144 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefResult[fieldId]), err) 2145 SkipFieldError: 2146 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2147 ReadFieldEndError: 2148 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2149 ReadStructEndError: 2150 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2151 } 2152 2153 func (p *ExampleServiceExampleDeepRefResult) FastReadField0(buf []byte) (int, error) { 2154 offset := 0 2155 p.Success = NewDeepRef() 2156 if l, err := p.Success.FastRead(buf[offset:]); err != nil { 2157 return offset, err 2158 } else { 2159 offset += l 2160 } 2161 return offset, nil 2162 } 2163 2164 // for compatibility 2165 func (p *ExampleServiceExampleDeepRefResult) FastWrite(buf []byte) int { 2166 return 0 2167 } 2168 2169 func (p *ExampleServiceExampleDeepRefResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2170 offset := 0 2171 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDeepRef_result") 2172 if p != nil { 2173 offset += p.fastWriteField0(buf[offset:], binaryWriter) 2174 } 2175 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2176 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2177 return offset 2178 } 2179 2180 func (p *ExampleServiceExampleDeepRefResult) BLength() int { 2181 l := 0 2182 l += bthrift.Binary.StructBeginLength("ExampleDeepRef_result") 2183 if p != nil { 2184 l += p.field0Length() 2185 } 2186 l += bthrift.Binary.FieldStopLength() 2187 l += bthrift.Binary.StructEndLength() 2188 return l 2189 } 2190 2191 func (p *ExampleServiceExampleDeepRefResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2192 offset := 0 2193 if p.IsSetSuccess() { 2194 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) 2195 offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) 2196 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2197 } 2198 return offset 2199 } 2200 2201 func (p *ExampleServiceExampleDeepRefResult) field0Length() int { 2202 l := 0 2203 if p.IsSetSuccess() { 2204 l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) 2205 l += p.Success.BLength() 2206 l += bthrift.Binary.FieldEndLength() 2207 } 2208 return l 2209 } 2210 2211 func (p *ExampleServiceExampleMethodArgs) FastRead(buf []byte) (int, error) { 2212 var err error 2213 var offset int 2214 var l int 2215 var fieldTypeId thrift.TType 2216 var fieldId int16 2217 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2218 offset += l 2219 if err != nil { 2220 goto ReadStructBeginError 2221 } 2222 2223 for { 2224 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2225 offset += l 2226 if err != nil { 2227 goto ReadFieldBeginError 2228 } 2229 if fieldTypeId == thrift.STOP { 2230 break 2231 } 2232 switch fieldId { 2233 case 1: 2234 if fieldTypeId == thrift.STRUCT { 2235 l, err = p.FastReadField1(buf[offset:]) 2236 offset += l 2237 if err != nil { 2238 goto ReadFieldError 2239 } 2240 } else { 2241 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2242 offset += l 2243 if err != nil { 2244 goto SkipFieldError 2245 } 2246 } 2247 default: 2248 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2249 offset += l 2250 if err != nil { 2251 goto SkipFieldError 2252 } 2253 } 2254 2255 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2256 offset += l 2257 if err != nil { 2258 goto ReadFieldEndError 2259 } 2260 } 2261 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2262 offset += l 2263 if err != nil { 2264 goto ReadStructEndError 2265 } 2266 2267 return offset, nil 2268 ReadStructBeginError: 2269 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2270 ReadFieldBeginError: 2271 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2272 ReadFieldError: 2273 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) 2274 SkipFieldError: 2275 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2276 ReadFieldEndError: 2277 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2278 ReadStructEndError: 2279 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2280 } 2281 2282 func (p *ExampleServiceExampleMethodArgs) FastReadField1(buf []byte) (int, error) { 2283 offset := 0 2284 p.Req = NewExampleReq() 2285 if l, err := p.Req.FastRead(buf[offset:]); err != nil { 2286 return offset, err 2287 } else { 2288 offset += l 2289 } 2290 return offset, nil 2291 } 2292 2293 // for compatibility 2294 func (p *ExampleServiceExampleMethodArgs) FastWrite(buf []byte) int { 2295 return 0 2296 } 2297 2298 func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2299 offset := 0 2300 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_args") 2301 if p != nil { 2302 offset += p.fastWriteField1(buf[offset:], binaryWriter) 2303 } 2304 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2305 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2306 return offset 2307 } 2308 2309 func (p *ExampleServiceExampleMethodArgs) BLength() int { 2310 l := 0 2311 l += bthrift.Binary.StructBeginLength("ExampleMethod_args") 2312 if p != nil { 2313 l += p.field1Length() 2314 } 2315 l += bthrift.Binary.FieldStopLength() 2316 l += bthrift.Binary.StructEndLength() 2317 return l 2318 } 2319 2320 func (p *ExampleServiceExampleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2321 offset := 0 2322 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) 2323 offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) 2324 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2325 return offset 2326 } 2327 2328 func (p *ExampleServiceExampleMethodArgs) field1Length() int { 2329 l := 0 2330 l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) 2331 l += p.Req.BLength() 2332 l += bthrift.Binary.FieldEndLength() 2333 return l 2334 } 2335 2336 func (p *ExampleServiceExampleMethodResult) FastRead(buf []byte) (int, error) { 2337 var err error 2338 var offset int 2339 var l int 2340 var fieldTypeId thrift.TType 2341 var fieldId int16 2342 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2343 offset += l 2344 if err != nil { 2345 goto ReadStructBeginError 2346 } 2347 2348 for { 2349 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2350 offset += l 2351 if err != nil { 2352 goto ReadFieldBeginError 2353 } 2354 if fieldTypeId == thrift.STOP { 2355 break 2356 } 2357 switch fieldId { 2358 case 0: 2359 if fieldTypeId == thrift.STRUCT { 2360 l, err = p.FastReadField0(buf[offset:]) 2361 offset += l 2362 if err != nil { 2363 goto ReadFieldError 2364 } 2365 } else { 2366 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2367 offset += l 2368 if err != nil { 2369 goto SkipFieldError 2370 } 2371 } 2372 case 1: 2373 if fieldTypeId == thrift.STRUCT { 2374 l, err = p.FastReadField1(buf[offset:]) 2375 offset += l 2376 if err != nil { 2377 goto ReadFieldError 2378 } 2379 } else { 2380 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2381 offset += l 2382 if err != nil { 2383 goto SkipFieldError 2384 } 2385 } 2386 default: 2387 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2388 offset += l 2389 if err != nil { 2390 goto SkipFieldError 2391 } 2392 } 2393 2394 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2395 offset += l 2396 if err != nil { 2397 goto ReadFieldEndError 2398 } 2399 } 2400 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2401 offset += l 2402 if err != nil { 2403 goto ReadStructEndError 2404 } 2405 2406 return offset, nil 2407 ReadStructBeginError: 2408 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2409 ReadFieldBeginError: 2410 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2411 ReadFieldError: 2412 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) 2413 SkipFieldError: 2414 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2415 ReadFieldEndError: 2416 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2417 ReadStructEndError: 2418 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2419 } 2420 2421 func (p *ExampleServiceExampleMethodResult) FastReadField0(buf []byte) (int, error) { 2422 offset := 0 2423 p.Success = NewExampleResp() 2424 if l, err := p.Success.FastRead(buf[offset:]); err != nil { 2425 return offset, err 2426 } else { 2427 offset += l 2428 } 2429 return offset, nil 2430 } 2431 2432 func (p *ExampleServiceExampleMethodResult) FastReadField1(buf []byte) (int, error) { 2433 offset := 0 2434 p.Err = NewException() 2435 if l, err := p.Err.FastRead(buf[offset:]); err != nil { 2436 return offset, err 2437 } else { 2438 offset += l 2439 } 2440 return offset, nil 2441 } 2442 2443 // for compatibility 2444 func (p *ExampleServiceExampleMethodResult) FastWrite(buf []byte) int { 2445 return 0 2446 } 2447 2448 func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2449 offset := 0 2450 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_result") 2451 if p != nil { 2452 offset += p.fastWriteField0(buf[offset:], binaryWriter) 2453 offset += p.fastWriteField1(buf[offset:], binaryWriter) 2454 } 2455 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2456 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2457 return offset 2458 } 2459 2460 func (p *ExampleServiceExampleMethodResult) BLength() int { 2461 l := 0 2462 l += bthrift.Binary.StructBeginLength("ExampleMethod_result") 2463 if p != nil { 2464 l += p.field0Length() 2465 l += p.field1Length() 2466 } 2467 l += bthrift.Binary.FieldStopLength() 2468 l += bthrift.Binary.StructEndLength() 2469 return l 2470 } 2471 2472 func (p *ExampleServiceExampleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2473 offset := 0 2474 if p.IsSetSuccess() { 2475 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) 2476 offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) 2477 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2478 } 2479 return offset 2480 } 2481 2482 func (p *ExampleServiceExampleMethodResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2483 offset := 0 2484 if p.IsSetErr() { 2485 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "err", thrift.STRUCT, 1) 2486 offset += p.Err.FastWriteNocopy(buf[offset:], binaryWriter) 2487 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2488 } 2489 return offset 2490 } 2491 2492 func (p *ExampleServiceExampleMethodResult) field0Length() int { 2493 l := 0 2494 if p.IsSetSuccess() { 2495 l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) 2496 l += p.Success.BLength() 2497 l += bthrift.Binary.FieldEndLength() 2498 } 2499 return l 2500 } 2501 2502 func (p *ExampleServiceExampleMethodResult) field1Length() int { 2503 l := 0 2504 if p.IsSetErr() { 2505 l += bthrift.Binary.FieldBeginLength("err", thrift.STRUCT, 1) 2506 l += p.Err.BLength() 2507 l += bthrift.Binary.FieldEndLength() 2508 } 2509 return l 2510 } 2511 2512 func (p *ExampleServiceFooArgs) FastRead(buf []byte) (int, error) { 2513 var err error 2514 var offset int 2515 var l int 2516 var fieldTypeId thrift.TType 2517 var fieldId int16 2518 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2519 offset += l 2520 if err != nil { 2521 goto ReadStructBeginError 2522 } 2523 2524 for { 2525 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2526 offset += l 2527 if err != nil { 2528 goto ReadFieldBeginError 2529 } 2530 if fieldTypeId == thrift.STOP { 2531 break 2532 } 2533 switch fieldId { 2534 case 1: 2535 if fieldTypeId == thrift.STRUCT { 2536 l, err = p.FastReadField1(buf[offset:]) 2537 offset += l 2538 if err != nil { 2539 goto ReadFieldError 2540 } 2541 } else { 2542 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2543 offset += l 2544 if err != nil { 2545 goto SkipFieldError 2546 } 2547 } 2548 default: 2549 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2550 offset += l 2551 if err != nil { 2552 goto SkipFieldError 2553 } 2554 } 2555 2556 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2557 offset += l 2558 if err != nil { 2559 goto ReadFieldEndError 2560 } 2561 } 2562 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2563 offset += l 2564 if err != nil { 2565 goto ReadStructEndError 2566 } 2567 2568 return offset, nil 2569 ReadStructBeginError: 2570 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2571 ReadFieldBeginError: 2572 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2573 ReadFieldError: 2574 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooArgs[fieldId]), err) 2575 SkipFieldError: 2576 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2577 ReadFieldEndError: 2578 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2579 ReadStructEndError: 2580 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2581 } 2582 2583 func (p *ExampleServiceFooArgs) FastReadField1(buf []byte) (int, error) { 2584 offset := 0 2585 p.Req = NewA() 2586 if l, err := p.Req.FastRead(buf[offset:]); err != nil { 2587 return offset, err 2588 } else { 2589 offset += l 2590 } 2591 return offset, nil 2592 } 2593 2594 // for compatibility 2595 func (p *ExampleServiceFooArgs) FastWrite(buf []byte) int { 2596 return 0 2597 } 2598 2599 func (p *ExampleServiceFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2600 offset := 0 2601 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") 2602 if p != nil { 2603 offset += p.fastWriteField1(buf[offset:], binaryWriter) 2604 } 2605 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2606 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2607 return offset 2608 } 2609 2610 func (p *ExampleServiceFooArgs) BLength() int { 2611 l := 0 2612 l += bthrift.Binary.StructBeginLength("Foo_args") 2613 if p != nil { 2614 l += p.field1Length() 2615 } 2616 l += bthrift.Binary.FieldStopLength() 2617 l += bthrift.Binary.StructEndLength() 2618 return l 2619 } 2620 2621 func (p *ExampleServiceFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2622 offset := 0 2623 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) 2624 offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) 2625 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2626 return offset 2627 } 2628 2629 func (p *ExampleServiceFooArgs) field1Length() int { 2630 l := 0 2631 l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) 2632 l += p.Req.BLength() 2633 l += bthrift.Binary.FieldEndLength() 2634 return l 2635 } 2636 2637 func (p *ExampleServiceFooResult) FastRead(buf []byte) (int, error) { 2638 var err error 2639 var offset int 2640 var l int 2641 var fieldTypeId thrift.TType 2642 var fieldId int16 2643 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2644 offset += l 2645 if err != nil { 2646 goto ReadStructBeginError 2647 } 2648 2649 for { 2650 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2651 offset += l 2652 if err != nil { 2653 goto ReadFieldBeginError 2654 } 2655 if fieldTypeId == thrift.STOP { 2656 break 2657 } 2658 switch fieldId { 2659 case 0: 2660 if fieldTypeId == thrift.STRUCT { 2661 l, err = p.FastReadField0(buf[offset:]) 2662 offset += l 2663 if err != nil { 2664 goto ReadFieldError 2665 } 2666 } else { 2667 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2668 offset += l 2669 if err != nil { 2670 goto SkipFieldError 2671 } 2672 } 2673 default: 2674 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2675 offset += l 2676 if err != nil { 2677 goto SkipFieldError 2678 } 2679 } 2680 2681 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2682 offset += l 2683 if err != nil { 2684 goto ReadFieldEndError 2685 } 2686 } 2687 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2688 offset += l 2689 if err != nil { 2690 goto ReadStructEndError 2691 } 2692 2693 return offset, nil 2694 ReadStructBeginError: 2695 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2696 ReadFieldBeginError: 2697 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2698 ReadFieldError: 2699 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooResult[fieldId]), err) 2700 SkipFieldError: 2701 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2702 ReadFieldEndError: 2703 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2704 ReadStructEndError: 2705 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2706 } 2707 2708 func (p *ExampleServiceFooResult) FastReadField0(buf []byte) (int, error) { 2709 offset := 0 2710 p.Success = NewA() 2711 if l, err := p.Success.FastRead(buf[offset:]); err != nil { 2712 return offset, err 2713 } else { 2714 offset += l 2715 } 2716 return offset, nil 2717 } 2718 2719 // for compatibility 2720 func (p *ExampleServiceFooResult) FastWrite(buf []byte) int { 2721 return 0 2722 } 2723 2724 func (p *ExampleServiceFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2725 offset := 0 2726 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") 2727 if p != nil { 2728 offset += p.fastWriteField0(buf[offset:], binaryWriter) 2729 } 2730 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2731 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2732 return offset 2733 } 2734 2735 func (p *ExampleServiceFooResult) BLength() int { 2736 l := 0 2737 l += bthrift.Binary.StructBeginLength("Foo_result") 2738 if p != nil { 2739 l += p.field0Length() 2740 } 2741 l += bthrift.Binary.FieldStopLength() 2742 l += bthrift.Binary.StructEndLength() 2743 return l 2744 } 2745 2746 func (p *ExampleServiceFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2747 offset := 0 2748 if p.IsSetSuccess() { 2749 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) 2750 offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) 2751 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2752 } 2753 return offset 2754 } 2755 2756 func (p *ExampleServiceFooResult) field0Length() int { 2757 l := 0 2758 if p.IsSetSuccess() { 2759 l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) 2760 l += p.Success.BLength() 2761 l += bthrift.Binary.FieldEndLength() 2762 } 2763 return l 2764 } 2765 2766 func (p *ExampleServicePingArgs) FastRead(buf []byte) (int, error) { 2767 var err error 2768 var offset int 2769 var l int 2770 var fieldTypeId thrift.TType 2771 var fieldId int16 2772 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2773 offset += l 2774 if err != nil { 2775 goto ReadStructBeginError 2776 } 2777 2778 for { 2779 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2780 offset += l 2781 if err != nil { 2782 goto ReadFieldBeginError 2783 } 2784 if fieldTypeId == thrift.STOP { 2785 break 2786 } 2787 switch fieldId { 2788 case 1: 2789 if fieldTypeId == thrift.STRING { 2790 l, err = p.FastReadField1(buf[offset:]) 2791 offset += l 2792 if err != nil { 2793 goto ReadFieldError 2794 } 2795 } else { 2796 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2797 offset += l 2798 if err != nil { 2799 goto SkipFieldError 2800 } 2801 } 2802 default: 2803 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2804 offset += l 2805 if err != nil { 2806 goto SkipFieldError 2807 } 2808 } 2809 2810 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2811 offset += l 2812 if err != nil { 2813 goto ReadFieldEndError 2814 } 2815 } 2816 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2817 offset += l 2818 if err != nil { 2819 goto ReadStructEndError 2820 } 2821 2822 return offset, nil 2823 ReadStructBeginError: 2824 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2825 ReadFieldBeginError: 2826 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2827 ReadFieldError: 2828 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingArgs[fieldId]), err) 2829 SkipFieldError: 2830 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2831 ReadFieldEndError: 2832 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2833 ReadStructEndError: 2834 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2835 } 2836 2837 func (p *ExampleServicePingArgs) FastReadField1(buf []byte) (int, error) { 2838 offset := 0 2839 2840 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 2841 return offset, err 2842 } else { 2843 offset += l 2844 2845 p.Msg = v 2846 2847 } 2848 return offset, nil 2849 } 2850 2851 // for compatibility 2852 func (p *ExampleServicePingArgs) FastWrite(buf []byte) int { 2853 return 0 2854 } 2855 2856 func (p *ExampleServicePingArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2857 offset := 0 2858 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_args") 2859 if p != nil { 2860 offset += p.fastWriteField1(buf[offset:], binaryWriter) 2861 } 2862 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2863 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2864 return offset 2865 } 2866 2867 func (p *ExampleServicePingArgs) BLength() int { 2868 l := 0 2869 l += bthrift.Binary.StructBeginLength("Ping_args") 2870 if p != nil { 2871 l += p.field1Length() 2872 } 2873 l += bthrift.Binary.FieldStopLength() 2874 l += bthrift.Binary.StructEndLength() 2875 return l 2876 } 2877 2878 func (p *ExampleServicePingArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2879 offset := 0 2880 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) 2881 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) 2882 2883 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 2884 return offset 2885 } 2886 2887 func (p *ExampleServicePingArgs) field1Length() int { 2888 l := 0 2889 l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) 2890 l += bthrift.Binary.StringLengthNocopy(p.Msg) 2891 2892 l += bthrift.Binary.FieldEndLength() 2893 return l 2894 } 2895 2896 func (p *ExampleServicePingResult) FastRead(buf []byte) (int, error) { 2897 var err error 2898 var offset int 2899 var l int 2900 var fieldTypeId thrift.TType 2901 var fieldId int16 2902 _, l, err = bthrift.Binary.ReadStructBegin(buf) 2903 offset += l 2904 if err != nil { 2905 goto ReadStructBeginError 2906 } 2907 2908 for { 2909 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 2910 offset += l 2911 if err != nil { 2912 goto ReadFieldBeginError 2913 } 2914 if fieldTypeId == thrift.STOP { 2915 break 2916 } 2917 switch fieldId { 2918 case 0: 2919 if fieldTypeId == thrift.STRING { 2920 l, err = p.FastReadField0(buf[offset:]) 2921 offset += l 2922 if err != nil { 2923 goto ReadFieldError 2924 } 2925 } else { 2926 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2927 offset += l 2928 if err != nil { 2929 goto SkipFieldError 2930 } 2931 } 2932 default: 2933 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 2934 offset += l 2935 if err != nil { 2936 goto SkipFieldError 2937 } 2938 } 2939 2940 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 2941 offset += l 2942 if err != nil { 2943 goto ReadFieldEndError 2944 } 2945 } 2946 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 2947 offset += l 2948 if err != nil { 2949 goto ReadStructEndError 2950 } 2951 2952 return offset, nil 2953 ReadStructBeginError: 2954 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 2955 ReadFieldBeginError: 2956 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 2957 ReadFieldError: 2958 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingResult[fieldId]), err) 2959 SkipFieldError: 2960 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 2961 ReadFieldEndError: 2962 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 2963 ReadStructEndError: 2964 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 2965 } 2966 2967 func (p *ExampleServicePingResult) FastReadField0(buf []byte) (int, error) { 2968 offset := 0 2969 2970 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 2971 return offset, err 2972 } else { 2973 offset += l 2974 p.Success = &v 2975 2976 } 2977 return offset, nil 2978 } 2979 2980 // for compatibility 2981 func (p *ExampleServicePingResult) FastWrite(buf []byte) int { 2982 return 0 2983 } 2984 2985 func (p *ExampleServicePingResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 2986 offset := 0 2987 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_result") 2988 if p != nil { 2989 offset += p.fastWriteField0(buf[offset:], binaryWriter) 2990 } 2991 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 2992 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 2993 return offset 2994 } 2995 2996 func (p *ExampleServicePingResult) BLength() int { 2997 l := 0 2998 l += bthrift.Binary.StructBeginLength("Ping_result") 2999 if p != nil { 3000 l += p.field0Length() 3001 } 3002 l += bthrift.Binary.FieldStopLength() 3003 l += bthrift.Binary.StructEndLength() 3004 return l 3005 } 3006 3007 func (p *ExampleServicePingResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3008 offset := 0 3009 if p.IsSetSuccess() { 3010 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRING, 0) 3011 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Success) 3012 3013 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3014 } 3015 return offset 3016 } 3017 3018 func (p *ExampleServicePingResult) field0Length() int { 3019 l := 0 3020 if p.IsSetSuccess() { 3021 l += bthrift.Binary.FieldBeginLength("success", thrift.STRING, 0) 3022 l += bthrift.Binary.StringLengthNocopy(*p.Success) 3023 3024 l += bthrift.Binary.FieldEndLength() 3025 } 3026 return l 3027 } 3028 3029 func (p *ExampleServiceOnewayArgs) FastRead(buf []byte) (int, error) { 3030 var err error 3031 var offset int 3032 var l int 3033 var fieldTypeId thrift.TType 3034 var fieldId int16 3035 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3036 offset += l 3037 if err != nil { 3038 goto ReadStructBeginError 3039 } 3040 3041 for { 3042 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3043 offset += l 3044 if err != nil { 3045 goto ReadFieldBeginError 3046 } 3047 if fieldTypeId == thrift.STOP { 3048 break 3049 } 3050 switch fieldId { 3051 case 1: 3052 if fieldTypeId == thrift.STRING { 3053 l, err = p.FastReadField1(buf[offset:]) 3054 offset += l 3055 if err != nil { 3056 goto ReadFieldError 3057 } 3058 } else { 3059 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3060 offset += l 3061 if err != nil { 3062 goto SkipFieldError 3063 } 3064 } 3065 default: 3066 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3067 offset += l 3068 if err != nil { 3069 goto SkipFieldError 3070 } 3071 } 3072 3073 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3074 offset += l 3075 if err != nil { 3076 goto ReadFieldEndError 3077 } 3078 } 3079 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3080 offset += l 3081 if err != nil { 3082 goto ReadStructEndError 3083 } 3084 3085 return offset, nil 3086 ReadStructBeginError: 3087 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3088 ReadFieldBeginError: 3089 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3090 ReadFieldError: 3091 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOnewayArgs[fieldId]), err) 3092 SkipFieldError: 3093 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 3094 ReadFieldEndError: 3095 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3096 ReadStructEndError: 3097 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3098 } 3099 3100 func (p *ExampleServiceOnewayArgs) FastReadField1(buf []byte) (int, error) { 3101 offset := 0 3102 3103 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 3104 return offset, err 3105 } else { 3106 offset += l 3107 3108 p.Msg = v 3109 3110 } 3111 return offset, nil 3112 } 3113 3114 // for compatibility 3115 func (p *ExampleServiceOnewayArgs) FastWrite(buf []byte) int { 3116 return 0 3117 } 3118 3119 func (p *ExampleServiceOnewayArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3120 offset := 0 3121 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Oneway_args") 3122 if p != nil { 3123 offset += p.fastWriteField1(buf[offset:], binaryWriter) 3124 } 3125 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3126 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3127 return offset 3128 } 3129 3130 func (p *ExampleServiceOnewayArgs) BLength() int { 3131 l := 0 3132 l += bthrift.Binary.StructBeginLength("Oneway_args") 3133 if p != nil { 3134 l += p.field1Length() 3135 } 3136 l += bthrift.Binary.FieldStopLength() 3137 l += bthrift.Binary.StructEndLength() 3138 return l 3139 } 3140 3141 func (p *ExampleServiceOnewayArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3142 offset := 0 3143 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) 3144 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) 3145 3146 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3147 return offset 3148 } 3149 3150 func (p *ExampleServiceOnewayArgs) field1Length() int { 3151 l := 0 3152 l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) 3153 l += bthrift.Binary.StringLengthNocopy(p.Msg) 3154 3155 l += bthrift.Binary.FieldEndLength() 3156 return l 3157 } 3158 3159 func (p *ExampleServiceVoidArgs) FastRead(buf []byte) (int, error) { 3160 var err error 3161 var offset int 3162 var l int 3163 var fieldTypeId thrift.TType 3164 var fieldId int16 3165 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3166 offset += l 3167 if err != nil { 3168 goto ReadStructBeginError 3169 } 3170 3171 for { 3172 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3173 offset += l 3174 if err != nil { 3175 goto ReadFieldBeginError 3176 } 3177 if fieldTypeId == thrift.STOP { 3178 break 3179 } 3180 switch fieldId { 3181 case 1: 3182 if fieldTypeId == thrift.STRING { 3183 l, err = p.FastReadField1(buf[offset:]) 3184 offset += l 3185 if err != nil { 3186 goto ReadFieldError 3187 } 3188 } else { 3189 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3190 offset += l 3191 if err != nil { 3192 goto SkipFieldError 3193 } 3194 } 3195 default: 3196 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3197 offset += l 3198 if err != nil { 3199 goto SkipFieldError 3200 } 3201 } 3202 3203 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3204 offset += l 3205 if err != nil { 3206 goto ReadFieldEndError 3207 } 3208 } 3209 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3210 offset += l 3211 if err != nil { 3212 goto ReadStructEndError 3213 } 3214 3215 return offset, nil 3216 ReadStructBeginError: 3217 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3218 ReadFieldBeginError: 3219 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3220 ReadFieldError: 3221 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceVoidArgs[fieldId]), err) 3222 SkipFieldError: 3223 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 3224 ReadFieldEndError: 3225 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3226 ReadStructEndError: 3227 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3228 } 3229 3230 func (p *ExampleServiceVoidArgs) FastReadField1(buf []byte) (int, error) { 3231 offset := 0 3232 3233 if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { 3234 return offset, err 3235 } else { 3236 offset += l 3237 3238 p.Msg = v 3239 3240 } 3241 return offset, nil 3242 } 3243 3244 // for compatibility 3245 func (p *ExampleServiceVoidArgs) FastWrite(buf []byte) int { 3246 return 0 3247 } 3248 3249 func (p *ExampleServiceVoidArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3250 offset := 0 3251 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_args") 3252 if p != nil { 3253 offset += p.fastWriteField1(buf[offset:], binaryWriter) 3254 } 3255 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3256 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3257 return offset 3258 } 3259 3260 func (p *ExampleServiceVoidArgs) BLength() int { 3261 l := 0 3262 l += bthrift.Binary.StructBeginLength("Void_args") 3263 if p != nil { 3264 l += p.field1Length() 3265 } 3266 l += bthrift.Binary.FieldStopLength() 3267 l += bthrift.Binary.StructEndLength() 3268 return l 3269 } 3270 3271 func (p *ExampleServiceVoidArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3272 offset := 0 3273 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) 3274 offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) 3275 3276 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3277 return offset 3278 } 3279 3280 func (p *ExampleServiceVoidArgs) field1Length() int { 3281 l := 0 3282 l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) 3283 l += bthrift.Binary.StringLengthNocopy(p.Msg) 3284 3285 l += bthrift.Binary.FieldEndLength() 3286 return l 3287 } 3288 3289 func (p *ExampleServiceVoidResult) FastRead(buf []byte) (int, error) { 3290 var err error 3291 var offset int 3292 var l int 3293 var fieldTypeId thrift.TType 3294 var fieldId int16 3295 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3296 offset += l 3297 if err != nil { 3298 goto ReadStructBeginError 3299 } 3300 3301 for { 3302 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3303 offset += l 3304 if err != nil { 3305 goto ReadFieldBeginError 3306 } 3307 if fieldTypeId == thrift.STOP { 3308 break 3309 } 3310 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3311 offset += l 3312 if err != nil { 3313 goto SkipFieldTypeError 3314 } 3315 3316 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3317 offset += l 3318 if err != nil { 3319 goto ReadFieldEndError 3320 } 3321 } 3322 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3323 offset += l 3324 if err != nil { 3325 goto ReadStructEndError 3326 } 3327 3328 return offset, nil 3329 ReadStructBeginError: 3330 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3331 ReadFieldBeginError: 3332 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3333 3334 SkipFieldTypeError: 3335 return offset, thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) 3336 ReadFieldEndError: 3337 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3338 ReadStructEndError: 3339 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3340 } 3341 3342 // for compatibility 3343 func (p *ExampleServiceVoidResult) FastWrite(buf []byte) int { 3344 return 0 3345 } 3346 3347 func (p *ExampleServiceVoidResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3348 offset := 0 3349 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_result") 3350 if p != nil { 3351 } 3352 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3353 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3354 return offset 3355 } 3356 3357 func (p *ExampleServiceVoidResult) BLength() int { 3358 l := 0 3359 l += bthrift.Binary.StructBeginLength("Void_result") 3360 if p != nil { 3361 } 3362 l += bthrift.Binary.FieldStopLength() 3363 l += bthrift.Binary.StructEndLength() 3364 return l 3365 } 3366 3367 func (p *ExampleServiceExampleToSnakeCaseArgs) FastRead(buf []byte) (int, error) { 3368 var err error 3369 var offset int 3370 var l int 3371 var fieldTypeId thrift.TType 3372 var fieldId int16 3373 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3374 offset += l 3375 if err != nil { 3376 goto ReadStructBeginError 3377 } 3378 3379 for { 3380 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3381 offset += l 3382 if err != nil { 3383 goto ReadFieldBeginError 3384 } 3385 if fieldTypeId == thrift.STOP { 3386 break 3387 } 3388 switch fieldId { 3389 case 1: 3390 if fieldTypeId == thrift.STRUCT { 3391 l, err = p.FastReadField1(buf[offset:]) 3392 offset += l 3393 if err != nil { 3394 goto ReadFieldError 3395 } 3396 } else { 3397 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3398 offset += l 3399 if err != nil { 3400 goto SkipFieldError 3401 } 3402 } 3403 default: 3404 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3405 offset += l 3406 if err != nil { 3407 goto SkipFieldError 3408 } 3409 } 3410 3411 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3412 offset += l 3413 if err != nil { 3414 goto ReadFieldEndError 3415 } 3416 } 3417 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3418 offset += l 3419 if err != nil { 3420 goto ReadStructEndError 3421 } 3422 3423 return offset, nil 3424 ReadStructBeginError: 3425 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3426 ReadFieldBeginError: 3427 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3428 ReadFieldError: 3429 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleToSnakeCaseArgs[fieldId]), err) 3430 SkipFieldError: 3431 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 3432 ReadFieldEndError: 3433 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3434 ReadStructEndError: 3435 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3436 } 3437 3438 func (p *ExampleServiceExampleToSnakeCaseArgs) FastReadField1(buf []byte) (int, error) { 3439 offset := 0 3440 p.Req = NewExampleToSnakeCase() 3441 if l, err := p.Req.FastRead(buf[offset:]); err != nil { 3442 return offset, err 3443 } else { 3444 offset += l 3445 } 3446 return offset, nil 3447 } 3448 3449 // for compatibility 3450 func (p *ExampleServiceExampleToSnakeCaseArgs) FastWrite(buf []byte) int { 3451 return 0 3452 } 3453 3454 func (p *ExampleServiceExampleToSnakeCaseArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3455 offset := 0 3456 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase_args") 3457 if p != nil { 3458 offset += p.fastWriteField1(buf[offset:], binaryWriter) 3459 } 3460 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3461 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3462 return offset 3463 } 3464 3465 func (p *ExampleServiceExampleToSnakeCaseArgs) BLength() int { 3466 l := 0 3467 l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase_args") 3468 if p != nil { 3469 l += p.field1Length() 3470 } 3471 l += bthrift.Binary.FieldStopLength() 3472 l += bthrift.Binary.StructEndLength() 3473 return l 3474 } 3475 3476 func (p *ExampleServiceExampleToSnakeCaseArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3477 offset := 0 3478 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) 3479 offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) 3480 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3481 return offset 3482 } 3483 3484 func (p *ExampleServiceExampleToSnakeCaseArgs) field1Length() int { 3485 l := 0 3486 l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) 3487 l += p.Req.BLength() 3488 l += bthrift.Binary.FieldEndLength() 3489 return l 3490 } 3491 3492 func (p *ExampleServiceExampleToSnakeCaseResult) FastRead(buf []byte) (int, error) { 3493 var err error 3494 var offset int 3495 var l int 3496 var fieldTypeId thrift.TType 3497 var fieldId int16 3498 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3499 offset += l 3500 if err != nil { 3501 goto ReadStructBeginError 3502 } 3503 3504 for { 3505 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3506 offset += l 3507 if err != nil { 3508 goto ReadFieldBeginError 3509 } 3510 if fieldTypeId == thrift.STOP { 3511 break 3512 } 3513 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3514 offset += l 3515 if err != nil { 3516 goto SkipFieldTypeError 3517 } 3518 3519 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3520 offset += l 3521 if err != nil { 3522 goto ReadFieldEndError 3523 } 3524 } 3525 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3526 offset += l 3527 if err != nil { 3528 goto ReadStructEndError 3529 } 3530 3531 return offset, nil 3532 ReadStructBeginError: 3533 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3534 ReadFieldBeginError: 3535 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3536 3537 SkipFieldTypeError: 3538 return offset, thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) 3539 ReadFieldEndError: 3540 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3541 ReadStructEndError: 3542 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3543 } 3544 3545 // for compatibility 3546 func (p *ExampleServiceExampleToSnakeCaseResult) FastWrite(buf []byte) int { 3547 return 0 3548 } 3549 3550 func (p *ExampleServiceExampleToSnakeCaseResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3551 offset := 0 3552 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase_result") 3553 if p != nil { 3554 } 3555 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3556 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3557 return offset 3558 } 3559 3560 func (p *ExampleServiceExampleToSnakeCaseResult) BLength() int { 3561 l := 0 3562 l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase_result") 3563 if p != nil { 3564 } 3565 l += bthrift.Binary.FieldStopLength() 3566 l += bthrift.Binary.StructEndLength() 3567 return l 3568 } 3569 3570 func (p *ExampleServiceExampleDefaultValueArgs) FastRead(buf []byte) (int, error) { 3571 var err error 3572 var offset int 3573 var l int 3574 var fieldTypeId thrift.TType 3575 var fieldId int16 3576 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3577 offset += l 3578 if err != nil { 3579 goto ReadStructBeginError 3580 } 3581 3582 for { 3583 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3584 offset += l 3585 if err != nil { 3586 goto ReadFieldBeginError 3587 } 3588 if fieldTypeId == thrift.STOP { 3589 break 3590 } 3591 switch fieldId { 3592 case 1: 3593 if fieldTypeId == thrift.STRUCT { 3594 l, err = p.FastReadField1(buf[offset:]) 3595 offset += l 3596 if err != nil { 3597 goto ReadFieldError 3598 } 3599 } else { 3600 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3601 offset += l 3602 if err != nil { 3603 goto SkipFieldError 3604 } 3605 } 3606 default: 3607 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3608 offset += l 3609 if err != nil { 3610 goto SkipFieldError 3611 } 3612 } 3613 3614 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3615 offset += l 3616 if err != nil { 3617 goto ReadFieldEndError 3618 } 3619 } 3620 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3621 offset += l 3622 if err != nil { 3623 goto ReadStructEndError 3624 } 3625 3626 return offset, nil 3627 ReadStructBeginError: 3628 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3629 ReadFieldBeginError: 3630 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3631 ReadFieldError: 3632 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueArgs[fieldId]), err) 3633 SkipFieldError: 3634 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 3635 ReadFieldEndError: 3636 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3637 ReadStructEndError: 3638 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3639 } 3640 3641 func (p *ExampleServiceExampleDefaultValueArgs) FastReadField1(buf []byte) (int, error) { 3642 offset := 0 3643 p.Req = NewExampleDefaultValue() 3644 if l, err := p.Req.FastRead(buf[offset:]); err != nil { 3645 return offset, err 3646 } else { 3647 offset += l 3648 } 3649 return offset, nil 3650 } 3651 3652 // for compatibility 3653 func (p *ExampleServiceExampleDefaultValueArgs) FastWrite(buf []byte) int { 3654 return 0 3655 } 3656 3657 func (p *ExampleServiceExampleDefaultValueArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3658 offset := 0 3659 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue_args") 3660 if p != nil { 3661 offset += p.fastWriteField1(buf[offset:], binaryWriter) 3662 } 3663 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3664 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3665 return offset 3666 } 3667 3668 func (p *ExampleServiceExampleDefaultValueArgs) BLength() int { 3669 l := 0 3670 l += bthrift.Binary.StructBeginLength("ExampleDefaultValue_args") 3671 if p != nil { 3672 l += p.field1Length() 3673 } 3674 l += bthrift.Binary.FieldStopLength() 3675 l += bthrift.Binary.StructEndLength() 3676 return l 3677 } 3678 3679 func (p *ExampleServiceExampleDefaultValueArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3680 offset := 0 3681 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) 3682 offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) 3683 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3684 return offset 3685 } 3686 3687 func (p *ExampleServiceExampleDefaultValueArgs) field1Length() int { 3688 l := 0 3689 l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) 3690 l += p.Req.BLength() 3691 l += bthrift.Binary.FieldEndLength() 3692 return l 3693 } 3694 3695 func (p *ExampleServiceExampleDefaultValueResult) FastRead(buf []byte) (int, error) { 3696 var err error 3697 var offset int 3698 var l int 3699 var fieldTypeId thrift.TType 3700 var fieldId int16 3701 _, l, err = bthrift.Binary.ReadStructBegin(buf) 3702 offset += l 3703 if err != nil { 3704 goto ReadStructBeginError 3705 } 3706 3707 for { 3708 _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) 3709 offset += l 3710 if err != nil { 3711 goto ReadFieldBeginError 3712 } 3713 if fieldTypeId == thrift.STOP { 3714 break 3715 } 3716 switch fieldId { 3717 case 0: 3718 if fieldTypeId == thrift.STRUCT { 3719 l, err = p.FastReadField0(buf[offset:]) 3720 offset += l 3721 if err != nil { 3722 goto ReadFieldError 3723 } 3724 } else { 3725 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3726 offset += l 3727 if err != nil { 3728 goto SkipFieldError 3729 } 3730 } 3731 default: 3732 l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) 3733 offset += l 3734 if err != nil { 3735 goto SkipFieldError 3736 } 3737 } 3738 3739 l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) 3740 offset += l 3741 if err != nil { 3742 goto ReadFieldEndError 3743 } 3744 } 3745 l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) 3746 offset += l 3747 if err != nil { 3748 goto ReadStructEndError 3749 } 3750 3751 return offset, nil 3752 ReadStructBeginError: 3753 return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) 3754 ReadFieldBeginError: 3755 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) 3756 ReadFieldError: 3757 return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueResult[fieldId]), err) 3758 SkipFieldError: 3759 return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) 3760 ReadFieldEndError: 3761 return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) 3762 ReadStructEndError: 3763 return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 3764 } 3765 3766 func (p *ExampleServiceExampleDefaultValueResult) FastReadField0(buf []byte) (int, error) { 3767 offset := 0 3768 p.Success = NewExampleDefaultValue() 3769 if l, err := p.Success.FastRead(buf[offset:]); err != nil { 3770 return offset, err 3771 } else { 3772 offset += l 3773 } 3774 return offset, nil 3775 } 3776 3777 // for compatibility 3778 func (p *ExampleServiceExampleDefaultValueResult) FastWrite(buf []byte) int { 3779 return 0 3780 } 3781 3782 func (p *ExampleServiceExampleDefaultValueResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3783 offset := 0 3784 offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue_result") 3785 if p != nil { 3786 offset += p.fastWriteField0(buf[offset:], binaryWriter) 3787 } 3788 offset += bthrift.Binary.WriteFieldStop(buf[offset:]) 3789 offset += bthrift.Binary.WriteStructEnd(buf[offset:]) 3790 return offset 3791 } 3792 3793 func (p *ExampleServiceExampleDefaultValueResult) BLength() int { 3794 l := 0 3795 l += bthrift.Binary.StructBeginLength("ExampleDefaultValue_result") 3796 if p != nil { 3797 l += p.field0Length() 3798 } 3799 l += bthrift.Binary.FieldStopLength() 3800 l += bthrift.Binary.StructEndLength() 3801 return l 3802 } 3803 3804 func (p *ExampleServiceExampleDefaultValueResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { 3805 offset := 0 3806 if p.IsSetSuccess() { 3807 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) 3808 offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) 3809 offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) 3810 } 3811 return offset 3812 } 3813 3814 func (p *ExampleServiceExampleDefaultValueResult) field0Length() int { 3815 l := 0 3816 if p.IsSetSuccess() { 3817 l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) 3818 l += p.Success.BLength() 3819 l += bthrift.Binary.FieldEndLength() 3820 } 3821 return l 3822 } 3823 3824 func (p *ExampleServiceExampleDeepRefArgs) GetFirstArgument() interface{} { 3825 return p.Req 3826 } 3827 3828 func (p *ExampleServiceExampleDeepRefResult) GetResult() interface{} { 3829 return p.Success 3830 } 3831 3832 func (p *ExampleServiceExampleMethodArgs) GetFirstArgument() interface{} { 3833 return p.Req 3834 } 3835 3836 func (p *ExampleServiceExampleMethodResult) GetResult() interface{} { 3837 return p.Success 3838 } 3839 3840 func (p *ExampleServiceFooArgs) GetFirstArgument() interface{} { 3841 return p.Req 3842 } 3843 3844 func (p *ExampleServiceFooResult) GetResult() interface{} { 3845 return p.Success 3846 } 3847 3848 func (p *ExampleServicePingArgs) GetFirstArgument() interface{} { 3849 return p.Msg 3850 } 3851 3852 func (p *ExampleServicePingResult) GetResult() interface{} { 3853 return p.Success 3854 } 3855 3856 func (p *ExampleServiceOnewayArgs) GetFirstArgument() interface{} { 3857 return p.Msg 3858 } 3859 3860 func (p *ExampleServiceVoidArgs) GetFirstArgument() interface{} { 3861 return p.Msg 3862 } 3863 3864 func (p *ExampleServiceVoidResult) GetResult() interface{} { 3865 return nil 3866 } 3867 3868 func (p *ExampleServiceExampleToSnakeCaseArgs) GetFirstArgument() interface{} { 3869 return p.Req 3870 } 3871 3872 func (p *ExampleServiceExampleToSnakeCaseResult) GetResult() interface{} { 3873 return nil 3874 } 3875 3876 func (p *ExampleServiceExampleDefaultValueArgs) GetFirstArgument() interface{} { 3877 return p.Req 3878 } 3879 3880 func (p *ExampleServiceExampleDefaultValueResult) GetResult() interface{} { 3881 return p.Success 3882 } 3883 3884 func (p *ExampleReq) GetOrSetBase() interface{} { 3885 if p.Base == nil { 3886 p.Base = base.NewBase() 3887 } 3888 return p.Base 3889 } 3890 func (p *ExampleToSnakeCase) GetOrSetBase() interface{} { 3891 if p.Base == nil { 3892 p.Base = base.NewBase() 3893 } 3894 return p.Base 3895 } 3896 3897 func (p *ExampleResp) GetOrSetBaseResp() interface{} { 3898 if p.BaseResp == nil { 3899 p.BaseResp = base.NewBaseResp() 3900 } 3901 return p.BaseResp 3902 }