From f05c71ba9bc1700c286b1987fe0cf04978e2e7f0 Mon Sep 17 00:00:00 2001 From: Kyle Xiao Date: Wed, 31 Jul 2024 16:57:59 +0800 Subject: [PATCH 1/2] refactor: rm github.com/apache/thrift --- .gitignore | 5 + conv/t2j/conv_test.go | 16 +- go.mod | 7 +- go.sum | 18 +- internal/bthrift/binary.go | 629 - internal/bthrift/interface.go | 99 - internal/bthrift/protocol_error.go | 108 - internal/bthrift/unknown.go | 397 - proto/generic/value_test.go | 4 + testdata/data/basic_example_pb.bin | Bin 1246 -> 0 bytes testdata/data/example3_pb.bin | 55 - testdata/gen.sh | 28 + testdata/idl/example.thrift | 3 +- testdata/idl/ref.thrift | 2 - testdata/kitex_gen/base/base.go | 973 +- testdata/kitex_gen/base/k-base.go | 1073 +- testdata/kitex_gen/baseline/baseline.go | 4885 +------ testdata/kitex_gen/baseline/k-baseline.go | 4785 ++---- testdata/kitex_gen/deep/deep.ref.go | 204 +- testdata/kitex_gen/deep/k-deep.ref.go | 241 +- testdata/kitex_gen/example/example.go | 4847 +------ testdata/kitex_gen/example/k-example.go | 4561 ++---- testdata/kitex_gen/example2/example2.go | 7346 +--------- testdata/kitex_gen/example2/k-example2.go | 7063 +++------ testdata/kitex_gen/example3/example3.go | 15235 ++------------------ testdata/kitex_gen/example3/k-example3.go | 14331 ++++++------------ testdata/kitex_gen/null/k-null.go | 947 +- testdata/kitex_gen/null/null.go | 959 +- testdata/kitex_gen/ref/k-ref.go | 24 +- testdata/kitex_gen/ref/ref.go | 3 +- testdata/kitex_gen/skip/k-skip.go | 578 +- testdata/kitex_gen/skip/skip.go | 628 +- testdata/sample/example2.go | 2 +- testdata/sample/example3.go | 4 +- thrift/base/base.go | 1087 +- thrift/base/k-base.go | 887 -- thrift/descriptor.go | 11 - thrift/generic/value_test.go | 2 +- 38 files changed, 11829 insertions(+), 60218 deletions(-) delete mode 100644 internal/bthrift/binary.go delete mode 100644 internal/bthrift/interface.go delete mode 100644 internal/bthrift/protocol_error.go delete mode 100644 internal/bthrift/unknown.go delete mode 100644 testdata/data/basic_example_pb.bin delete mode 100644 testdata/data/example3_pb.bin create mode 100755 testdata/gen.sh delete mode 100644 thrift/base/k-base.go diff --git a/.gitignore b/.gitignore index db2da7c4..80900ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,8 @@ output *.dSYM *.profile *.txt + + +# testdata/data/basic_example_pb.bin +# testdata/data/basic_example_pb.bin +*.bin diff --git a/conv/t2j/conv_test.go b/conv/t2j/conv_test.go index 026cf753..83966927 100644 --- a/conv/t2j/conv_test.go +++ b/conv/t2j/conv_test.go @@ -314,9 +314,9 @@ func TestInt2String(t *testing.T) { desc := getExampleInt2Float() exp := example3.NewExampleInt2Float() exp.Int32 = 1 - exp.Int64 = 2 exp.Float64 = 3.14 - exp.String_ = "hello" + exp.String_ = "hello" // json:"中文" + exp.Int64 = 2 exp.Subfix = 0.92653 ctx := context.Background() in := make([]byte, exp.BLength()) @@ -324,17 +324,17 @@ func TestInt2String(t *testing.T) { out, err := cv.Do(ctx, desc, in) require.NoError(t, err) - require.Equal(t, `{"Int32":"1","Float64":"3.14","Int64":2,"Subfix":0.92653,"中文":"hello"}`, string(out)) + require.Equal(t, `{"Int32":"1","Float64":"3.14","中文":"hello","Int64":2,"Subfix":0.92653}`, string(out)) cv.opts.EnableValueMapping = false out, err = cv.Do(ctx, desc, in) require.NoError(t, err) - require.Equal(t, (`{"Int32":1,"Float64":3.14,"Int64":2,"Subfix":0.92653,"中文":"hello"}`), string(out)) + require.Equal(t, (`{"Int32":1,"Float64":3.14,"中文":"hello","Int64":2,"Subfix":0.92653}`), string(out)) cv.opts.Int642String = true out, err = cv.Do(ctx, desc, in) require.NoError(t, err) - require.Equal(t, (`{"Int32":1,"Float64":3.14,"Int64":"2","Subfix":0.92653,"中文":"hello"}`), string(out)) + require.Equal(t, (`{"Int32":1,"Float64":3.14,"中文":"hello","Int64":"2","Subfix":0.92653}`), string(out)) } func TestHttpMappingFallback(t *testing.T) { @@ -687,7 +687,7 @@ func TestSimpleArgs(t *testing.T) { func TestConvThrift2HTTP_KitexApiHeader(t *testing.T) { // annotation.RegisterHttpMaping(annotation.APIHeader, annotation.HttpMapingHandler{Req:annotation.ApiHeaderRequest, Resp:annotation.ApiheaderKitexResponse, Enc:annotation.ApiHeaderKitexEncoding}) - + desc := thrift.FnResponse(thrift.GetFnDescFromFile("testdata/idl/example3.thrift", "JSONStringMethod", thrift.Options{})) exp := example3.NewExampleJSONString() eobj := &example3.JSONObject{ @@ -705,7 +705,7 @@ func TestConvThrift2HTTP_KitexApiHeader(t *testing.T) { EnableHttpMapping: true, WriteHttpValueFallback: true, OmitHttpMappingErrors: true, - UseKitexHttpEncoding: true, + UseKitexHttpEncoding: true, }) ctx := context.Background() resp := http.NewHTTPResponse() @@ -721,4 +721,4 @@ func TestConvThrift2HTTP_KitexApiHeader(t *testing.T) { require.Equal(t, "1,2", resp.Cookies()[1].Value) // annotation.RegisterHttpMaping(annotation.APIHeader, annotation.HttpMapingHandler{Req:annotation.ApiHeaderRequest, Resp: annotation.ApiHeaderResponse, Enc:annotation.ApiHeaderEncoding}) -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index 1c45f406..753f08b4 100644 --- a/go.mod +++ b/go.mod @@ -3,28 +3,29 @@ module github.com/cloudwego/dynamicgo go 1.17 require ( - github.com/apache/thrift v0.13.0 github.com/bytedance/sonic v1.12.0 github.com/bytedance/sonic/loader v0.2.0 github.com/cloudwego/base64x v0.1.4 github.com/cloudwego/fastpb v0.0.4 + github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40 github.com/cloudwego/thriftgo v0.3.6 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/fatih/structtag v1.2.0 github.com/iancoleman/strcase v0.2.0 github.com/jhump/protoreflect v1.8.2 github.com/klauspost/cpuid/v2 v2.2.4 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.9.0 google.golang.org/protobuf v1.28.1 ) require ( + github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8 // indirect github.com/cloudwego/iasm v0.2.0 // indirect github.com/golang/protobuf v1.5.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index a51b0de5..f2211a69 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8 h1:rDwLxYTMoKHaw4cS0bQhaTZnkXp5e6ediCggGcRD/CA= +github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= github.com/bytedance/sonic v1.12.0 h1:YGPgxF9xzaCNvd/ZKdQ28yRovhfMFZQjuk6fKBzZ3ls= github.com/bytedance/sonic v1.12.0/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -13,6 +14,8 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/fastpb v0.0.4 h1:/ROVVfoFtpfc+1pkQLzGs+azjxUbSOsAqSY4tAAx4mg= github.com/cloudwego/fastpb v0.0.4/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= +github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40 h1:H1D2KkfXUimnvJ1KPkhYLFrJOiOz33iAwTA8Puatvfw= +github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40/go.mod h1:32yKw2zkpTMtuX6amJR0EMK79f0vGPr67UcArCOlZLU= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cloudwego/thriftgo v0.3.6 h1:gHHW8Ag3cAEQ/awP4emTJiRPr5yQjbANhcsmV8/Epbw= @@ -72,12 +75,14 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -109,8 +114,9 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -118,6 +124,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -128,8 +135,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/bthrift/binary.go b/internal/bthrift/binary.go deleted file mode 100644 index c0c31ffe..00000000 --- a/internal/bthrift/binary.go +++ /dev/null @@ -1,629 +0,0 @@ -/* - * Copyright 2021 CloudWeGo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Package bthrift . -package bthrift - -import ( - "encoding/binary" - "errors" - "fmt" - "math" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/dynamicgo/internal/rt" -) - -// Binary protocol for bthrift. -var Binary binaryProtocol - -var _ BTProtocol = binaryProtocol{} - -type binaryProtocol struct{} - -func (binaryProtocol) WriteMessageBegin(buf []byte, name string, typeID thrift.TMessageType, seqid int32) int { - offset := 0 - version := uint32(thrift.VERSION_1) | uint32(typeID) - offset += Binary.WriteI32(buf, int32(version)) - offset += Binary.WriteString(buf[offset:], name) - offset += Binary.WriteI32(buf[offset:], seqid) - return offset -} - -func (binaryProtocol) WriteMessageEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteStructBegin(buf []byte, name string) int { - return 0 -} - -func (binaryProtocol) WriteStructEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteFieldBegin(buf []byte, name string, typeID thrift.TType, id int16) int { - return Binary.WriteByte(buf, int8(typeID)) + Binary.WriteI16(buf[1:], id) -} - -func (binaryProtocol) WriteFieldEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteFieldStop(buf []byte) int { - return Binary.WriteByte(buf, thrift.STOP) -} - -func (binaryProtocol) WriteMapBegin(buf []byte, keyType, valueType thrift.TType, size int) int { - return Binary.WriteByte(buf, int8(keyType)) + - Binary.WriteByte(buf[1:], int8(valueType)) + - Binary.WriteI32(buf[2:], int32(size)) -} - -func (binaryProtocol) WriteMapEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteListBegin(buf []byte, elemType thrift.TType, size int) int { - return Binary.WriteByte(buf, int8(elemType)) + - Binary.WriteI32(buf[1:], int32(size)) -} - -func (binaryProtocol) WriteListEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteSetBegin(buf []byte, elemType thrift.TType, size int) int { - return Binary.WriteByte(buf, int8(elemType)) + - Binary.WriteI32(buf[1:], int32(size)) -} - -func (binaryProtocol) WriteSetEnd(buf []byte) int { - return 0 -} - -func (binaryProtocol) WriteBool(buf []byte, value bool) int { - if value { - return Binary.WriteByte(buf, 1) - } - return Binary.WriteByte(buf, 0) -} - -func (binaryProtocol) WriteByte(buf []byte, value int8) int { - buf[0] = byte(value) - return 1 -} - -func (binaryProtocol) WriteI16(buf []byte, value int16) int { - binary.BigEndian.PutUint16(buf, uint16(value)) - return 2 -} - -func (binaryProtocol) WriteI32(buf []byte, value int32) int { - binary.BigEndian.PutUint32(buf, uint32(value)) - return 4 -} - -func (binaryProtocol) WriteI64(buf []byte, value int64) int { - binary.BigEndian.PutUint64(buf, uint64(value)) - return 8 -} - -func (binaryProtocol) WriteDouble(buf []byte, value float64) int { - return Binary.WriteI64(buf, int64(math.Float64bits(value))) -} - -func (binaryProtocol) WriteString(buf []byte, value string) int { - l := Binary.WriteI32(buf, int32(len(value))) - copy(buf[l:], value) - return l + len(value) -} - -func (binaryProtocol) WriteBinary(buf, value []byte) int { - l := Binary.WriteI32(buf, int32(len(value))) - copy(buf[l:], value) - return l + len(value) -} - -func (binaryProtocol) WriteStringNocopy(buf []byte, binaryWriter BinaryWriter, value string) int { - return Binary.WriteBinaryNocopy(buf, binaryWriter, rt.Str2Mem(value)) -} - -func (binaryProtocol) WriteBinaryNocopy(buf []byte, binaryWriter BinaryWriter, value []byte) int { - l := Binary.WriteI32(buf, int32(len(value))) - copy(buf[l:], value) - return l + len(value) -} - -func (binaryProtocol) MessageBeginLength(name string, typeID thrift.TMessageType, seqid int32) int { - version := uint32(thrift.VERSION_1) | uint32(typeID) - return Binary.I32Length(int32(version)) + Binary.StringLength(name) + Binary.I32Length(seqid) -} - -func (binaryProtocol) MessageEndLength() int { - return 0 -} - -func (binaryProtocol) StructBeginLength(name string) int { - return 0 -} - -func (binaryProtocol) StructEndLength() int { - return 0 -} - -func (binaryProtocol) FieldBeginLength(name string, typeID thrift.TType, id int16) int { - return Binary.ByteLength(int8(typeID)) + Binary.I16Length(id) -} - -func (binaryProtocol) FieldEndLength() int { - return 0 -} - -func (binaryProtocol) FieldStopLength() int { - return Binary.ByteLength(thrift.STOP) -} - -func (binaryProtocol) MapBeginLength(keyType, valueType thrift.TType, size int) int { - return Binary.ByteLength(int8(keyType)) + - Binary.ByteLength(int8(valueType)) + - Binary.I32Length(int32(size)) -} - -func (binaryProtocol) MapEndLength() int { - return 0 -} - -func (binaryProtocol) ListBeginLength(elemType thrift.TType, size int) int { - return Binary.ByteLength(int8(elemType)) + - Binary.I32Length(int32(size)) -} - -func (binaryProtocol) ListEndLength() int { - return 0 -} - -func (binaryProtocol) SetBeginLength(elemType thrift.TType, size int) int { - return Binary.ByteLength(int8(elemType)) + - Binary.I32Length(int32(size)) -} - -func (binaryProtocol) SetEndLength() int { - return 0 -} - -func (binaryProtocol) BoolLength(value bool) int { - if value { - return Binary.ByteLength(1) - } - return Binary.ByteLength(0) -} - -func (binaryProtocol) ByteLength(value int8) int { - return 1 -} - -func (binaryProtocol) I16Length(value int16) int { - return 2 -} - -func (binaryProtocol) I32Length(value int32) int { - return 4 -} - -func (binaryProtocol) I64Length(value int64) int { - return 8 -} - -func (binaryProtocol) DoubleLength(value float64) int { - return Binary.I64Length(int64(math.Float64bits(value))) -} - -func (binaryProtocol) StringLength(value string) int { - return Binary.I32Length(int32(len(value))) + len(value) -} - -func (binaryProtocol) BinaryLength(value []byte) int { - return Binary.I32Length(int32(len(value))) + len(value) -} - -func (binaryProtocol) StringLengthNocopy(value string) int { - return Binary.BinaryLengthNocopy(rt.Str2Mem(value)) -} - -func (binaryProtocol) BinaryLengthNocopy(value []byte) int { - l := Binary.I32Length(int32(len(value))) - return l + len(value) -} - -func (binaryProtocol) ReadMessageBegin(buf []byte) (name string, typeID thrift.TMessageType, seqid int32, length int, err error) { - size, l, e := Binary.ReadI32(buf) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - if size > 0 { - err = NewProtocolErrorWithType(BadVersion, "Missing version in ReadMessageBegin") - return - } - typeID = thrift.TMessageType(size & 0x0ff) - version := int64(size) & thrift.VERSION_MASK - if version != thrift.VERSION_1 { - err = NewProtocolErrorWithType(BadVersion, "Bad version in ReadMessageBegin") - return - } - name, l, e = Binary.ReadString(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - seqid, l, e = Binary.ReadI32(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - return -} - -func (binaryProtocol) ReadMessageEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadStructBegin(buf []byte) (name string, length int, err error) { - return -} - -func (binaryProtocol) ReadStructEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadFieldBegin(buf []byte) (name string, typeID thrift.TType, id int16, length int, err error) { - t, l, e := Binary.ReadByte(buf) - length += l - typeID = thrift.TType(t) - if e != nil { - err = e - return - } - if t != thrift.STOP { - id, l, err = Binary.ReadI16(buf[length:]) - length += l - } - return -} - -func (binaryProtocol) ReadFieldEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadMapBegin(buf []byte) (keyType, valueType thrift.TType, size, length int, err error) { - k, l, e := Binary.ReadByte(buf) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - keyType = thrift.TType(k) - v, l, e := Binary.ReadByte(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - valueType = thrift.TType(v) - size32, l, e := Binary.ReadI32(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - if size32 < 0 { - err = InvalidDataLength - return - } - size = int(size32) - return -} - -func (binaryProtocol) ReadMapEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadListBegin(buf []byte) (elemType thrift.TType, size, length int, err error) { - b, l, e := Binary.ReadByte(buf) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - elemType = thrift.TType(b) - size32, l, e := Binary.ReadI32(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - if size32 < 0 { - err = InvalidDataLength - return - } - size = int(size32) - - return -} - -func (binaryProtocol) ReadListEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadSetBegin(buf []byte) (elemType thrift.TType, size, length int, err error) { - b, l, e := Binary.ReadByte(buf) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - elemType = thrift.TType(b) - size32, l, e := Binary.ReadI32(buf[length:]) - length += l - if e != nil { - err = NewProtocolError(e) - return - } - if size32 < 0 { - err = InvalidDataLength - return - } - size = int(size32) - return -} - -func (binaryProtocol) ReadSetEnd(buf []byte) (int, error) { - return 0, nil -} - -func (binaryProtocol) ReadBool(buf []byte) (value bool, length int, err error) { - b, l, e := Binary.ReadByte(buf) - v := true - if b != 1 { - v = false - } - return v, l, e -} - -func (binaryProtocol) ReadByte(buf []byte) (value int8, length int, err error) { - if len(buf) < 1 { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadByte] buf length less than 1") - } - return int8(buf[0]), 1, err -} - -func (binaryProtocol) ReadI16(buf []byte) (value int16, length int, err error) { - if len(buf) < 2 { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadI16] buf length less than 2") - } - value = int16(binary.BigEndian.Uint16(buf)) - return value, 2, err -} - -func (binaryProtocol) ReadI32(buf []byte) (value int32, length int, err error) { - if len(buf) < 4 { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadI32] buf length less than 4") - } - value = int32(binary.BigEndian.Uint32(buf)) - return value, 4, err -} - -func (binaryProtocol) ReadI64(buf []byte) (value int64, length int, err error) { - if len(buf) < 8 { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadI64] buf length less than 8") - } - value = int64(binary.BigEndian.Uint64(buf)) - return value, 8, err -} - -func (binaryProtocol) ReadDouble(buf []byte) (value float64, length int, err error) { - if len(buf) < 8 { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadDouble] buf length less than 8") - } - value = math.Float64frombits(binary.BigEndian.Uint64(buf)) - return value, 8, err -} - -func (binaryProtocol) ReadString(buf []byte) (value string, length int, err error) { - size, l, e := Binary.ReadI32(buf) - length += l - if e != nil { - err = e - return - } - if size < 0 || int(size) > len(buf) { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadString] the string size greater than buf length") - } - value = string(buf[length : length+int(size)]) - length += int(size) - return -} - -func (binaryProtocol) ReadBinary(buf []byte) (value []byte, length int, err error) { - size, l, e := Binary.ReadI32(buf) - length += l - if e != nil { - err = e - return - } - if size < 0 || int(size) > len(buf) { - return value, length, NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadBinary] the binary size greater than buf length") - } - value = make([]byte, size) - copy(value, buf[length:length+int(size)]) - length += int(size) - return -} - -// Skip . -func (binaryProtocol) Skip(buf []byte, fieldType thrift.TType) (length int, err error) { - return SkipDefaultDepth(buf, Binary, fieldType) -} - -// SkipDefaultDepth skips over the next data element from the provided input TProtocol object. -func SkipDefaultDepth(buf []byte, prot BTProtocol, typeID thrift.TType) (int, error) { - return Skip(buf, prot, typeID, thrift.DEFAULT_RECURSION_DEPTH) -} - -// Skip skips over the next data element from the provided input TProtocol object. -func Skip(buf []byte, self BTProtocol, fieldType thrift.TType, maxDepth int) (length int, err error) { - if maxDepth <= 0 { - return 0, thrift.NewTProtocolExceptionWithType(thrift.DEPTH_LIMIT, errors.New("depth limit exceeded")) - } - - var l int - switch fieldType { - case thrift.BOOL: - length += 1 - return - case thrift.BYTE: - length += 1 - return - case thrift.I16: - length += 2 - return - case thrift.I32: - length += 4 - return - case thrift.I64: - length += 8 - return - case thrift.DOUBLE: - length += 8 - return - case thrift.STRING: - var sl int32 - sl, l, err = self.ReadI32(buf) - length += l + int(sl) - return - case thrift.STRUCT: - _, l, err = self.ReadStructBegin(buf) - length += l - if err != nil { - return - } - for { - _, typeID, _, l, e := self.ReadFieldBegin(buf[length:]) - length += l - if e != nil { - err = e - return - } - if typeID == thrift.STOP { - break - } - l, e = Skip(buf[length:], self, typeID, maxDepth-1) - length += l - if e != nil { - err = e - return - } - l, e = self.ReadFieldEnd(buf[length:]) - length += l - if e != nil { - err = e - return - } - } - l, e := self.ReadStructEnd(buf[length:]) - length += l - if e != nil { - err = e - } - return - case thrift.MAP: - keyType, valueType, size, l, e := self.ReadMapBegin(buf) - length += l - if e != nil { - err = e - return - } - for i := 0; i < size; i++ { - l, e := Skip(buf[length:], self, keyType, maxDepth-1) - length += l - if e != nil { - err = e - return - } - l, e = Skip(buf[length:], self, valueType, maxDepth-1) - length += l - if e != nil { - err = e - return - } - } - l, e = self.ReadMapEnd(buf[length:]) - length += l - if e != nil { - err = e - } - return - case thrift.SET: - elemType, size, l, e := self.ReadSetBegin(buf) - length += l - if e != nil { - err = e - return - } - for i := 0; i < size; i++ { - l, e = Skip(buf[length:], self, elemType, maxDepth-1) - length += l - if e != nil { - err = e - return - } - } - l, e = self.ReadSetEnd(buf[length:]) - length += l - if e != nil { - err = e - } - return - case thrift.LIST: - elemType, size, l, e := self.ReadListBegin(buf) - length += l - if e != nil { - err = e - return - } - for i := 0; i < size; i++ { - l, e = Skip(buf[length:], self, elemType, maxDepth-1) - length += l - if e != nil { - err = e - return - } - } - l, e = self.ReadListEnd(buf[length:]) - length += l - if e != nil { - err = e - } - return - default: - return 0, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("unknown data type %d", fieldType)) - } -} diff --git a/internal/bthrift/interface.go b/internal/bthrift/interface.go deleted file mode 100644 index 53692702..00000000 --- a/internal/bthrift/interface.go +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2021 CloudWeGo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Package bthrift is byted thrift -package bthrift - -import ( - "github.com/apache/thrift/lib/go/thrift" -) - -// BinaryWriter . -// Deprecated: removed from FastCodec in order to be compatible with Bytebuffer other than netpoll. -type BinaryWriter interface { - WriteDirect(b []byte, remainCap int) error -} - -// BTProtocol . -type BTProtocol interface { - WriteMessageBegin(buf []byte, name string, typeID thrift.TMessageType, seqid int32) int - WriteMessageEnd(buf []byte) int - WriteStructBegin(buf []byte, name string) int - WriteStructEnd(buf []byte) int - WriteFieldBegin(buf []byte, name string, typeID thrift.TType, id int16) int - WriteFieldEnd(buf []byte) int - WriteFieldStop(buf []byte) int - WriteMapBegin(buf []byte, keyType, valueType thrift.TType, size int) int - WriteMapEnd(buf []byte) int - WriteListBegin(buf []byte, elemType thrift.TType, size int) int - WriteListEnd(buf []byte) int - WriteSetBegin(buf []byte, elemType thrift.TType, size int) int - WriteSetEnd(buf []byte) int - WriteBool(buf []byte, value bool) int - WriteByte(buf []byte, value int8) int - WriteI16(buf []byte, value int16) int - WriteI32(buf []byte, value int32) int - WriteI64(buf []byte, value int64) int - WriteDouble(buf []byte, value float64) int - WriteString(buf []byte, value string) int - WriteBinary(buf, value []byte) int - WriteStringNocopy(buf []byte, binaryWriter BinaryWriter, value string) int - WriteBinaryNocopy(buf []byte, binaryWriter BinaryWriter, value []byte) int - MessageBeginLength(name string, typeID thrift.TMessageType, seqid int32) int - MessageEndLength() int - StructBeginLength(name string) int - StructEndLength() int - FieldBeginLength(name string, typeID thrift.TType, id int16) int - FieldEndLength() int - FieldStopLength() int - MapBeginLength(keyType, valueType thrift.TType, size int) int - MapEndLength() int - ListBeginLength(elemType thrift.TType, size int) int - ListEndLength() int - SetBeginLength(elemType thrift.TType, size int) int - SetEndLength() int - BoolLength(value bool) int - ByteLength(value int8) int - I16Length(value int16) int - I32Length(value int32) int - I64Length(value int64) int - DoubleLength(value float64) int - StringLength(value string) int - BinaryLength(value []byte) int - StringLengthNocopy(value string) int - BinaryLengthNocopy(value []byte) int - ReadMessageBegin(buf []byte) (name string, typeID thrift.TMessageType, seqid int32, length int, err error) - ReadMessageEnd(buf []byte) (int, error) - ReadStructBegin(buf []byte) (name string, length int, err error) - ReadStructEnd(buf []byte) (int, error) - ReadFieldBegin(buf []byte) (name string, typeID thrift.TType, id int16, length int, err error) - ReadFieldEnd(buf []byte) (int, error) - ReadMapBegin(buf []byte) (keyType, valueType thrift.TType, size, length int, err error) - ReadMapEnd(buf []byte) (int, error) - ReadListBegin(buf []byte) (elemType thrift.TType, size, length int, err error) - ReadListEnd(buf []byte) (int, error) - ReadSetBegin(buf []byte) (elemType thrift.TType, size, length int, err error) - ReadSetEnd(buf []byte) (int, error) - ReadBool(buf []byte) (value bool, length int, err error) - ReadByte(buf []byte) (value int8, length int, err error) - ReadI16(buf []byte) (value int16, length int, err error) - ReadI32(buf []byte) (value int32, length int, err error) - ReadI64(buf []byte) (value int64, length int, err error) - ReadDouble(buf []byte) (value float64, length int, err error) - ReadString(buf []byte) (value string, length int, err error) - ReadBinary(buf []byte) (value []byte, length int, err error) - Skip(buf []byte, fieldType thrift.TType) (length int, err error) -} diff --git a/internal/bthrift/protocol_error.go b/internal/bthrift/protocol_error.go deleted file mode 100644 index 95dca41a..00000000 --- a/internal/bthrift/protocol_error.go +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2021 CloudWeGo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bthrift - -import "errors" - -// ProtocolError indicates an protocol error has occurred. -type ProtocolError interface { - error - TypeId() int -} - -// 0-6 corresponding with thrift protocol_exception -const ( - UnknownProtocolError = 0 // unknown error - InvalidData = 1 - NegativeSize = 2 - SizeLimit = 3 - BadVersion = 4 - NotImplemented = 5 - DepthLimit = 6 -) - -// InvalidDataLength indicates the data length is invalid. -var InvalidDataLength = NewProtocolErrorWithType(InvalidData, "Invalid data length") - -type protocolException struct { - typeID int - message string - rawErr error -} - -// TypeId implements the ProtocolError interface. -func (p *protocolException) TypeId() int { - return p.typeID -} - -// String implements the ProtocolError interface. -func (p *protocolException) String() string { - return p.message -} - -// Error implements the ProtocolError interface. -func (p *protocolException) Error() string { - return p.message -} - -// Unwrap enables protocolException to use methods in errors lib. -func (p *protocolException) Unwrap() error { - return p.rawErr -} - -// Is enables protocolException to use methods in errors lib. -func (p *protocolException) Is(target error) bool { - return p == target || errors.Is(p.rawErr, target) -} - -// NewProtocolError creates a new ProtocolError wrapping the given error. -func NewProtocolError(err error) error { - if err == nil { - return nil - } - if e, ok := err.(ProtocolError); ok { - return e - } - return &protocolException{typeID: UnknownProtocolError, message: err.Error(), rawErr: err} -} - -// NewProtocolErrorWithErrMsg to build protocolException with rawErr and errMsg -func NewProtocolErrorWithErrMsg(err error, errMsg string) error { - if err == nil { - return nil - } - if e, ok := err.(ProtocolError); ok { - return e - } - return &protocolException{typeID: UnknownProtocolError, message: errMsg, rawErr: err} -} - -// NewProtocolErrorWithMsg to build protocolException with errMsg -func NewProtocolErrorWithMsg(errMsg string) error { - return &protocolException{typeID: UnknownProtocolError, message: errMsg} -} - -// NewProtocolErrorWithType to build protocolException with errType and errMsg -func NewProtocolErrorWithType(errType int, errMsg string) ProtocolError { - return &protocolException{typeID: errType, message: errMsg} -} - -// IsProtocolError to assert if the err is ProtocolError which has TypeId() func -func IsProtocolError(err error) bool { - _, ok := err.(ProtocolError) - return ok -} diff --git a/internal/bthrift/unknown.go b/internal/bthrift/unknown.go deleted file mode 100644 index cea1de81..00000000 --- a/internal/bthrift/unknown.go +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright 2023 CloudWeGo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bthrift - -import ( - "errors" - "fmt" - "reflect" - - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/thriftgo/generator/golang/extension/unknown" -) - -// UnknownField is used to describe an unknown field. -type UnknownField struct { - Name string - ID int16 - Type int - KeyType int - ValType int - Value interface{} -} - -// GetUnknownFields deserialize unknownFields stored in v to a list of *UnknownFields. -func GetUnknownFields(v interface{}) (fields []UnknownField, err error) { - var buf []byte - rv := reflect.ValueOf(v) - if rv.Kind() == reflect.Ptr && !rv.IsNil() { - rv = rv.Elem() - } - if rv.Kind() != reflect.Struct { - return nil, fmt.Errorf("%T is not a struct type", v) - } - if unknownField := rv.FieldByName("_unknownFields"); !unknownField.IsValid() { - return nil, fmt.Errorf("%T has no field named '_unknownFields'", v) - } else { - buf = unknownField.Bytes() - } - return ConvertUnknownFields(buf) -} - -// ConvertUnknownFields converts buf to deserialized unknown fields. -func ConvertUnknownFields(buf unknown.Fields) (fields []UnknownField, err error) { - if len(buf) == 0 { - return nil, errors.New("_unknownFields is empty") - } - var offset int - var l int - var name string - var fieldTypeId thrift.TType - var fieldId int16 - var f UnknownField - for { - if offset == len(buf) { - return - } - name, fieldTypeId, fieldId, l, err = Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - return nil, fmt.Errorf("read field %d begin error: %v", fieldId, err) - } - l, err = readUnknownField(&f, buf[offset:], name, fieldTypeId, fieldId) - offset += l - if err != nil { - return nil, fmt.Errorf("read unknown field %d error: %v", fieldId, err) - } - fields = append(fields, f) - } -} - -func readUnknownField(f *UnknownField, buf []byte, name string, fieldType thrift.TType, id int16) (length int, err error) { - var size int - var l int - f.Name = name - f.ID = id - f.Type = int(fieldType) - switch fieldType { - case thrift.BOOL: - f.Value, l, err = Binary.ReadBool(buf[length:]) - length += l - case thrift.BYTE: - f.Value, l, err = Binary.ReadByte(buf[length:]) - length += l - case thrift.I16: - f.Value, l, err = Binary.ReadI16(buf[length:]) - length += l - case thrift.I32: - f.Value, l, err = Binary.ReadI32(buf[length:]) - length += l - case thrift.I64: - f.Value, l, err = Binary.ReadI64(buf[length:]) - length += l - case thrift.DOUBLE: - f.Value, l, err = Binary.ReadDouble(buf[length:]) - length += l - case thrift.STRING: - f.Value, l, err = Binary.ReadString(buf[length:]) - length += l - case thrift.SET: - var ttype thrift.TType - ttype, size, l, err = Binary.ReadSetBegin(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read set begin error: %w", err) - } - f.ValType = int(ttype) - set := make([]UnknownField, size) - for i := 0; i < size; i++ { - l, err2 := readUnknownField(&set[i], buf[length:], "", thrift.TType(f.ValType), int16(i)) - length += l - if err2 != nil { - return length, fmt.Errorf("read set elem error: %w", err2) - } - } - l, err = Binary.ReadSetEnd(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read set end error: %w", err) - } - f.Value = set - case thrift.LIST: - var ttype thrift.TType - ttype, size, l, err = Binary.ReadListBegin(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read list begin error: %w", err) - } - f.ValType = int(ttype) - list := make([]UnknownField, size) - for i := 0; i < size; i++ { - l, err2 := readUnknownField(&list[i], buf[length:], "", thrift.TType(f.ValType), int16(i)) - length += l - if err2 != nil { - return length, fmt.Errorf("read list elem error: %w", err2) - } - } - l, err = Binary.ReadListEnd(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read list end error: %w", err) - } - f.Value = list - case thrift.MAP: - var kttype, vttype thrift.TType - kttype, vttype, size, l, err = Binary.ReadMapBegin(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read map begin error: %w", err) - } - f.KeyType = int(kttype) - f.ValType = int(vttype) - flatMap := make([]UnknownField, size*2) - for i := 0; i < size; i++ { - l, err2 := readUnknownField(&flatMap[2*i], buf[length:], "", thrift.TType(f.KeyType), int16(i)) - length += l - if err2 != nil { - return length, fmt.Errorf("read map key error: %w", err2) - } - l, err2 = readUnknownField(&flatMap[2*i+1], buf[length:], "", thrift.TType(f.ValType), int16(i)) - length += l - if err2 != nil { - return length, fmt.Errorf("read map value error: %w", err2) - } - } - l, err = Binary.ReadMapEnd(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read map end error: %w", err) - } - f.Value = flatMap - case thrift.STRUCT: - _, l, err = Binary.ReadStructBegin(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read struct begin error: %w", err) - } - var field UnknownField - var fields []UnknownField - for { - name, fieldTypeID, fieldID, l, err := Binary.ReadFieldBegin(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read field begin error: %w", err) - } - if fieldTypeID == thrift.STOP { - break - } - l, err = readUnknownField(&field, buf[length:], name, fieldTypeID, fieldID) - length += l - if err != nil { - return length, fmt.Errorf("read struct field error: %w", err) - } - l, err = Binary.ReadFieldEnd(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read field end error: %w", err) - } - fields = append(fields, field) - } - l, err = Binary.ReadStructEnd(buf[length:]) - length += l - if err != nil { - return length, fmt.Errorf("read struct end error: %w", err) - } - f.Value = fields - default: - return length, fmt.Errorf("unknown data type %d", f.Type) - } - if err != nil { - return length, err - } - return -} - -// UnknownFieldsLength returns the length of fs. -func UnknownFieldsLength(fs []UnknownField) (int, error) { - l := 0 - for _, f := range fs { - l += Binary.FieldBeginLength(f.Name, thrift.TType(f.Type), f.ID) - ll, err := unknownFieldLength(&f) - l += ll - if err != nil { - return l, err - } - l += Binary.FieldEndLength() - } - return l, nil -} - -func unknownFieldLength(f *UnknownField) (length int, err error) { - // use constants to avoid some type assert - switch f.Type { - case unknown.TBool: - length += Binary.BoolLength(false) - case unknown.TByte: - length += Binary.ByteLength(0) - case unknown.TDouble: - length += Binary.DoubleLength(0) - case unknown.TI16: - length += Binary.I16Length(0) - case unknown.TI32: - length += Binary.I32Length(0) - case unknown.TI64: - length += Binary.I64Length(0) - case unknown.TString: - length += Binary.StringLength(f.Value.(string)) - case unknown.TSet: - vs := f.Value.([]UnknownField) - length += Binary.SetBeginLength(thrift.TType(f.ValType), len(vs)) - for _, v := range vs { - l, err := unknownFieldLength(&v) - length += l - if err != nil { - return length, err - } - } - length += Binary.SetEndLength() - case unknown.TList: - vs := f.Value.([]UnknownField) - length += Binary.ListBeginLength(thrift.TType(f.ValType), len(vs)) - for _, v := range vs { - l, err := unknownFieldLength(&v) - length += l - if err != nil { - return length, err - } - } - length += Binary.ListEndLength() - case unknown.TMap: - kvs := f.Value.([]UnknownField) - length += Binary.MapBeginLength(thrift.TType(f.KeyType), thrift.TType(f.ValType), len(kvs)/2) - for i := 0; i < len(kvs); i += 2 { - l, err := unknownFieldLength(&kvs[i]) - length += l - if err != nil { - return length, err - } - l, err = unknownFieldLength(&kvs[i+1]) - length += l - if err != nil { - return length, err - } - } - length += Binary.MapEndLength() - case unknown.TStruct: - fs := f.Value.([]UnknownField) - length += Binary.StructBeginLength(f.Name) - l, err := UnknownFieldsLength(fs) - length += l - if err != nil { - return length, err - } - length += Binary.FieldStopLength() - length += Binary.StructEndLength() - default: - return length, fmt.Errorf("unknown data type %d", f.Type) - } - return -} - -// WriteUnknownFields writes fs into buf, and return written offset of the buf. -func WriteUnknownFields(buf []byte, fs []UnknownField) (offset int, err error) { - for _, f := range fs { - offset += Binary.WriteFieldBegin(buf[offset:], f.Name, thrift.TType(f.Type), f.ID) - l, err := writeUnknownField(buf[offset:], &f) - offset += l - if err != nil { - return offset, err - } - offset += Binary.WriteFieldEnd(buf[offset:]) - } - return offset, nil -} - -func writeUnknownField(buf []byte, f *UnknownField) (offset int, err error) { - switch f.Type { - case unknown.TBool: - offset += Binary.WriteBool(buf, f.Value.(bool)) - case unknown.TByte: - offset += Binary.WriteByte(buf, f.Value.(int8)) - case unknown.TDouble: - offset += Binary.WriteDouble(buf, f.Value.(float64)) - case unknown.TI16: - offset += Binary.WriteI16(buf, f.Value.(int16)) - case unknown.TI32: - offset += Binary.WriteI32(buf, f.Value.(int32)) - case unknown.TI64: - offset += Binary.WriteI64(buf, f.Value.(int64)) - case unknown.TString: - offset += Binary.WriteString(buf, f.Value.(string)) - case unknown.TSet: - vs := f.Value.([]UnknownField) - offset += Binary.WriteSetBegin(buf, thrift.TType(f.ValType), len(vs)) - for _, v := range vs { - l, err := writeUnknownField(buf[offset:], &v) - offset += l - if err != nil { - return offset, err - } - } - offset += Binary.WriteSetEnd(buf[offset:]) - case unknown.TList: - vs := f.Value.([]UnknownField) - offset += Binary.WriteListBegin(buf, thrift.TType(f.ValType), len(vs)) - for _, v := range vs { - l, err := writeUnknownField(buf[offset:], &v) - offset += l - if err != nil { - return offset, err - } - } - offset += Binary.WriteListEnd(buf[offset:]) - case unknown.TMap: - kvs := f.Value.([]UnknownField) - offset += Binary.WriteMapBegin(buf, thrift.TType(f.KeyType), thrift.TType(f.ValType), len(kvs)/2) - for i := 0; i < len(kvs); i += 2 { - l, err := writeUnknownField(buf[offset:], &kvs[i]) - offset += l - if err != nil { - return offset, err - } - l, err = writeUnknownField(buf[offset:], &kvs[i+1]) - offset += l - if err != nil { - return offset, err - } - } - offset += Binary.WriteMapEnd(buf[offset:]) - case unknown.TStruct: - fs := f.Value.([]UnknownField) - offset += Binary.WriteStructBegin(buf, f.Name) - l, err := WriteUnknownFields(buf[offset:], fs) - offset += l - if err != nil { - return offset, err - } - offset += Binary.WriteFieldStop(buf[offset:]) - offset += Binary.WriteStructEnd(buf[offset:]) - default: - return offset, fmt.Errorf("unknown data type %d", f.Type) - } - return -} diff --git a/proto/generic/value_test.go b/proto/generic/value_test.go index 39ac877a..f87d3eff 100644 --- a/proto/generic/value_test.go +++ b/proto/generic/value_test.go @@ -25,6 +25,10 @@ const ( exampleProtoPath = "../../testdata/data/example3_pb.bin" ) +func init() { + generateBinaryData() // for generating exampleProtoPath +} + // parse protofile to get MessageDescriptor func getExample3Desc() *proto.TypeDescriptor { includeDirs := util_test.MustGitPath("testdata/idl/") // includeDirs is used to find the include files. diff --git a/testdata/data/basic_example_pb.bin b/testdata/data/basic_example_pb.bin deleted file mode 100644 index 9a8903b61cbf82cbb080feadcb2f20c504311a44..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1246 zcma)5F^m#X5dAYB*p)+B5H2<*XGdXy;#Ed(wYM;KCYqp}ITGZOYrIIYWJ_W}wmT|A zNh}N{C5?pKHB{yr6DmVLK^JnJGf3w&%r*`XtU~REwc)1zm zXYi;dgm}V+@r)PG7rR&CCE%dG2%I>-nbIfxDq4+R2>9#!W;}wu~`9LH!3=!g&Vd=F*~D$Hev?~8|>mA=VUu6E6a(@N7Wnv$iJ zz+GKa^e(0Anbk=;&+DyJ&vMg!-EiL|(W>-u)3~9-6Z*}!hapDekaxroojCWb#;A0m zBX*Ums)BZnFhS9mYL4)RN}3CK;b}*?x`?Qsu19FcGD3_osfiT>8E=f1<`t7wy2)y> zGfz9H*kWSS`E91E1ld=%2hQJUv4NqExj*wg3#{bp`KDh+Ehn< f#SN(|sVV49xvKOJq!u%f>vsy|T+79OqYi%oJE*9x diff --git a/testdata/data/example3_pb.bin b/testdata/data/example3_pb.bin deleted file mode 100644 index c293f2f5..00000000 --- a/testdata/data/example3_pb.bin +++ /dev/null @@ -1,55 +0,0 @@ - -hello{{ {(1L6@: hello_innerB J -m1aaaJ -m2bbbJ -m3cccJ -m4dddR baaabbbbbcccbdddjr u32aar u32bbr u32ccr u32ddz u64aaz u64bbz u64ccz u64dd 64aaa 64bbb 64ccc 64dddTP -logIdcalleraddr"client*env2 -1aaaa2 -2abbb2 -3accc2 -4addd_[ -logId2caller2addr2"client2*env22 - -1aaaa22 - -2abbb22 - -3accc22 - -4addd2P -logIdcalleraddr"client*env2 -1aaaa2 -2abbb2 -3accc2 -4addd[ -logId2caller2addr2"client2*env22 - -1aaaa22 - -2abbb22 - -3accc22 - -4addd2U -1P -logIdcalleraddr"client*env2 -4addd2 -1aaaa2 -2abbb2 -3accc` -2[ -logId2caller2addr2"client2*env22 - -1aaaa22 - -2abbb22 - -3accc22 - -4addd211122233344516P -logIdcalleraddr"client*env2 -1baaa2 -2bbbb2 -3bccc2 -4bddd \ No newline at end of file diff --git a/testdata/gen.sh b/testdata/gen.sh new file mode 100755 index 00000000..db58ebf4 --- /dev/null +++ b/testdata/gen.sh @@ -0,0 +1,28 @@ +#! /bin/bash + + +# please install fastcodec version of thriftgo +# if the `feat-fastcodec` branch doesn't exist try to use `main` branch +# the feature is only for internal use now, but it will be released in the future when it's stable. +# go install github.com/cloudwego/thriftgo@feat-fastcodec + + +IDL_LIST=( +"./idl/base.thrift" +"./idl/baseline.thrift" +"./idl/example.thrift" +"./idl/example2.thrift" +"./idl/example3.thrift" +#"./idl/example4.thrift" # only used by thrift.NewDescritorFromPath +"./idl/null.thrift" +"./idl/ref.thrift" +"./idl/skip.thrift" +"./idl/deep/deep.ref.thrift" +) +THRIFTGO_ARGS="-g fastgo:no_default_serdes=true,package_prefix=github.com/cloudwego/dynamicgo/testdata/kitex_gen -o=./kitex_gen" + +for idl in "${IDL_LIST[@]}" +do + echo "generating" $idl + thriftgo $THRIFTGO_ARGS $idl +done diff --git a/testdata/idl/example.thrift b/testdata/idl/example.thrift index bc054d44..6e3beb41 100644 --- a/testdata/idl/example.thrift +++ b/testdata/idl/example.thrift @@ -1,6 +1,5 @@ include "base.thrift" include "deep/deep.ref.thrift" -include "example.thrift" include "ref.thrift" namespace go example @@ -66,4 +65,4 @@ service ExampleService { void Void(1: string msg) void ExampleToSnakeCase(1: ExampleToSnakeCase req) (agw.to_snake = "") ExampleDefaultValue ExampleDefaultValue(1: ExampleDefaultValue req) -} \ No newline at end of file +} diff --git a/testdata/idl/ref.thrift b/testdata/idl/ref.thrift index a517d95c..0e2b1b85 100644 --- a/testdata/idl/ref.thrift +++ b/testdata/idl/ref.thrift @@ -1,5 +1,3 @@ -include "example.thrift" - namespace go ref enum FOO { diff --git a/testdata/kitex_gen/base/base.go b/testdata/kitex_gen/base/base.go index be0dec6b..02b8db92 100644 --- a/testdata/kitex_gen/base/base.go +++ b/testdata/kitex_gen/base/base.go @@ -1,11 +1,9 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package base import ( "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" ) type TrafficEnv struct { @@ -21,6 +19,11 @@ func NewTrafficEnv() *TrafficEnv { } } +func (p *TrafficEnv) InitDefault() { + p.Open = false + p.Env = "" +} + func (p *TrafficEnv) GetOpen() (v bool) { return p.Open } @@ -28,171 +31,6 @@ func (p *TrafficEnv) GetOpen() (v bool) { func (p *TrafficEnv) GetEnv() (v string) { return p.Env } -func (p *TrafficEnv) SetOpen(val bool) { - p.Open = val -} -func (p *TrafficEnv) SetEnv(val string) { - p.Env = val -} - -var fieldIDToName_TrafficEnv = map[int16]string{ - 1: "Open", - 2: "Env", -} - -func (p *TrafficEnv) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TrafficEnv) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Open = v - } - return nil -} - -func (p *TrafficEnv) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Env = v - } - return nil -} - -func (p *TrafficEnv) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TrafficEnv"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *TrafficEnv) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Open", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Open); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *TrafficEnv) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Env", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Env); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} func (p *TrafficEnv) String() string { if p == nil { @@ -201,34 +39,9 @@ func (p *TrafficEnv) String() string { return fmt.Sprintf("TrafficEnv(%+v)", *p) } -func (p *TrafficEnv) DeepEqual(ano *TrafficEnv) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Open) { - return false - } - if !p.Field2DeepEqual(ano.Env) { - return false - } - return true -} - -func (p *TrafficEnv) Field1DeepEqual(src bool) bool { - - if p.Open != src { - return false - } - return true -} -func (p *TrafficEnv) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Env, src) != 0 { - return false - } - return true +var fieldIDToName_TrafficEnv = map[int16]string{ + 1: "Open", + 2: "Env", } type Base struct { @@ -236,8 +49,8 @@ type Base struct { Caller string `thrift:"Caller,2" json:"Caller"` Addr string `thrift:"Addr,3" json:"Addr"` Client string `thrift:"Client,4" json:"Client"` - TrafficEnv *TrafficEnv `thrift:"TrafficEnv,5" json:"TrafficEnv,omitempty"` - Extra map[string]string `thrift:"Extra,6" json:"Extra,omitempty"` + TrafficEnv *TrafficEnv `thrift:"TrafficEnv,5,optional" json:"TrafficEnv,omitempty"` + Extra map[string]string `thrift:"Extra,6,optional" json:"Extra,omitempty"` } func NewBase() *Base { @@ -250,6 +63,13 @@ func NewBase() *Base { } } +func (p *Base) InitDefault() { + p.LogID = "" + p.Caller = "" + p.Addr = "" + p.Client = "" +} + func (p *Base) GetLogID() (v string) { return p.LogID } @@ -283,33 +103,6 @@ func (p *Base) GetExtra() (v map[string]string) { } return p.Extra } -func (p *Base) SetLogID(val string) { - p.LogID = val -} -func (p *Base) SetCaller(val string) { - p.Caller = val -} -func (p *Base) SetAddr(val string) { - p.Addr = val -} -func (p *Base) SetClient(val string) { - p.Client = val -} -func (p *Base) SetTrafficEnv(val *TrafficEnv) { - p.TrafficEnv = val -} -func (p *Base) SetExtra(val map[string]string) { - p.Extra = val -} - -var fieldIDToName_Base = map[int16]string{ - 1: "LogID", - 2: "Caller", - 3: "Addr", - 4: "Client", - 5: "TrafficEnv", - 6: "Extra", -} func (p *Base) IsSetTrafficEnv() bool { return p.TrafficEnv != nil @@ -319,356 +112,6 @@ func (p *Base) IsSetExtra() bool { return p.Extra != nil } -func (p *Base) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Base) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.LogID = v - } - return nil -} - -func (p *Base) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Caller = v - } - return nil -} - -func (p *Base) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Addr = v - } - return nil -} - -func (p *Base) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Client = v - } - return nil -} - -func (p *Base) ReadField5(iprot thrift.TProtocol) error { - p.TrafficEnv = NewTrafficEnv() - if err := p.TrafficEnv.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *Base) ReadField6(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Extra[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Base) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Base"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Base) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("LogID", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.LogID); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Base) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Caller", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Caller); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *Base) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Addr", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Addr); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *Base) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Client", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Client); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *Base) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetTrafficEnv() { - if err = oprot.WriteFieldBegin("TrafficEnv", thrift.STRUCT, 5); err != nil { - goto WriteFieldBeginError - } - if err := p.TrafficEnv.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *Base) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetExtra() { - if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil { - return err - } - for k, v := range p.Extra { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - func (p *Base) String() string { if p == nil { return "" @@ -676,86 +119,19 @@ func (p *Base) String() string { return fmt.Sprintf("Base(%+v)", *p) } -func (p *Base) DeepEqual(ano *Base) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.LogID) { - return false - } - if !p.Field2DeepEqual(ano.Caller) { - return false - } - if !p.Field3DeepEqual(ano.Addr) { - return false - } - if !p.Field4DeepEqual(ano.Client) { - return false - } - if !p.Field5DeepEqual(ano.TrafficEnv) { - return false - } - if !p.Field6DeepEqual(ano.Extra) { - return false - } - return true -} - -func (p *Base) Field1DeepEqual(src string) bool { - - if strings.Compare(p.LogID, src) != 0 { - return false - } - return true -} -func (p *Base) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Caller, src) != 0 { - return false - } - return true -} -func (p *Base) Field3DeepEqual(src string) bool { - - if strings.Compare(p.Addr, src) != 0 { - return false - } - return true -} -func (p *Base) Field4DeepEqual(src string) bool { - - if strings.Compare(p.Client, src) != 0 { - return false - } - return true -} -func (p *Base) Field5DeepEqual(src *TrafficEnv) bool { - - if !p.TrafficEnv.DeepEqual(src) { - return false - } - return true -} -func (p *Base) Field6DeepEqual(src map[string]string) bool { - - if len(p.Extra) != len(src) { - return false - } - for k, v := range p.Extra { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +var fieldIDToName_Base = map[int16]string{ + 1: "LogID", + 2: "Caller", + 3: "Addr", + 4: "Client", + 5: "TrafficEnv", + 6: "Extra", } type BaseResp struct { StatusMessage string `thrift:"StatusMessage,1" json:"StatusMessage"` StatusCode int32 `thrift:"StatusCode,2" json:"StatusCode"` - Extra map[string]string `thrift:"Extra,3" json:"Extra,omitempty"` + Extra map[string]string `thrift:"Extra,3,optional" json:"Extra,omitempty"` } func NewBaseResp() *BaseResp { @@ -766,6 +142,11 @@ func NewBaseResp() *BaseResp { } } +func (p *BaseResp) InitDefault() { + p.StatusMessage = "" + p.StatusCode = 0 +} + func (p *BaseResp) GetStatusMessage() (v string) { return p.StatusMessage } @@ -782,255 +163,11 @@ func (p *BaseResp) GetExtra() (v map[string]string) { } return p.Extra } -func (p *BaseResp) SetStatusMessage(val string) { - p.StatusMessage = val -} -func (p *BaseResp) SetStatusCode(val int32) { - p.StatusCode = val -} -func (p *BaseResp) SetExtra(val map[string]string) { - p.Extra = val -} - -var fieldIDToName_BaseResp = map[int16]string{ - 1: "StatusMessage", - 2: "StatusCode", - 3: "Extra", -} func (p *BaseResp) IsSetExtra() bool { return p.Extra != nil } -func (p *BaseResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.MAP { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.StatusMessage = v - } - return nil -} - -func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.StatusCode = v - } - return nil -} - -func (p *BaseResp) ReadField3(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Extra[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("BaseResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaseResp) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StatusMessage", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.StatusMessage); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaseResp) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StatusCode", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.StatusCode); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *BaseResp) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetExtra() { - if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil { - return err - } - for k, v := range p.Extra { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - func (p *BaseResp) String() string { if p == nil { return "" @@ -1038,48 +175,8 @@ func (p *BaseResp) String() string { return fmt.Sprintf("BaseResp(%+v)", *p) } -func (p *BaseResp) DeepEqual(ano *BaseResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.StatusMessage) { - return false - } - if !p.Field2DeepEqual(ano.StatusCode) { - return false - } - if !p.Field3DeepEqual(ano.Extra) { - return false - } - return true -} - -func (p *BaseResp) Field1DeepEqual(src string) bool { - - if strings.Compare(p.StatusMessage, src) != 0 { - return false - } - return true -} -func (p *BaseResp) Field2DeepEqual(src int32) bool { - - if p.StatusCode != src { - return false - } - return true -} -func (p *BaseResp) Field3DeepEqual(src map[string]string) bool { - - if len(p.Extra) != len(src) { - return false - } - for k, v := range p.Extra { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +var fieldIDToName_BaseResp = map[int16]string{ + 1: "StatusMessage", + 2: "StatusCode", + 3: "Extra", } diff --git a/testdata/kitex_gen/base/k-base.go b/testdata/kitex_gen/base/k-base.go index f324acc7..249c66af 100644 --- a/testdata/kitex_gen/base/k-base.go +++ b/testdata/kitex_gen/base/k-base.go @@ -1,885 +1,416 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package base import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" + "unsafe" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) +func (p *TrafficEnv) BLength() int { + if p == nil { + return 1 + } + off := 0 -func (p *TrafficEnv) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError + // p.Open ID:1 thrift.BOOL + off += 3 + off += 1 + + // p.Env ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Env) + return off + 1 +} + +func (p *TrafficEnv) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *TrafficEnv) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } + off := 0 + + // p.Open ID:1 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Open))) + off++ + + // p.Env ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Env) + + b[off] = 0 + return off + 1 +} +func (p *TrafficEnv) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x102: // p.Open ID:1 thrift.BOOL + p.Open, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20b: // p.Env ID:2 thrift.STRING + p.Env, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_TrafficEnv[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *TrafficEnv) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Open = v - +func (p *Base) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *TrafficEnv) FastReadField2(buf []byte) (int, error) { - offset := 0 + // p.LogID ID:1 thrift.STRING + off += 3 + off += 4 + len(p.LogID) - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Caller ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Caller) - p.Env = v + // p.Addr ID:3 thrift.STRING + off += 3 + off += 4 + len(p.Addr) - } - return offset, nil -} - -// for compatibility -func (p *TrafficEnv) FastWrite(buf []byte) int { - return 0 -} + // p.Client ID:4 thrift.STRING + off += 3 + off += 4 + len(p.Client) -func (p *TrafficEnv) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TrafficEnv") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) + // p.TrafficEnv ID:5 thrift.STRUCT + if p.TrafficEnv != nil { + off += 3 + off += p.TrafficEnv.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} -func (p *TrafficEnv) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TrafficEnv") - if p != nil { - l += p.field1Length() - l += p.field2Length() + // p.Extra ID:6 thrift.MAP + if p.Extra != nil { + off += 3 + off += 6 + for k, v := range p.Extra { + off += 4 + len(k) + off += 4 + len(v) + } + } + return off + 1 +} + +func (p *Base) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *Base) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.LogID ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.LogID) + + // p.Caller ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Caller) + + // p.Addr ID:3 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Addr) + + // p.Client ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Client) + + // p.TrafficEnv ID:5 thrift.STRUCT + if p.TrafficEnv != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += p.TrafficEnv.FastWriteNocopy(b[off:], w) + } + + // p.Extra ID:6 thrift.MAP + if p.Extra != nil { + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Extra))) + off += 6 + for k, v := range p.Extra { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *TrafficEnv) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Open", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Open) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TrafficEnv) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Env", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Env) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TrafficEnv) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Open", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Open) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *TrafficEnv) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Env", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Env) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *Base) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Base) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.LogID ID:1 thrift.STRING + p.LogID, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20b: // p.Caller ID:2 thrift.STRING + p.Caller, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30b: // p.Addr ID:3 thrift.STRING + p.Addr, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x40b: // p.Client ID:4 thrift.STRING + p.Client, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x50c: // p.TrafficEnv ID:5 thrift.STRUCT + p.TrafficEnv = NewTrafficEnv() + l, err = p.TrafficEnv.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField6(buf[offset:]) - offset += l + case 0x60d: // p.Extra ID:6 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Extra = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.Extra[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Base[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Base) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.LogID = v - - } - return offset, nil -} - -func (p *Base) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Caller = v - - } - return offset, nil -} - -func (p *Base) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Addr = v - - } - return offset, nil -} - -func (p *Base) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Client = v - - } - return offset, nil -} - -func (p *Base) FastReadField5(buf []byte) (int, error) { - offset := 0 - p.TrafficEnv = NewTrafficEnv() - if l, err := p.TrafficEnv.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Base) FastReadField6(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err +func (p *BaseResp) BLength() int { + if p == nil { + return 1 } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - _key = v + // p.StatusMessage ID:1 thrift.STRING + off += 3 + off += 4 + len(p.StatusMessage) - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v + // p.StatusCode ID:2 thrift.I32 + off += 3 + off += 4 + // p.Extra ID:3 thrift.MAP + if p.Extra != nil { + off += 3 + off += 6 + for k, v := range p.Extra { + off += 4 + len(k) + off += 4 + len(v) } - - p.Extra[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l } - return offset, nil + return off + 1 } -// for compatibility -func (p *Base) FastWrite(buf []byte) int { - return 0 -} +func (p *BaseResp) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *Base) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Base") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) +func (p *BaseResp) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *Base) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Base") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + // p.StatusMessage ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.StatusMessage) -func (p *Base) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "LogID", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.LogID) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.StatusCode ID:2 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.StatusCode)) + off += 4 -func (p *Base) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Caller", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Caller) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Addr", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Addr) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Client", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Client) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetTrafficEnv() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "TrafficEnv", thrift.STRUCT, 5) - offset += p.TrafficEnv.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *Base) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetExtra() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 6) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra)) + // p.Extra ID:3 thrift.MAP + if p.Extra != nil { + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Extra))) + off += 6 for k, v := range p.Extra { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *Base) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("LogID", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.LogID) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Caller", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Caller) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Addr", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Addr) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Client", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Client) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field5Length() int { - l := 0 - if p.IsSetTrafficEnv() { - l += bthrift.Binary.FieldBeginLength("TrafficEnv", thrift.STRUCT, 5) - l += p.TrafficEnv.BLength() - l += bthrift.Binary.FieldEndLength() } - return l -} - -func (p *Base) field6Length() int { - l := 0 - if p.IsSetExtra() { - l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 6) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - l += bthrift.Binary.StringLengthNocopy(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - } - return l + b[off] = 0 + return off + 1 } -func (p *BaseResp) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaseResp) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.StatusMessage ID:1 thrift.STRING + p.StatusMessage, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x208: // p.StatusCode ID:2 thrift.I32 + p.StatusCode, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30d: // p.Extra ID:3 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField3(buf[offset:]) - offset += l + p.Extra = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.Extra[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaseResp[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaseResp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.StatusMessage = v - - } - return offset, nil -} - -func (p *BaseResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.StatusCode = v - - } - return offset, nil -} - -func (p *BaseResp) FastReadField3(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Extra[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *BaseResp) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaseResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BaseResp") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("BaseResp") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaseResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusMessage", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StatusMessage) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusCode", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], p.StatusCode) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetExtra() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 3) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaseResp) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StatusMessage", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.StatusMessage) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaseResp) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StatusCode", thrift.I32, 2) - l += bthrift.Binary.I32Length(p.StatusCode) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaseResp) field3Length() int { - l := 0 - if p.IsSetExtra() { - l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 3) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - l += bthrift.Binary.StringLengthNocopy(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - } - return l + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/baseline/baseline.go b/testdata/kitex_gen/baseline/baseline.go index 78c0dd26..062c1fdc 100644 --- a/testdata/kitex_gen/baseline/baseline.go +++ b/testdata/kitex_gen/baseline/baseline.go @@ -1,13 +1,10 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package baseline import ( - "bytes" "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" ) type Simple struct { @@ -23,6 +20,9 @@ func NewSimple() *Simple { return &Simple{} } +func (p *Simple) InitDefault() { +} + func (p *Simple) GetByteField() (v int8) { return p.ByteField } @@ -46,23 +46,12 @@ func (p *Simple) GetStringField() (v string) { func (p *Simple) GetBinaryField() (v []byte) { return p.BinaryField } -func (p *Simple) SetByteField(val int8) { - p.ByteField = val -} -func (p *Simple) SetI64Field(val int64) { - p.I64Field = val -} -func (p *Simple) SetDoubleField(val float64) { - p.DoubleField = val -} -func (p *Simple) SetI32Field(val int32) { - p.I32Field = val -} -func (p *Simple) SetStringField(val string) { - p.StringField = val -} -func (p *Simple) SetBinaryField(val []byte) { - p.BinaryField = val + +func (p *Simple) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Simple(%+v)", *p) } var fieldIDToName_Simple = map[int16]string{ @@ -74,397 +63,6 @@ var fieldIDToName_Simple = map[int16]string{ 6: "BinaryField", } -func (p *Simple) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I64 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRING { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Simple[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Simple) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.ByteField = v - } - return nil -} - -func (p *Simple) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64Field = v - } - return nil -} - -func (p *Simple) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.DoubleField = v - } - return nil -} - -func (p *Simple) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32Field = v - } - return nil -} - -func (p *Simple) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.StringField = v - } - return nil -} - -func (p *Simple) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.BinaryField = []byte(v) - } - return nil -} - -func (p *Simple) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Simple"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Simple) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ByteField", thrift.BYTE, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.ByteField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Simple) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64Field", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64Field); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *Simple) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("DoubleField", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.DoubleField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *Simple) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32Field", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32Field); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *Simple) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StringField", thrift.STRING, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.StringField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *Simple) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BinaryField", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.BinaryField)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *Simple) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Simple(%+v)", *p) -} - -func (p *Simple) DeepEqual(ano *Simple) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.ByteField) { - return false - } - if !p.Field2DeepEqual(ano.I64Field) { - return false - } - if !p.Field3DeepEqual(ano.DoubleField) { - return false - } - if !p.Field4DeepEqual(ano.I32Field) { - return false - } - if !p.Field5DeepEqual(ano.StringField) { - return false - } - if !p.Field6DeepEqual(ano.BinaryField) { - return false - } - return true -} - -func (p *Simple) Field1DeepEqual(src int8) bool { - - if p.ByteField != src { - return false - } - return true -} -func (p *Simple) Field2DeepEqual(src int64) bool { - - if p.I64Field != src { - return false - } - return true -} -func (p *Simple) Field3DeepEqual(src float64) bool { - - if p.DoubleField != src { - return false - } - return true -} -func (p *Simple) Field4DeepEqual(src int32) bool { - - if p.I32Field != src { - return false - } - return true -} -func (p *Simple) Field5DeepEqual(src string) bool { - - if strings.Compare(p.StringField, src) != 0 { - return false - } - return true -} -func (p *Simple) Field6DeepEqual(src []byte) bool { - - if bytes.Compare(p.BinaryField, src) != 0 { - return false - } - return true -} - type PartialSimple struct { ByteField int8 `thrift:"ByteField,1" json:"ByteField"` DoubleField float64 `thrift:"DoubleField,3" json:"DoubleField"` @@ -475,6 +73,9 @@ func NewPartialSimple() *PartialSimple { return &PartialSimple{} } +func (p *PartialSimple) InitDefault() { +} + func (p *PartialSimple) GetByteField() (v int8) { return p.ByteField } @@ -486,215 +87,6 @@ func (p *PartialSimple) GetDoubleField() (v float64) { func (p *PartialSimple) GetBinaryField() (v []byte) { return p.BinaryField } -func (p *PartialSimple) SetByteField(val int8) { - p.ByteField = val -} -func (p *PartialSimple) SetDoubleField(val float64) { - p.DoubleField = val -} -func (p *PartialSimple) SetBinaryField(val []byte) { - p.BinaryField = val -} - -var fieldIDToName_PartialSimple = map[int16]string{ - 1: "ByteField", - 3: "DoubleField", - 6: "BinaryField", -} - -func (p *PartialSimple) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialSimple) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.ByteField = v - } - return nil -} - -func (p *PartialSimple) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.DoubleField = v - } - return nil -} - -func (p *PartialSimple) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.BinaryField = []byte(v) - } - return nil -} - -func (p *PartialSimple) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimple"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PartialSimple) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ByteField", thrift.BYTE, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.ByteField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *PartialSimple) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("DoubleField", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.DoubleField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *PartialSimple) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BinaryField", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.BinaryField)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} func (p *PartialSimple) String() string { if p == nil { @@ -703,44 +95,10 @@ func (p *PartialSimple) String() string { return fmt.Sprintf("PartialSimple(%+v)", *p) } -func (p *PartialSimple) DeepEqual(ano *PartialSimple) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.ByteField) { - return false - } - if !p.Field3DeepEqual(ano.DoubleField) { - return false - } - if !p.Field6DeepEqual(ano.BinaryField) { - return false - } - return true -} - -func (p *PartialSimple) Field1DeepEqual(src int8) bool { - - if p.ByteField != src { - return false - } - return true -} -func (p *PartialSimple) Field3DeepEqual(src float64) bool { - - if p.DoubleField != src { - return false - } - return true -} -func (p *PartialSimple) Field6DeepEqual(src []byte) bool { - - if bytes.Compare(p.BinaryField, src) != 0 { - return false - } - return true +var fieldIDToName_PartialSimple = map[int16]string{ + 1: "ByteField", + 3: "DoubleField", + 6: "BinaryField", } type Nesting struct { @@ -765,6 +123,9 @@ func NewNesting() *Nesting { return &Nesting{} } +func (p *Nesting) InitDefault() { +} + func (p *Nesting) GetString() (v string) { return p.String_ } @@ -829,50 +190,16 @@ func (p *Nesting) GetByte() (v int8) { func (p *Nesting) GetMapStringSimple() (v map[string]*Simple) { return p.MapStringSimple } -func (p *Nesting) SetString(val string) { - p.String_ = val -} -func (p *Nesting) SetListSimple(val []*Simple) { - p.ListSimple = val -} -func (p *Nesting) SetDouble(val float64) { - p.Double = val -} -func (p *Nesting) SetI32(val int32) { - p.I32 = val -} -func (p *Nesting) SetListI32(val []int32) { - p.ListI32 = val -} -func (p *Nesting) SetI64(val int64) { - p.I64 = val -} -func (p *Nesting) SetMapStringString(val map[string]string) { - p.MapStringString = val -} -func (p *Nesting) SetSimpleStruct(val *Simple) { - p.SimpleStruct = val -} -func (p *Nesting) SetMapI32I64(val map[int32]int64) { - p.MapI32I64 = val -} -func (p *Nesting) SetListString(val []string) { - p.ListString = val -} -func (p *Nesting) SetBinary(val []byte) { - p.Binary = val -} -func (p *Nesting) SetMapI64String(val map[int64]string) { - p.MapI64String = val -} -func (p *Nesting) SetListI64(val []int64) { - p.ListI64 = val -} -func (p *Nesting) SetByte(val int8) { - p.Byte = val + +func (p *Nesting) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil } -func (p *Nesting) SetMapStringSimple(val map[string]*Simple) { - p.MapStringSimple = val + +func (p *Nesting) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Nesting(%+v)", *p) } var fieldIDToName_Nesting = map[int16]string{ @@ -893,1472 +220,72 @@ var fieldIDToName_Nesting = map[int16]string{ 15: "MapStringSimple", } -func (p *Nesting) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil +type PartialNesting struct { + ListSimple []*PartialSimple `thrift:"ListSimple,2" json:"ListSimple"` + SimpleStruct *PartialSimple `thrift:"SimpleStruct,8" json:"SimpleStruct"` + MapStringSimple map[string]*PartialSimple `thrift:"MapStringSimple,15" json:"MapStringSimple"` } -func (p *Nesting) Read(iprot thrift.TProtocol) (err error) { +func NewPartialNesting() *PartialNesting { + return &PartialNesting{} +} - var fieldTypeId thrift.TType - var fieldId int16 +func (p *PartialNesting) InitDefault() { +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *PartialNesting) GetListSimple() (v []*PartialSimple) { + return p.ListSimple +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.LIST { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.LIST { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.MAP { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.MAP { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 10: - if fieldTypeId == thrift.LIST { - if err = p.ReadField10(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 11: - if fieldTypeId == thrift.STRING { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 12: - if fieldTypeId == thrift.MAP { - if err = p.ReadField12(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 13: - if fieldTypeId == thrift.LIST { - if err = p.ReadField13(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 14: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField14(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 15: - if fieldTypeId == thrift.MAP { - if err = p.ReadField15(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var PartialNesting_SimpleStruct_DEFAULT *PartialSimple - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v +func (p *PartialNesting) GetSimpleStruct() (v *PartialSimple) { + if !p.IsSetSimpleStruct() { + return PartialNesting_SimpleStruct_DEFAULT } - return nil + return p.SimpleStruct } -func (p *Nesting) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListSimple = make([]*Simple, 0, size) - for i := 0; i < size; i++ { - _elem := NewSimple() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListSimple = append(p.ListSimple, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil +func (p *PartialNesting) GetMapStringSimple() (v map[string]*PartialSimple) { + return p.MapStringSimple } -func (p *Nesting) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil +func (p *PartialNesting) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil } -func (p *Nesting) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32 = v +func (p *PartialNesting) String() string { + if p == nil { + return "" } - return nil + return fmt.Sprintf("PartialNesting(%+v)", *p) } -func (p *Nesting) ReadField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListI32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.ListI32 = append(p.ListI32, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil +var fieldIDToName_PartialNesting = map[int16]string{ + 2: "ListSimple", + 8: "SimpleStruct", + 15: "MapStringSimple", } -func (p *Nesting) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64 = v - } - return nil +type Nesting2 struct { + MapSimpleNesting map[*Simple]*Nesting `thrift:"MapSimpleNesting,1" json:"MapSimpleNesting"` + SimpleStruct *Simple `thrift:"SimpleStruct,2" json:"SimpleStruct"` + Byte int8 `thrift:"Byte,3" json:"Byte"` + Double float64 `thrift:"Double,4" json:"Double"` + ListNesting []*Nesting `thrift:"ListNesting,5" json:"ListNesting"` + I64 int64 `thrift:"I64,6" json:"I64"` + NestingStruct *Nesting `thrift:"NestingStruct,7" json:"NestingStruct"` + Binary []byte `thrift:"Binary,8" json:"Binary"` + String_ string `thrift:"String,9" json:"String"` + SetNesting []*Nesting `thrift:"SetNesting,10" json:"SetNesting"` + I32 int32 `thrift:"I32,11" json:"I32"` } -func (p *Nesting) ReadField7(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func NewNesting2() *Nesting2 { + return &Nesting2{} } -func (p *Nesting) ReadField8(iprot thrift.TProtocol) error { - p.SimpleStruct = NewSimple() - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *Nesting) ReadField9(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapI32I64 = make(map[int32]int64, size) - for i := 0; i < size; i++ { - var _key int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _key = v - } - - var _val int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _val = v - } - - p.MapI32I64[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListString = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.ListString = append(p.ListString, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) ReadField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil -} - -func (p *Nesting) ReadField12(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapI64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapI64String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) ReadField13(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListI64 = make([]int64, 0, size) - for i := 0; i < size; i++ { - var _elem int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _elem = v - } - - p.ListI64 = append(p.ListI64, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) ReadField14(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil -} - -func (p *Nesting) ReadField15(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringSimple = make(map[string]*Simple, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - _val := NewSimple() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapStringSimple[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField10(oprot); err != nil { - fieldId = 10 - goto WriteFieldError - } - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - if err = p.writeField12(oprot); err != nil { - fieldId = 12 - goto WriteFieldError - } - if err = p.writeField13(oprot); err != nil { - fieldId = 13 - goto WriteFieldError - } - if err = p.writeField14(oprot); err != nil { - fieldId = 14 - goto WriteFieldError - } - if err = p.writeField15(oprot); err != nil { - fieldId = 15 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Nesting) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Nesting) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { - return err - } - for _, v := range p.ListSimple { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *Nesting) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *Nesting) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *Nesting) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListI32", thrift.LIST, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I32, len(p.ListI32)); err != nil { - return err - } - for _, v := range p.ListI32 { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *Nesting) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *Nesting) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 7); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { - return err - } - for k, v := range p.MapStringString { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *Nesting) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { - goto WriteFieldBeginError - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *Nesting) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapI32I64", thrift.MAP, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I64, len(p.MapI32I64)); err != nil { - return err - } - for k, v := range p.MapI32I64 { - - if err := oprot.WriteI32(k); err != nil { - return err - } - - if err := oprot.WriteI64(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} - -func (p *Nesting) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListString", thrift.LIST, 10); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRING, len(p.ListString)); err != nil { - return err - } - for _, v := range p.ListString { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) -} - -func (p *Nesting) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) -} - -func (p *Nesting) writeField12(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapI64String", thrift.MAP, 12); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, len(p.MapI64String)); err != nil { - return err - } - for k, v := range p.MapI64String { - - if err := oprot.WriteI64(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) -} - -func (p *Nesting) writeField13(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListI64", thrift.LIST, 13); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I64, len(p.ListI64)); err != nil { - return err - } - for _, v := range p.ListI64 { - if err := oprot.WriteI64(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) -} - -func (p *Nesting) writeField14(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 14); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) -} - -func (p *Nesting) writeField15(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { - return err - } - for k, v := range p.MapStringSimple { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) -} - -func (p *Nesting) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Nesting(%+v)", *p) -} - -func (p *Nesting) DeepEqual(ano *Nesting) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.String_) { - return false - } - if !p.Field2DeepEqual(ano.ListSimple) { - return false - } - if !p.Field3DeepEqual(ano.Double) { - return false - } - if !p.Field4DeepEqual(ano.I32) { - return false - } - if !p.Field5DeepEqual(ano.ListI32) { - return false - } - if !p.Field6DeepEqual(ano.I64) { - return false - } - if !p.Field7DeepEqual(ano.MapStringString) { - return false - } - if !p.Field8DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field9DeepEqual(ano.MapI32I64) { - return false - } - if !p.Field10DeepEqual(ano.ListString) { - return false - } - if !p.Field11DeepEqual(ano.Binary) { - return false - } - if !p.Field12DeepEqual(ano.MapI64String) { - return false - } - if !p.Field13DeepEqual(ano.ListI64) { - return false - } - if !p.Field14DeepEqual(ano.Byte) { - return false - } - if !p.Field15DeepEqual(ano.MapStringSimple) { - return false - } - return true -} - -func (p *Nesting) Field1DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *Nesting) Field2DeepEqual(src []*Simple) bool { - - if len(p.ListSimple) != len(src) { - return false - } - for i, v := range p.ListSimple { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *Nesting) Field3DeepEqual(src float64) bool { - - if p.Double != src { - return false - } - return true -} -func (p *Nesting) Field4DeepEqual(src int32) bool { - - if p.I32 != src { - return false - } - return true -} -func (p *Nesting) Field5DeepEqual(src []int32) bool { - - if len(p.ListI32) != len(src) { - return false - } - for i, v := range p.ListI32 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field6DeepEqual(src int64) bool { - - if p.I64 != src { - return false - } - return true -} -func (p *Nesting) Field7DeepEqual(src map[string]string) bool { - - if len(p.MapStringString) != len(src) { - return false - } - for k, v := range p.MapStringString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field8DeepEqual(src *Simple) bool { - - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true -} -func (p *Nesting) Field9DeepEqual(src map[int32]int64) bool { - - if len(p.MapI32I64) != len(src) { - return false - } - for k, v := range p.MapI32I64 { - _src := src[k] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field10DeepEqual(src []string) bool { - - if len(p.ListString) != len(src) { - return false - } - for i, v := range p.ListString { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field11DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true -} -func (p *Nesting) Field12DeepEqual(src map[int64]string) bool { - - if len(p.MapI64String) != len(src) { - return false - } - for k, v := range p.MapI64String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field13DeepEqual(src []int64) bool { - - if len(p.ListI64) != len(src) { - return false - } - for i, v := range p.ListI64 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field14DeepEqual(src int8) bool { - - if p.Byte != src { - return false - } - return true -} -func (p *Nesting) Field15DeepEqual(src map[string]*Simple) bool { - - if len(p.MapStringSimple) != len(src) { - return false - } - for k, v := range p.MapStringSimple { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} - -type PartialNesting struct { - ListSimple []*PartialSimple `thrift:"ListSimple,2" json:"ListSimple"` - SimpleStruct *PartialSimple `thrift:"SimpleStruct,8" json:"SimpleStruct"` - MapStringSimple map[string]*PartialSimple `thrift:"MapStringSimple,15" json:"MapStringSimple"` -} - -func NewPartialNesting() *PartialNesting { - return &PartialNesting{} -} - -func (p *PartialNesting) GetListSimple() (v []*PartialSimple) { - return p.ListSimple -} - -var PartialNesting_SimpleStruct_DEFAULT *PartialSimple - -func (p *PartialNesting) GetSimpleStruct() (v *PartialSimple) { - if !p.IsSetSimpleStruct() { - return PartialNesting_SimpleStruct_DEFAULT - } - return p.SimpleStruct -} - -func (p *PartialNesting) GetMapStringSimple() (v map[string]*PartialSimple) { - return p.MapStringSimple -} -func (p *PartialNesting) SetListSimple(val []*PartialSimple) { - p.ListSimple = val -} -func (p *PartialNesting) SetSimpleStruct(val *PartialSimple) { - p.SimpleStruct = val -} -func (p *PartialNesting) SetMapStringSimple(val map[string]*PartialSimple) { - p.MapStringSimple = val -} - -var fieldIDToName_PartialNesting = map[int16]string{ - 2: "ListSimple", - 8: "SimpleStruct", - 15: "MapStringSimple", -} - -func (p *PartialNesting) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil -} - -func (p *PartialNesting) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 2: - if fieldTypeId == thrift.LIST { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 15: - if fieldTypeId == thrift.MAP { - if err = p.ReadField15(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialNesting) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListSimple = make([]*PartialSimple, 0, size) - for i := 0; i < size; i++ { - _elem := NewPartialSimple() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListSimple = append(p.ListSimple, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *PartialNesting) ReadField8(iprot thrift.TProtocol) error { - p.SimpleStruct = NewPartialSimple() - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *PartialNesting) ReadField15(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringSimple = make(map[string]*PartialSimple, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - _val := NewPartialSimple() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapStringSimple[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *PartialNesting) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNesting"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField15(oprot); err != nil { - fieldId = 15 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PartialNesting) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { - return err - } - for _, v := range p.ListSimple { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *PartialNesting) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { - goto WriteFieldBeginError - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *PartialNesting) writeField15(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { - return err - } - for k, v := range p.MapStringSimple { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) -} - -func (p *PartialNesting) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PartialNesting(%+v)", *p) -} - -func (p *PartialNesting) DeepEqual(ano *PartialNesting) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field2DeepEqual(ano.ListSimple) { - return false - } - if !p.Field8DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field15DeepEqual(ano.MapStringSimple) { - return false - } - return true -} - -func (p *PartialNesting) Field2DeepEqual(src []*PartialSimple) bool { - - if len(p.ListSimple) != len(src) { - return false - } - for i, v := range p.ListSimple { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *PartialNesting) Field8DeepEqual(src *PartialSimple) bool { - - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true -} -func (p *PartialNesting) Field15DeepEqual(src map[string]*PartialSimple) bool { - - if len(p.MapStringSimple) != len(src) { - return false - } - for k, v := range p.MapStringSimple { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} - -type Nesting2 struct { - MapSimpleNesting map[*Simple]*Nesting `thrift:"MapSimpleNesting,1" json:"MapSimpleNesting"` - SimpleStruct *Simple `thrift:"SimpleStruct,2" json:"SimpleStruct"` - Byte int8 `thrift:"Byte,3" json:"Byte"` - Double float64 `thrift:"Double,4" json:"Double"` - ListNesting []*Nesting `thrift:"ListNesting,5" json:"ListNesting"` - I64 int64 `thrift:"I64,6" json:"I64"` - NestingStruct *Nesting `thrift:"NestingStruct,7" json:"NestingStruct"` - Binary []byte `thrift:"Binary,8" json:"Binary"` - String_ string `thrift:"String,9" json:"String"` - SetNesting []*Nesting `thrift:"SetNesting,10" json:"SetNesting"` - I32 int32 `thrift:"I32,11" json:"I32"` -} - -func NewNesting2() *Nesting2 { - return &Nesting2{} +func (p *Nesting2) InitDefault() { } func (p *Nesting2) GetMapSimpleNesting() (v map[*Simple]*Nesting) { @@ -2371,838 +298,77 @@ func (p *Nesting2) GetSimpleStruct() (v *Simple) { if !p.IsSetSimpleStruct() { return Nesting2_SimpleStruct_DEFAULT } - return p.SimpleStruct -} - -func (p *Nesting2) GetByte() (v int8) { - return p.Byte -} - -func (p *Nesting2) GetDouble() (v float64) { - return p.Double -} - -func (p *Nesting2) GetListNesting() (v []*Nesting) { - return p.ListNesting -} - -func (p *Nesting2) GetI64() (v int64) { - return p.I64 -} - -var Nesting2_NestingStruct_DEFAULT *Nesting - -func (p *Nesting2) GetNestingStruct() (v *Nesting) { - if !p.IsSetNestingStruct() { - return Nesting2_NestingStruct_DEFAULT - } - return p.NestingStruct -} - -func (p *Nesting2) GetBinary() (v []byte) { - return p.Binary -} - -func (p *Nesting2) GetString() (v string) { - return p.String_ -} - -func (p *Nesting2) GetSetNesting() (v []*Nesting) { - return p.SetNesting -} - -func (p *Nesting2) GetI32() (v int32) { - return p.I32 -} -func (p *Nesting2) SetMapSimpleNesting(val map[*Simple]*Nesting) { - p.MapSimpleNesting = val -} -func (p *Nesting2) SetSimpleStruct(val *Simple) { - p.SimpleStruct = val -} -func (p *Nesting2) SetByte(val int8) { - p.Byte = val -} -func (p *Nesting2) SetDouble(val float64) { - p.Double = val -} -func (p *Nesting2) SetListNesting(val []*Nesting) { - p.ListNesting = val -} -func (p *Nesting2) SetI64(val int64) { - p.I64 = val -} -func (p *Nesting2) SetNestingStruct(val *Nesting) { - p.NestingStruct = val -} -func (p *Nesting2) SetBinary(val []byte) { - p.Binary = val -} -func (p *Nesting2) SetString(val string) { - p.String_ = val -} -func (p *Nesting2) SetSetNesting(val []*Nesting) { - p.SetNesting = val -} -func (p *Nesting2) SetI32(val int32) { - p.I32 = val -} - -var fieldIDToName_Nesting2 = map[int16]string{ - 1: "MapSimpleNesting", - 2: "SimpleStruct", - 3: "Byte", - 4: "Double", - 5: "ListNesting", - 6: "I64", - 7: "NestingStruct", - 8: "Binary", - 9: "String", - 10: "SetNesting", - 11: "I32", -} - -func (p *Nesting2) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil -} - -func (p *Nesting2) IsSetNestingStruct() bool { - return p.NestingStruct != nil -} - -func (p *Nesting2) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.LIST { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRING { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.STRING { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 10: - if fieldTypeId == thrift.SET { - if err = p.ReadField10(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 11: - if fieldTypeId == thrift.I32 { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting2) ReadField1(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapSimpleNesting = make(map[*Simple]*Nesting, size) - for i := 0; i < size; i++ { - _key := NewSimple() - if err := _key.Read(iprot); err != nil { - return err - } - _val := NewNesting() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapSimpleNesting[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting2) ReadField2(iprot thrift.TProtocol) error { - p.SimpleStruct = NewSimple() - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *Nesting2) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil -} - -func (p *Nesting2) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil -} - -func (p *Nesting2) ReadField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - _elem := NewNesting() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListNesting = append(p.ListNesting, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting2) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64 = v - } - return nil -} - -func (p *Nesting2) ReadField7(iprot thrift.TProtocol) error { - p.NestingStruct = NewNesting() - if err := p.NestingStruct.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *Nesting2) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil -} - -func (p *Nesting2) ReadField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} - -func (p *Nesting2) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.SetNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - _elem := NewNesting() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.SetNesting = append(p.SetNesting, _elem) - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting2) ReadField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32 = v - } - return nil -} - -func (p *Nesting2) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField10(oprot); err != nil { - fieldId = 10 - goto WriteFieldError - } - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Nesting2) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapSimpleNesting", thrift.MAP, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)); err != nil { - return err - } - for k, v := range p.MapSimpleNesting { - - if err := k.Write(oprot); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Nesting2) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 2); err != nil { - goto WriteFieldBeginError - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *Nesting2) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *Nesting2) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *Nesting2) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListNesting", thrift.LIST, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListNesting)); err != nil { - return err - } - for _, v := range p.ListNesting { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *Nesting2) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *Nesting2) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("NestingStruct", thrift.STRUCT, 7); err != nil { - goto WriteFieldBeginError - } - if err := p.NestingStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *Nesting2) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *Nesting2) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} - -func (p *Nesting2) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SetNesting", thrift.SET, 10); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.SetNesting)); err != nil { - return err - } - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } - for _, v := range p.SetNesting { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) -} - -func (p *Nesting2) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32", thrift.I32, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) -} - -func (p *Nesting2) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Nesting2(%+v)", *p) + return p.SimpleStruct } -func (p *Nesting2) DeepEqual(ano *Nesting2) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.MapSimpleNesting) { - return false - } - if !p.Field2DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field3DeepEqual(ano.Byte) { - return false - } - if !p.Field4DeepEqual(ano.Double) { - return false - } - if !p.Field5DeepEqual(ano.ListNesting) { - return false - } - if !p.Field6DeepEqual(ano.I64) { - return false - } - if !p.Field7DeepEqual(ano.NestingStruct) { - return false - } - if !p.Field8DeepEqual(ano.Binary) { - return false - } - if !p.Field9DeepEqual(ano.String_) { - return false - } - if !p.Field10DeepEqual(ano.SetNesting) { - return false - } - if !p.Field11DeepEqual(ano.I32) { - return false - } - return true +func (p *Nesting2) GetByte() (v int8) { + return p.Byte } -func (p *Nesting2) Field1DeepEqual(src map[*Simple]*Nesting) bool { +func (p *Nesting2) GetDouble() (v float64) { + return p.Double +} - if len(p.MapSimpleNesting) != len(src) { - return false - } - for k, v := range p.MapSimpleNesting { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true +func (p *Nesting2) GetListNesting() (v []*Nesting) { + return p.ListNesting } -func (p *Nesting2) Field2DeepEqual(src *Simple) bool { - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true +func (p *Nesting2) GetI64() (v int64) { + return p.I64 } -func (p *Nesting2) Field3DeepEqual(src int8) bool { - if p.Byte != src { - return false +var Nesting2_NestingStruct_DEFAULT *Nesting + +func (p *Nesting2) GetNestingStruct() (v *Nesting) { + if !p.IsSetNestingStruct() { + return Nesting2_NestingStruct_DEFAULT } - return true + return p.NestingStruct } -func (p *Nesting2) Field4DeepEqual(src float64) bool { - if p.Double != src { - return false - } - return true +func (p *Nesting2) GetBinary() (v []byte) { + return p.Binary } -func (p *Nesting2) Field5DeepEqual(src []*Nesting) bool { - if len(p.ListNesting) != len(src) { - return false - } - for i, v := range p.ListNesting { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true +func (p *Nesting2) GetString() (v string) { + return p.String_ } -func (p *Nesting2) Field6DeepEqual(src int64) bool { - if p.I64 != src { - return false - } - return true +func (p *Nesting2) GetSetNesting() (v []*Nesting) { + return p.SetNesting } -func (p *Nesting2) Field7DeepEqual(src *Nesting) bool { - if !p.NestingStruct.DeepEqual(src) { - return false - } - return true +func (p *Nesting2) GetI32() (v int32) { + return p.I32 } -func (p *Nesting2) Field8DeepEqual(src []byte) bool { - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true +func (p *Nesting2) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil } -func (p *Nesting2) Field9DeepEqual(src string) bool { - if strings.Compare(p.String_, src) != 0 { - return false - } - return true +func (p *Nesting2) IsSetNestingStruct() bool { + return p.NestingStruct != nil } -func (p *Nesting2) Field10DeepEqual(src []*Nesting) bool { - if len(p.SetNesting) != len(src) { - return false - } - for i, v := range p.SetNesting { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } +func (p *Nesting2) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("Nesting2(%+v)", *p) } -func (p *Nesting2) Field11DeepEqual(src int32) bool { - if p.I32 != src { - return false - } - return true +var fieldIDToName_Nesting2 = map[int16]string{ + 1: "MapSimpleNesting", + 2: "SimpleStruct", + 3: "Byte", + 4: "Double", + 5: "ListNesting", + 6: "I64", + 7: "NestingStruct", + 8: "Binary", + 9: "String", + 10: "SetNesting", + 11: "I32", } type BaselineService interface { @@ -3217,367 +383,6 @@ type BaselineService interface { Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) } -type BaselineServiceClient struct { - c thrift.TClient -} - -func NewBaselineServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaselineServiceClient { - return &BaselineServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewBaselineServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaselineServiceClient { - return &BaselineServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewBaselineServiceClient(c thrift.TClient) *BaselineServiceClient { - return &BaselineServiceClient{ - c: c, - } -} - -func (p *BaselineServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *BaselineServiceClient) SimpleMethod(ctx context.Context, req *Simple) (r *Simple, err error) { - var _args BaselineServiceSimpleMethodArgs - _args.Req = req - var _result BaselineServiceSimpleMethodResult - if err = p.Client_().Call(ctx, "SimpleMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BaselineServiceClient) PartialSimpleMethod(ctx context.Context, req *PartialSimple) (r *PartialSimple, err error) { - var _args BaselineServicePartialSimpleMethodArgs - _args.Req = req - var _result BaselineServicePartialSimpleMethodResult - if err = p.Client_().Call(ctx, "PartialSimpleMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BaselineServiceClient) NestingMethod(ctx context.Context, req *Nesting) (r *Nesting, err error) { - var _args BaselineServiceNestingMethodArgs - _args.Req = req - var _result BaselineServiceNestingMethodResult - if err = p.Client_().Call(ctx, "NestingMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BaselineServiceClient) PartialNestingMethod(ctx context.Context, req *PartialNesting) (r *PartialNesting, err error) { - var _args BaselineServicePartialNestingMethodArgs - _args.Req = req - var _result BaselineServicePartialNestingMethodResult - if err = p.Client_().Call(ctx, "PartialNestingMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *BaselineServiceClient) Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) { - var _args BaselineServiceNesting2MethodArgs - _args.Req = req - var _result BaselineServiceNesting2MethodResult - if err = p.Client_().Call(ctx, "Nesting2Method", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type BaselineServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler BaselineService -} - -func (p *BaselineServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *BaselineServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *BaselineServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewBaselineServiceProcessor(handler BaselineService) *BaselineServiceProcessor { - self := &BaselineServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("SimpleMethod", &baselineServiceProcessorSimpleMethod{handler: handler}) - self.AddToProcessorMap("PartialSimpleMethod", &baselineServiceProcessorPartialSimpleMethod{handler: handler}) - self.AddToProcessorMap("NestingMethod", &baselineServiceProcessorNestingMethod{handler: handler}) - self.AddToProcessorMap("PartialNestingMethod", &baselineServiceProcessorPartialNestingMethod{handler: handler}) - self.AddToProcessorMap("Nesting2Method", &baselineServiceProcessorNesting2Method{handler: handler}) - return self -} -func (p *BaselineServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type baselineServiceProcessorSimpleMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceSimpleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceSimpleMethodResult{} - var retval *Simple - if retval, err2 = p.handler.SimpleMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing SimpleMethod: "+err2.Error()) - oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("SimpleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorPartialSimpleMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorPartialSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServicePartialSimpleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServicePartialSimpleMethodResult{} - var retval *PartialSimple - if retval, err2 = p.handler.PartialSimpleMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialSimpleMethod: "+err2.Error()) - oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PartialSimpleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorNestingMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceNestingMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceNestingMethodResult{} - var retval *Nesting - if retval, err2 = p.handler.NestingMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NestingMethod: "+err2.Error()) - oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("NestingMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorPartialNestingMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorPartialNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServicePartialNestingMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServicePartialNestingMethodResult{} - var retval *PartialNesting - if retval, err2 = p.handler.PartialNestingMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialNestingMethod: "+err2.Error()) - oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PartialNestingMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorNesting2Method struct { - handler BaselineService -} - -func (p *baselineServiceProcessorNesting2Method) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceNesting2MethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceNesting2MethodResult{} - var retval *Nesting2 - if retval, err2 = p.handler.Nesting2Method(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Nesting2Method: "+err2.Error()) - oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Nesting2Method", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - type BaselineServiceSimpleMethodArgs struct { Req *Simple `thrift:"req,1" json:"req"` } @@ -3586,6 +391,9 @@ func NewBaselineServiceSimpleMethodArgs() *BaselineServiceSimpleMethodArgs { return &BaselineServiceSimpleMethodArgs{} } +func (p *BaselineServiceSimpleMethodArgs) InitDefault() { +} + var BaselineServiceSimpleMethodArgs_Req_DEFAULT *Simple func (p *BaselineServiceSimpleMethodArgs) GetReq() (v *Simple) { @@ -3594,131 +402,11 @@ func (p *BaselineServiceSimpleMethodArgs) GetReq() (v *Simple) { } return p.Req } -func (p *BaselineServiceSimpleMethodArgs) SetReq(val *Simple) { - p.Req = val -} - -var fieldIDToName_BaselineServiceSimpleMethodArgs = map[int16]string{ - 1: "req", -} func (p *BaselineServiceSimpleMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *BaselineServiceSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewSimple() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("SimpleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *BaselineServiceSimpleMethodArgs) String() string { if p == nil { return "" @@ -3726,34 +414,21 @@ func (p *BaselineServiceSimpleMethodArgs) String() string { return fmt.Sprintf("BaselineServiceSimpleMethodArgs(%+v)", *p) } -func (p *BaselineServiceSimpleMethodArgs) DeepEqual(ano *BaselineServiceSimpleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceSimpleMethodArgs) Field1DeepEqual(src *Simple) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceSimpleMethodArgs = map[int16]string{ + 1: "req", } type BaselineServiceSimpleMethodResult struct { - Success *Simple `thrift:"success,0" json:"success,omitempty"` + Success *Simple `thrift:"success,0,optional" json:"success,omitempty"` } func NewBaselineServiceSimpleMethodResult() *BaselineServiceSimpleMethodResult { return &BaselineServiceSimpleMethodResult{} } +func (p *BaselineServiceSimpleMethodResult) InitDefault() { +} + var BaselineServiceSimpleMethodResult_Success_DEFAULT *Simple func (p *BaselineServiceSimpleMethodResult) GetSuccess() (v *Simple) { @@ -3762,133 +437,11 @@ func (p *BaselineServiceSimpleMethodResult) GetSuccess() (v *Simple) { } return p.Success } -func (p *BaselineServiceSimpleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Simple) -} - -var fieldIDToName_BaselineServiceSimpleMethodResult = map[int16]string{ - 0: "success", -} func (p *BaselineServiceSimpleMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *BaselineServiceSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewSimple() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("SimpleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *BaselineServiceSimpleMethodResult) String() string { if p == nil { return "" @@ -3896,24 +449,8 @@ func (p *BaselineServiceSimpleMethodResult) String() string { return fmt.Sprintf("BaselineServiceSimpleMethodResult(%+v)", *p) } -func (p *BaselineServiceSimpleMethodResult) DeepEqual(ano *BaselineServiceSimpleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceSimpleMethodResult) Field0DeepEqual(src *Simple) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceSimpleMethodResult = map[int16]string{ + 0: "success", } type BaselineServicePartialSimpleMethodArgs struct { @@ -3924,137 +461,20 @@ func NewBaselineServicePartialSimpleMethodArgs() *BaselineServicePartialSimpleMe return &BaselineServicePartialSimpleMethodArgs{} } +func (p *BaselineServicePartialSimpleMethodArgs) InitDefault() { +} + var BaselineServicePartialSimpleMethodArgs_Req_DEFAULT *PartialSimple func (p *BaselineServicePartialSimpleMethodArgs) GetReq() (v *PartialSimple) { if !p.IsSetReq() { return BaselineServicePartialSimpleMethodArgs_Req_DEFAULT } - return p.Req -} -func (p *BaselineServicePartialSimpleMethodArgs) SetReq(val *PartialSimple) { - p.Req = val -} - -var fieldIDToName_BaselineServicePartialSimpleMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServicePartialSimpleMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServicePartialSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewPartialSimple() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil + return p.Req } -func (p *BaselineServicePartialSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimpleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *BaselineServicePartialSimpleMethodArgs) IsSetReq() bool { + return p.Req != nil } func (p *BaselineServicePartialSimpleMethodArgs) String() string { @@ -4064,34 +484,21 @@ func (p *BaselineServicePartialSimpleMethodArgs) String() string { return fmt.Sprintf("BaselineServicePartialSimpleMethodArgs(%+v)", *p) } -func (p *BaselineServicePartialSimpleMethodArgs) DeepEqual(ano *BaselineServicePartialSimpleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServicePartialSimpleMethodArgs) Field1DeepEqual(src *PartialSimple) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServicePartialSimpleMethodArgs = map[int16]string{ + 1: "req", } type BaselineServicePartialSimpleMethodResult struct { - Success *PartialSimple `thrift:"success,0" json:"success,omitempty"` + Success *PartialSimple `thrift:"success,0,optional" json:"success,omitempty"` } func NewBaselineServicePartialSimpleMethodResult() *BaselineServicePartialSimpleMethodResult { return &BaselineServicePartialSimpleMethodResult{} } +func (p *BaselineServicePartialSimpleMethodResult) InitDefault() { +} + var BaselineServicePartialSimpleMethodResult_Success_DEFAULT *PartialSimple func (p *BaselineServicePartialSimpleMethodResult) GetSuccess() (v *PartialSimple) { @@ -4100,133 +507,11 @@ func (p *BaselineServicePartialSimpleMethodResult) GetSuccess() (v *PartialSimpl } return p.Success } -func (p *BaselineServicePartialSimpleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*PartialSimple) -} - -var fieldIDToName_BaselineServicePartialSimpleMethodResult = map[int16]string{ - 0: "success", -} func (p *BaselineServicePartialSimpleMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *BaselineServicePartialSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewPartialSimple() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimpleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *BaselineServicePartialSimpleMethodResult) String() string { if p == nil { return "" @@ -4234,24 +519,8 @@ func (p *BaselineServicePartialSimpleMethodResult) String() string { return fmt.Sprintf("BaselineServicePartialSimpleMethodResult(%+v)", *p) } -func (p *BaselineServicePartialSimpleMethodResult) DeepEqual(ano *BaselineServicePartialSimpleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServicePartialSimpleMethodResult) Field0DeepEqual(src *PartialSimple) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServicePartialSimpleMethodResult = map[int16]string{ + 0: "success", } type BaselineServiceNestingMethodArgs struct { @@ -4262,6 +531,9 @@ func NewBaselineServiceNestingMethodArgs() *BaselineServiceNestingMethodArgs { return &BaselineServiceNestingMethodArgs{} } +func (p *BaselineServiceNestingMethodArgs) InitDefault() { +} + var BaselineServiceNestingMethodArgs_Req_DEFAULT *Nesting func (p *BaselineServiceNestingMethodArgs) GetReq() (v *Nesting) { @@ -4270,131 +542,11 @@ func (p *BaselineServiceNestingMethodArgs) GetReq() (v *Nesting) { } return p.Req } -func (p *BaselineServiceNestingMethodArgs) SetReq(val *Nesting) { - p.Req = val -} - -var fieldIDToName_BaselineServiceNestingMethodArgs = map[int16]string{ - 1: "req", -} func (p *BaselineServiceNestingMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *BaselineServiceNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewNesting() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NestingMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *BaselineServiceNestingMethodArgs) String() string { if p == nil { return "" @@ -4402,34 +554,21 @@ func (p *BaselineServiceNestingMethodArgs) String() string { return fmt.Sprintf("BaselineServiceNestingMethodArgs(%+v)", *p) } -func (p *BaselineServiceNestingMethodArgs) DeepEqual(ano *BaselineServiceNestingMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceNestingMethodArgs) Field1DeepEqual(src *Nesting) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceNestingMethodArgs = map[int16]string{ + 1: "req", } type BaselineServiceNestingMethodResult struct { - Success *Nesting `thrift:"success,0" json:"success,omitempty"` + Success *Nesting `thrift:"success,0,optional" json:"success,omitempty"` } func NewBaselineServiceNestingMethodResult() *BaselineServiceNestingMethodResult { return &BaselineServiceNestingMethodResult{} } +func (p *BaselineServiceNestingMethodResult) InitDefault() { +} + var BaselineServiceNestingMethodResult_Success_DEFAULT *Nesting func (p *BaselineServiceNestingMethodResult) GetSuccess() (v *Nesting) { @@ -4438,133 +577,11 @@ func (p *BaselineServiceNestingMethodResult) GetSuccess() (v *Nesting) { } return p.Success } -func (p *BaselineServiceNestingMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Nesting) -} - -var fieldIDToName_BaselineServiceNestingMethodResult = map[int16]string{ - 0: "success", -} func (p *BaselineServiceNestingMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *BaselineServiceNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewNesting() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NestingMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *BaselineServiceNestingMethodResult) String() string { if p == nil { return "" @@ -4572,24 +589,8 @@ func (p *BaselineServiceNestingMethodResult) String() string { return fmt.Sprintf("BaselineServiceNestingMethodResult(%+v)", *p) } -func (p *BaselineServiceNestingMethodResult) DeepEqual(ano *BaselineServiceNestingMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceNestingMethodResult) Field0DeepEqual(src *Nesting) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceNestingMethodResult = map[int16]string{ + 0: "success", } type BaselineServicePartialNestingMethodArgs struct { @@ -4600,6 +601,9 @@ func NewBaselineServicePartialNestingMethodArgs() *BaselineServicePartialNesting return &BaselineServicePartialNestingMethodArgs{} } +func (p *BaselineServicePartialNestingMethodArgs) InitDefault() { +} + var BaselineServicePartialNestingMethodArgs_Req_DEFAULT *PartialNesting func (p *BaselineServicePartialNestingMethodArgs) GetReq() (v *PartialNesting) { @@ -4608,131 +612,11 @@ func (p *BaselineServicePartialNestingMethodArgs) GetReq() (v *PartialNesting) { } return p.Req } -func (p *BaselineServicePartialNestingMethodArgs) SetReq(val *PartialNesting) { - p.Req = val -} - -var fieldIDToName_BaselineServicePartialNestingMethodArgs = map[int16]string{ - 1: "req", -} func (p *BaselineServicePartialNestingMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *BaselineServicePartialNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewPartialNesting() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNestingMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *BaselineServicePartialNestingMethodArgs) String() string { if p == nil { return "" @@ -4740,34 +624,21 @@ func (p *BaselineServicePartialNestingMethodArgs) String() string { return fmt.Sprintf("BaselineServicePartialNestingMethodArgs(%+v)", *p) } -func (p *BaselineServicePartialNestingMethodArgs) DeepEqual(ano *BaselineServicePartialNestingMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServicePartialNestingMethodArgs) Field1DeepEqual(src *PartialNesting) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServicePartialNestingMethodArgs = map[int16]string{ + 1: "req", } type BaselineServicePartialNestingMethodResult struct { - Success *PartialNesting `thrift:"success,0" json:"success,omitempty"` + Success *PartialNesting `thrift:"success,0,optional" json:"success,omitempty"` } func NewBaselineServicePartialNestingMethodResult() *BaselineServicePartialNestingMethodResult { return &BaselineServicePartialNestingMethodResult{} } +func (p *BaselineServicePartialNestingMethodResult) InitDefault() { +} + var BaselineServicePartialNestingMethodResult_Success_DEFAULT *PartialNesting func (p *BaselineServicePartialNestingMethodResult) GetSuccess() (v *PartialNesting) { @@ -4776,133 +647,11 @@ func (p *BaselineServicePartialNestingMethodResult) GetSuccess() (v *PartialNest } return p.Success } -func (p *BaselineServicePartialNestingMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*PartialNesting) -} - -var fieldIDToName_BaselineServicePartialNestingMethodResult = map[int16]string{ - 0: "success", -} func (p *BaselineServicePartialNestingMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *BaselineServicePartialNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewPartialNesting() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNestingMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *BaselineServicePartialNestingMethodResult) String() string { if p == nil { return "" @@ -4910,24 +659,8 @@ func (p *BaselineServicePartialNestingMethodResult) String() string { return fmt.Sprintf("BaselineServicePartialNestingMethodResult(%+v)", *p) } -func (p *BaselineServicePartialNestingMethodResult) DeepEqual(ano *BaselineServicePartialNestingMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServicePartialNestingMethodResult) Field0DeepEqual(src *PartialNesting) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServicePartialNestingMethodResult = map[int16]string{ + 0: "success", } type BaselineServiceNesting2MethodArgs struct { @@ -4938,6 +671,9 @@ func NewBaselineServiceNesting2MethodArgs() *BaselineServiceNesting2MethodArgs { return &BaselineServiceNesting2MethodArgs{} } +func (p *BaselineServiceNesting2MethodArgs) InitDefault() { +} + var BaselineServiceNesting2MethodArgs_Req_DEFAULT *Nesting2 func (p *BaselineServiceNesting2MethodArgs) GetReq() (v *Nesting2) { @@ -4946,131 +682,11 @@ func (p *BaselineServiceNesting2MethodArgs) GetReq() (v *Nesting2) { } return p.Req } -func (p *BaselineServiceNesting2MethodArgs) SetReq(val *Nesting2) { - p.Req = val -} - -var fieldIDToName_BaselineServiceNesting2MethodArgs = map[int16]string{ - 1: "req", -} func (p *BaselineServiceNesting2MethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *BaselineServiceNesting2MethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewNesting2() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNesting2MethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2Method_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *BaselineServiceNesting2MethodArgs) String() string { if p == nil { return "" @@ -5078,34 +694,21 @@ func (p *BaselineServiceNesting2MethodArgs) String() string { return fmt.Sprintf("BaselineServiceNesting2MethodArgs(%+v)", *p) } -func (p *BaselineServiceNesting2MethodArgs) DeepEqual(ano *BaselineServiceNesting2MethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceNesting2MethodArgs) Field1DeepEqual(src *Nesting2) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceNesting2MethodArgs = map[int16]string{ + 1: "req", } type BaselineServiceNesting2MethodResult struct { - Success *Nesting2 `thrift:"success,0" json:"success,omitempty"` + Success *Nesting2 `thrift:"success,0,optional" json:"success,omitempty"` } func NewBaselineServiceNesting2MethodResult() *BaselineServiceNesting2MethodResult { return &BaselineServiceNesting2MethodResult{} } +func (p *BaselineServiceNesting2MethodResult) InitDefault() { +} + var BaselineServiceNesting2MethodResult_Success_DEFAULT *Nesting2 func (p *BaselineServiceNesting2MethodResult) GetSuccess() (v *Nesting2) { @@ -5114,133 +717,11 @@ func (p *BaselineServiceNesting2MethodResult) GetSuccess() (v *Nesting2) { } return p.Success } -func (p *BaselineServiceNesting2MethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Nesting2) -} - -var fieldIDToName_BaselineServiceNesting2MethodResult = map[int16]string{ - 0: "success", -} func (p *BaselineServiceNesting2MethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *BaselineServiceNesting2MethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewNesting2() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNesting2MethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2Method_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *BaselineServiceNesting2MethodResult) String() string { if p == nil { return "" @@ -5248,22 +729,6 @@ func (p *BaselineServiceNesting2MethodResult) String() string { return fmt.Sprintf("BaselineServiceNesting2MethodResult(%+v)", *p) } -func (p *BaselineServiceNesting2MethodResult) DeepEqual(ano *BaselineServiceNesting2MethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceNesting2MethodResult) Field0DeepEqual(src *Nesting2) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_BaselineServiceNesting2MethodResult = map[int16]string{ + 0: "success", } diff --git a/testdata/kitex_gen/baseline/k-baseline.go b/testdata/kitex_gen/baseline/k-baseline.go index d06c83e8..4091c95f 100644 --- a/testdata/kitex_gen/baseline/k-baseline.go +++ b/testdata/kitex_gen/baseline/k-baseline.go @@ -1,3933 +1,1926 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package baseline import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/dynamicgo/internal/bthrift" -) + "unsafe" -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + "github.com/cloudwego/gopkg/protocol/thrift" ) -func (p *Simple) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Simple) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.ByteField ID:1 thrift.I08 + off += 3 + off += 1 + + // p.I64Field ID:2 thrift.I64 + off += 3 + off += 8 + + // p.DoubleField ID:3 thrift.DOUBLE + off += 3 + off += 8 + + // p.I32Field ID:4 thrift.I32 + off += 3 + off += 4 + + // p.StringField ID:5 thrift.STRING + off += 3 + off += 4 + len(p.StringField) + + // p.BinaryField ID:6 thrift.STRING + off += 3 + off += 4 + len(p.BinaryField) + return off + 1 +} + +func (p *Simple) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *Simple) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.ByteField ID:1 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = byte(p.ByteField) + off++ + + // p.I64Field ID:2 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.I64Field)) + off += 8 + + // p.DoubleField ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.DoubleField))) + off += 8 + + // p.I32Field ID:4 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.I32Field)) + off += 4 + + // p.StringField ID:5 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.StringField) + + // p.BinaryField ID:6 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.BinaryField) + + b[off] = 0 + return off + 1 +} + +func (p *Simple) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x103: // p.ByteField ID:1 thrift.I08 + p.ByteField, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20a: // p.I64Field ID:2 thrift.I64 + p.I64Field, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x304: // p.DoubleField ID:3 thrift.DOUBLE + p.DoubleField, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x408: // p.I32Field ID:4 thrift.I32 + p.I32Field, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x50b: // p.StringField ID:5 thrift.STRING + p.StringField, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x60b: // p.BinaryField ID:6 thrift.STRING + p.BinaryField, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Simple[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Simple[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Simple) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.ByteField = v - - } - return offset, nil -} - -func (p *Simple) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64Field = v - - } - return offset, nil -} - -func (p *Simple) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.DoubleField = v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Simple) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32Field = v - +func (p *PartialSimple) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *Simple) FastReadField5(buf []byte) (int, error) { - offset := 0 + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.ByteField ID:1 thrift.I08 + off += 3 + off += 1 - p.StringField = v + // p.DoubleField ID:3 thrift.DOUBLE + off += 3 + off += 8 - } - return offset, nil + // p.BinaryField ID:6 thrift.STRING + off += 3 + off += 4 + len(p.BinaryField) + return off + 1 } -func (p *Simple) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.BinaryField = []byte(v) +func (p *PartialSimple) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *PartialSimple) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} - -// for compatibility -func (p *Simple) FastWrite(buf []byte) int { - return 0 -} - -func (p *Simple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Simple") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Simple) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Simple") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Simple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) - offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64Field", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64Field) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32Field", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32Field) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StringField", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StringField) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) - l += bthrift.Binary.ByteLength(p.ByteField) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64Field", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.I64Field) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.DoubleField) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32Field", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.I32Field) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.ByteField ID:1 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = byte(p.ByteField) + off++ -func (p *Simple) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StringField", thrift.STRING, 5) - l += bthrift.Binary.StringLength(p.StringField) + // p.DoubleField ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.DoubleField))) + off += 8 - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) + // p.BinaryField ID:6 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.BinaryField) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *PartialSimple) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *PartialSimple) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x103: // p.ByteField ID:1 thrift.I08 + p.ByteField, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x304: // p.DoubleField ID:3 thrift.DOUBLE + p.DoubleField, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x60b: // p.BinaryField ID:6 thrift.STRING + p.BinaryField, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_PartialSimple[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *PartialSimple) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.ByteField = v - +func (p *Nesting) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *PartialSimple) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.DoubleField = v + // p.String_ ID:1 thrift.STRING + off += 3 + off += 4 + len(p.String_) + // p.ListSimple ID:2 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListSimple { + off += v.BLength() } - return offset, nil -} -func (p *PartialSimple) FastReadField6(buf []byte) (int, error) { - offset := 0 + // p.Double ID:3 thrift.DOUBLE + off += 3 + off += 8 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.I32 ID:4 thrift.I32 + off += 3 + off += 4 - p.BinaryField = []byte(v) + // p.ListI32 ID:5 thrift.LIST + off += 3 + off += 5 + off += len(p.ListI32) * 4 - } - return offset, nil -} + // p.I64 ID:6 thrift.I64 + off += 3 + off += 8 -// for compatibility -func (p *PartialSimple) FastWrite(buf []byte) int { - return 0 -} + // p.MapStringString ID:7 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringString { + off += 4 + len(k) + off += 4 + len(v) + } -func (p *PartialSimple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimple") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + // p.SimpleStruct ID:8 thrift.STRUCT + off += 3 + off += p.SimpleStruct.BLength() -func (p *PartialSimple) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimple") - if p != nil { - l += p.field1Length() - l += p.field3Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + // p.MapI32I64 ID:9 thrift.MAP + off += 3 + off += 6 + off += len(p.MapI32I64) * (4 + 8) -func (p *PartialSimple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) - offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) + // p.ListString ID:10 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListString { + off += 4 + len(v) + } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Binary ID:11 thrift.STRING + off += 3 + off += 4 + len(p.Binary) -func (p *PartialSimple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) + // p.MapI64String ID:12 thrift.MAP + off += 3 + off += 6 + off += len(p.MapI64String) * 8 + for _, v := range p.MapI64String { + off += 4 + len(v) + } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.ListI64 ID:13 thrift.LIST + off += 3 + off += 5 + off += len(p.ListI64) * 8 -func (p *PartialSimple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) + // p.Byte ID:14 thrift.I08 + off += 3 + off += 1 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.MapStringSimple ID:15 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringSimple { + off += 4 + len(k) + off += v.BLength() + } + return off + 1 } -func (p *PartialSimple) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) - l += bthrift.Binary.ByteLength(p.ByteField) - - l += bthrift.Binary.FieldEndLength() - return l -} +func (p *Nesting) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *PartialSimple) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.DoubleField) +func (p *Nesting) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.String_ ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) -func (p *PartialSimple) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) + // p.ListSimple ID:2 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListSimple))) + off += 5 + for _, v := range p.ListSimple { + off += v.FastWriteNocopy(b[off:], w) + } + + // p.Double ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Double))) + off += 8 + + // p.I32 ID:4 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.I32)) + off += 4 + + // p.ListI32 ID:5 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListI32))) + off += 5 + for _, v := range p.ListI32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.I64 ID:6 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.I64)) + off += 8 + + // p.MapStringString ID:7 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringString))) + off += 6 + for k, v := range p.MapStringString { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.SimpleStruct ID:8 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + off += p.SimpleStruct.FastWriteNocopy(b[off:], w) + + // p.MapI32I64 ID:9 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + b[off] = 8 + b[off+1] = 10 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapI32I64))) + off += 6 + for k, v := range p.MapI32I64 { + binary.BigEndian.PutUint32(b[off:], uint32(k)) + off += 4 + binary.BigEndian.PutUint64(b[off:], uint64(v)) + off += 8 + } + + // p.ListString ID:10 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 10) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListString))) + off += 5 + for _, v := range p.ListString { + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.Binary ID:11 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 11) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary) + + // p.MapI64String ID:12 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 12) + off += 3 + b[off] = 10 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapI64String))) + off += 6 + for k, v := range p.MapI64String { + binary.BigEndian.PutUint64(b[off:], uint64(k)) + off += 8 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.ListI64 ID:13 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 13) + off += 3 + b[off] = 10 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListI64))) + off += 5 + for _, v := range p.ListI64 { + binary.BigEndian.PutUint64(b[off:], uint64(v)) + off += 8 + } + + // p.Byte ID:14 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 14) + off += 3 + b[off] = byte(p.Byte) + off++ + + // p.MapStringSimple ID:15 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 15) + off += 3 + b[off] = 11 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringSimple))) + off += 6 + for k, v := range p.MapStringSimple { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += v.FastWriteNocopy(b[off:], w) + } - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *Nesting) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Nesting) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.String_ ID:1 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20f: // p.ListSimple ID:2 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l + p.ListSimple = make([]*Simple, sz) + for i := 0; i < sz; i++ { + p.ListSimple[i] = NewSimple() + l, err = p.ListSimple[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 4: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x304: // p.Double ID:3 thrift.DOUBLE + p.Double, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x408: // p.I32 ID:4 thrift.I32 + p.I32, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x50f: // p.ListI32 ID:5 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 7: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField7(buf[offset:]) - offset += l + p.ListI32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.ListI32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 8: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x60a: // p.I64 ID:6 thrift.I64 + p.I64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x70d: // p.MapStringString ID:7 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 10: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField10(buf[offset:]) - offset += l + p.MapStringString = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringString[k] = v + } + case 0x80c: // p.SimpleStruct ID:8 thrift.STRUCT + p.SimpleStruct = NewSimple() + l, err = p.SimpleStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x90d: // p.MapI32I64 ID:9 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 11: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField11(buf[offset:]) - offset += l + p.MapI32I64 = make(map[int32]int64, sz) + for i := 0; i < sz; i++ { + var k int32 + var v int64 + k, l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadI64(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapI32I64[k] = v + } + case 0xa0f: // p.ListString ID:10 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 12: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField12(buf[offset:]) - offset += l + p.ListString = make([]string, sz) + for i := 0; i < sz; i++ { + p.ListString[i], l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 13: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField13(buf[offset:]) - offset += l + case 0xb0b: // p.Binary ID:11 thrift.STRING + p.Binary, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xc0d: // p.MapI64String ID:12 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapI64String = make(map[int64]string, sz) + for i := 0; i < sz; i++ { + var k int64 + var v string + k, l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapI64String[k] = v + } + case 0xd0f: // p.ListI64 ID:13 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 14: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField14(buf[offset:]) - offset += l + p.ListI64 = make([]int64, sz) + for i := 0; i < sz; i++ { + p.ListI64[i], l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 15: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField15(buf[offset:]) - offset += l + case 0xe03: // p.Byte ID:14 thrift.I08 + p.Byte, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xf0d: // p.MapStringSimple ID:15 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapStringSimple = make(map[string]*Simple, sz) + for i := 0; i < sz; i++ { + var k string + var v *Simple + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v = NewSimple() + l, err = v.FastRead(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringSimple[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Nesting[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Nesting) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *PartialNesting) BLength() int { + if p == nil { + return 1 + } + off := 0 - p.String_ = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField2(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListSimple = make([]*Simple, 0, size) - for i := 0; i < size; i++ { - _elem := NewSimple() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListSimple = append(p.ListSimple, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32 = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField5(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListI32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListI32 = append(p.ListI32, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64 = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField7(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapStringString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField8(buf []byte) (int, error) { - offset := 0 - p.SimpleStruct = NewSimple() - if l, err := p.SimpleStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField9(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapI32I64 = make(map[int32]int64, size) - for i := 0; i < size; i++ { - var _key int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapI32I64[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField10(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListString = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListString = append(p.ListString, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField11(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *Nesting) FastReadField12(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapI64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapI64String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField13(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListI64 = make([]int64, 0, size) - for i := 0; i < size; i++ { - var _elem int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListI64 = append(p.ListI64, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField14(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField15(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringSimple = make(map[string]*Simple, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - _val := NewSimple() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapStringSimple[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *Nesting) FastWrite(buf []byte) int { - return 0 -} - -func (p *Nesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting") - if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField14(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField10(buf[offset:], binaryWriter) - offset += p.fastWriteField11(buf[offset:], binaryWriter) - offset += p.fastWriteField12(buf[offset:], binaryWriter) - offset += p.fastWriteField13(buf[offset:], binaryWriter) - offset += p.fastWriteField15(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Nesting) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field9Length() - l += p.field10Length() - l += p.field11Length() - l += p.field12Length() - l += p.field13Length() - l += p.field14Length() - l += p.field15Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Nesting) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListSimple)) - for _, v := range p.ListSimple { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI32", thrift.LIST, 5) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I32, len(p.ListI32)) - for _, v := range p.ListI32 { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 7) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI32I64", thrift.MAP, 9) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I32, thrift.I64, len(p.MapI32I64)) - for k, v := range p.MapI32I64 { - - offset += bthrift.Binary.WriteI32(buf[offset:], k) - - offset += bthrift.Binary.WriteI64(buf[offset:], v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListString", thrift.LIST, 10) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.ListString)) - for _, v := range p.ListString { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 11) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI64String", thrift.MAP, 12) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I64, thrift.STRING, len(p.MapI64String)) - for k, v := range p.MapI64String { - - offset += bthrift.Binary.WriteI64(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI64", thrift.LIST, 13) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I64, len(p.ListI64)) - for _, v := range p.ListI64 { - offset += bthrift.Binary.WriteI64(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 14) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) - for k, v := range p.MapStringSimple { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) - for _, v := range p.ListSimple { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.Double) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.I32) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListI32", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListI32)) - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.ListI32) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.I64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 7) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapI32I64", thrift.MAP, 9) - l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.I64, len(p.MapI32I64)) - var tmpK int32 - var tmpV int64 - l += (bthrift.Binary.I32Length(int32(tmpK)) + bthrift.Binary.I64Length(int64(tmpV))) * len(p.MapI32I64) - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field10Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListString", thrift.LIST, 10) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.ListString)) - for _, v := range p.ListString { - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 11) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field12Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapI64String", thrift.MAP, 12) - l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, len(p.MapI64String)) - for k, v := range p.MapI64String { - - l += bthrift.Binary.I64Length(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field13Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListI64", thrift.LIST, 13) - l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.ListI64)) - var tmpV int64 - l += bthrift.Binary.I64Length(int64(tmpV)) * len(p.ListI64) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field14Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 14) - l += bthrift.Binary.ByteLength(p.Byte) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field15Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) - for k, v := range p.MapStringSimple { - - l += bthrift.Binary.StringLength(k) - - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 15: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField15(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + // p.ListSimple ID:2 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListSimple { + off += v.BLength() } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialNesting) FastReadField2(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListSimple = make([]*PartialSimple, 0, size) - for i := 0; i < size; i++ { - _elem := NewPartialSimple() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListSimple = append(p.ListSimple, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} + // p.SimpleStruct ID:8 thrift.STRUCT + off += 3 + off += p.SimpleStruct.BLength() -func (p *PartialNesting) FastReadField8(buf []byte) (int, error) { - offset := 0 - p.SimpleStruct = NewPartialSimple() - if l, err := p.SimpleStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.MapStringSimple ID:15 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringSimple { + off += 4 + len(k) + off += v.BLength() } - return offset, nil + return off + 1 } -func (p *PartialNesting) FastReadField15(buf []byte) (int, error) { - offset := 0 +func (p *PartialNesting) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err +func (p *PartialNesting) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - p.MapStringSimple = make(map[string]*PartialSimple, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - _key = v - - } - _val := NewPartialSimple() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapStringSimple[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *PartialNesting) FastWrite(buf []byte) int { - return 0 -} - -func (p *PartialNesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNesting") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField15(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNesting") - if p != nil { - l += p.field2Length() - l += p.field8Length() - l += p.field15Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PartialNesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListSimple)) + // p.ListSimple ID:2 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListSimple))) + off += 5 for _, v := range p.ListSimple { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) + off += v.FastWriteNocopy(b[off:], w) + } + + // p.SimpleStruct ID:8 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + off += p.SimpleStruct.FastWriteNocopy(b[off:], w) + + // p.MapStringSimple ID:15 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 15) + off += 3 + b[off] = 11 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringSimple))) + off += 6 for k, v := range p.MapStringSimple { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) - for _, v := range p.ListSimple { - l += v.BLength() + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += v.FastWriteNocopy(b[off:], w) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) field15Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) - for k, v := range p.MapStringSimple { - - l += bthrift.Binary.StringLength(k) - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *Nesting2) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *PartialNesting) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x20f: // p.ListSimple ID:2 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 7: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField7(buf[offset:]) - offset += l + p.ListSimple = make([]*PartialSimple, sz) + for i := 0; i < sz; i++ { + p.ListSimple[i] = NewPartialSimple() + l, err = p.ListSimple[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 8: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x80c: // p.SimpleStruct ID:8 thrift.STRUCT + p.SimpleStruct = NewPartialSimple() + l, err = p.SimpleStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xf0d: // p.MapStringSimple ID:15 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 10: - if fieldTypeId == thrift.SET { - l, err = p.FastReadField10(buf[offset:]) - offset += l + p.MapStringSimple = make(map[string]*PartialSimple, sz) + for i := 0; i < sz; i++ { + var k string + var v *PartialSimple + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 11: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField11(buf[offset:]) - offset += l + v = NewPartialSimple() + l, err = v.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + p.MapStringSimple[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_PartialNesting[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting2) FastReadField1(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapSimpleNesting = make(map[*Simple]*Nesting, size) - for i := 0; i < size; i++ { - _key := NewSimple() - if l, err := _key.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - _val := NewNesting() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapSimpleNesting[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField2(buf []byte) (int, error) { - offset := 0 - p.SimpleStruct = NewSimple() - if l, err := p.SimpleStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField5(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - _elem := NewNesting() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListNesting = append(p.ListNesting, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64 = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField7(buf []byte) (int, error) { - offset := 0 - p.NestingStruct = NewNesting() - if l, err := p.NestingStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField8(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *Nesting2) FastReadField9(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField10(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.SetNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - _elem := NewNesting() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.SetNesting = append(p.SetNesting, _elem) - } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField11(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32 = v - - } - return offset, nil -} - -// for compatibility -func (p *Nesting2) FastWrite(buf []byte) int { - return 0 -} - -func (p *Nesting2) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2") - if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField11(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField10(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *Nesting2) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field9Length() - l += p.field10Length() - l += p.field11Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + if p == nil { + return 1 + } + off := 0 -func (p *Nesting2) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapSimpleNesting", thrift.MAP, 1) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)) + // p.MapSimpleNesting ID:1 thrift.MAP + off += 3 + off += 6 for k, v := range p.MapSimpleNesting { - - offset += k.FastWriteNocopy(buf[offset:], binaryWriter) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + off += k.BLength() + off += v.BLength() } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 2) - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 3) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.SimpleStruct ID:2 thrift.STRUCT + off += 3 + off += p.SimpleStruct.BLength() -func (p *Nesting2) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 4) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) + // p.Byte ID:3 thrift.I08 + off += 3 + off += 1 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Double ID:4 thrift.DOUBLE + off += 3 + off += 8 -func (p *Nesting2) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListNesting", thrift.LIST, 5) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListNesting)) + // p.ListNesting ID:5 thrift.LIST + off += 3 + off += 5 for _, v := range p.ListNesting { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + off += v.BLength() } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "NestingStruct", thrift.STRUCT, 7) - offset += p.NestingStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} -func (p *Nesting2) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 8) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) + // p.I64 ID:6 thrift.I64 + off += 3 + off += 8 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 9) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) + // p.NestingStruct ID:7 thrift.STRUCT + off += 3 + off += p.NestingStruct.BLength() - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Binary ID:8 thrift.STRING + off += 3 + off += 4 + len(p.Binary) -func (p *Nesting2) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SetNesting", thrift.SET, 10) - offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.STRUCT, len(p.SetNesting)) + // p.String_ ID:9 thrift.STRING + off += 3 + off += 4 + len(p.String_) - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } + // p.SetNesting ID:10 thrift.SET + off += 3 + off += 5 for _, v := range p.SetNesting { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + off += v.BLength() } - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} -func (p *Nesting2) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 11) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.I32 ID:11 thrift.I32 + off += 3 + off += 4 + return off + 1 } -func (p *Nesting2) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapSimpleNesting", thrift.MAP, 1) - l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)) - for k, v := range p.MapSimpleNesting { - - l += k.BLength() +func (p *Nesting2) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += v.BLength() +func (p *Nesting2) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 2) - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 3) - l += bthrift.Binary.ByteLength(p.Byte) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 4) - l += bthrift.Binary.DoubleLength(p.Double) - - l += bthrift.Binary.FieldEndLength() - return l -} + off := 0 -func (p *Nesting2) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListNesting", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListNesting)) + // p.MapSimpleNesting ID:1 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = 12 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapSimpleNesting))) + off += 6 + for k, v := range p.MapSimpleNesting { + off += k.FastWriteNocopy(b[off:], w) + off += v.FastWriteNocopy(b[off:], w) + } + + // p.SimpleStruct ID:2 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += p.SimpleStruct.FastWriteNocopy(b[off:], w) + + // p.Byte ID:3 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + b[off] = byte(p.Byte) + off++ + + // p.Double ID:4 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Double))) + off += 8 + + // p.ListNesting ID:5 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListNesting))) + off += 5 for _, v := range p.ListNesting { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.I64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("NestingStruct", thrift.STRUCT, 7) - l += p.NestingStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 8) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 9) - l += bthrift.Binary.StringLength(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field10Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SetNesting", thrift.SET, 10) - l += bthrift.Binary.SetBeginLength(thrift.STRUCT, len(p.SetNesting)) - - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } + off += v.FastWriteNocopy(b[off:], w) + } + + // p.I64 ID:6 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.I64)) + off += 8 + + // p.NestingStruct ID:7 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += p.NestingStruct.FastWriteNocopy(b[off:], w) + + // p.Binary ID:8 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary) + + // p.String_ ID:9 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) + + // p.SetNesting ID:10 thrift.SET + b[off] = 14 + binary.BigEndian.PutUint16(b[off+1:], 10) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.SetNesting))) + off += 5 for _, v := range p.SetNesting { - l += v.BLength() + off += v.FastWriteNocopy(b[off:], w) } - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} -func (p *Nesting2) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 11) - l += bthrift.Binary.I32Length(p.I32) + // p.I32 ID:11 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 11) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.I32)) + off += 4 - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServiceSimpleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Nesting2) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10d: // p.MapSimpleNesting ID:1 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapSimpleNesting = make(map[*Simple]*Nesting, sz) + for i := 0; i < sz; i++ { + var k *Simple + var v *Nesting + k = NewSimple() + l, err = k.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + v = NewNesting() + l, err = v.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + p.MapSimpleNesting[k] = v + } + case 0x20c: // p.SimpleStruct ID:2 thrift.STRUCT + p.SimpleStruct = NewSimple() + l, err = p.SimpleStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x303: // p.Byte ID:3 thrift.I08 + p.Byte, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x404: // p.Double ID:4 thrift.DOUBLE + p.Double, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x50f: // p.ListNesting ID:5 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListNesting = make([]*Nesting, sz) + for i := 0; i < sz; i++ { + p.ListNesting[i] = NewNesting() + l, err = p.ListNesting[i].FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + } + case 0x60a: // p.I64 ID:6 thrift.I64 + p.I64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x70c: // p.NestingStruct ID:7 thrift.STRUCT + p.NestingStruct = NewNesting() + l, err = p.NestingStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x80b: // p.Binary ID:8 thrift.STRING + p.Binary, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x90b: // p.String_ ID:9 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xa0e: // p.SetNesting ID:10 thrift.SET + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.SetNesting = make([]*Nesting, sz) + for i := 0; i < sz; i++ { + p.SetNesting[i] = NewNesting() + l, err = p.SetNesting[i].FastRead(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } } + case 0xb08: // p.I32 ID:11 thrift.I32 + p.I32, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Nesting2[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceSimpleMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewSimple() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceSimpleMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServiceSimpleMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *BaselineServiceSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *BaselineServiceSimpleMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceSimpleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("SimpleMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServiceSimpleMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *BaselineServiceSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *BaselineServiceSimpleMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServiceSimpleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServiceSimpleMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewSimple() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceSimpleMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceSimpleMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewSimple() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceSimpleMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *BaselineServiceSimpleMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *BaselineServiceSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *BaselineServiceSimpleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("SimpleMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServiceSimpleMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *BaselineServiceSimpleMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *BaselineServiceSimpleMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *BaselineServicePartialSimpleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServiceSimpleMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewSimple() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceSimpleMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServicePartialSimpleMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewPartialSimple() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServicePartialSimpleMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServicePartialSimpleMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *BaselineServicePartialSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *BaselineServicePartialSimpleMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServicePartialSimpleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServicePartialSimpleMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *BaselineServicePartialSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *BaselineServicePartialSimpleMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServicePartialSimpleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServicePartialSimpleMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewPartialSimple() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServicePartialSimpleMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewPartialSimple() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServicePartialSimpleMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *BaselineServicePartialSimpleMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *BaselineServicePartialSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *BaselineServicePartialSimpleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *BaselineServicePartialSimpleMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServicePartialSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *BaselineServicePartialSimpleMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *BaselineServicePartialSimpleMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *BaselineServiceNestingMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServicePartialSimpleMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewPartialSimple() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServicePartialSimpleMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceNestingMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewNesting() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceNestingMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServiceNestingMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *BaselineServiceNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *BaselineServiceNestingMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceNestingMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NestingMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServiceNestingMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *BaselineServiceNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *BaselineServiceNestingMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServiceNestingMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServiceNestingMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewNesting() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceNestingMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceNestingMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewNesting() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceNestingMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServiceNestingMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *BaselineServiceNestingMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NestingMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *BaselineServiceNestingMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *BaselineServiceNestingMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *BaselineServiceNestingMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *BaselineServicePartialNestingMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServiceNestingMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewNesting() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceNestingMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServicePartialNestingMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewPartialNesting() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServicePartialNestingMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServicePartialNestingMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *BaselineServicePartialNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *BaselineServicePartialNestingMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServicePartialNestingMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNestingMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServicePartialNestingMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *BaselineServicePartialNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *BaselineServicePartialNestingMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServicePartialNestingMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServicePartialNestingMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewPartialNesting() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServicePartialNestingMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServicePartialNestingMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewPartialNesting() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServicePartialNestingMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServicePartialNestingMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServicePartialNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *BaselineServicePartialNestingMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNestingMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *BaselineServicePartialNestingMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServicePartialNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *BaselineServicePartialNestingMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *BaselineServicePartialNestingMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *BaselineServiceNesting2MethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServicePartialNestingMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewPartialNesting() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServicePartialNestingMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceNesting2MethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewNesting2() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceNesting2MethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *BaselineServiceNesting2MethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *BaselineServiceNesting2MethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *BaselineServiceNesting2MethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceNesting2MethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2Method_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *BaselineServiceNesting2MethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *BaselineServiceNesting2MethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *BaselineServiceNesting2MethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *BaselineServiceNesting2MethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *BaselineServiceNesting2MethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewNesting2() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceNesting2MethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *BaselineServiceNesting2MethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewNesting2() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *BaselineServiceNesting2MethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *BaselineServiceNesting2MethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *BaselineServiceNesting2MethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *BaselineServiceNesting2MethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2Method_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *BaselineServiceNesting2MethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *BaselineServiceNesting2MethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *BaselineServiceNesting2MethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *BaselineServiceNesting2MethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l -} - -func (p *BaselineServiceSimpleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} -func (p *BaselineServiceSimpleMethodResult) GetResult() interface{} { - return p.Success + b[off] = 0 + return off + 1 } -func (p *BaselineServicePartialSimpleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServicePartialSimpleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServiceNestingMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServiceNestingMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServicePartialNestingMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServicePartialNestingMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServiceNesting2MethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServiceNesting2MethodResult) GetResult() interface{} { - return p.Success +func (p *BaselineServiceNesting2MethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewNesting2() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BaselineServiceNesting2MethodResult[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/deep/deep.ref.go b/testdata/kitex_gen/deep/deep.ref.go index cb9cfd97..24b4b864 100644 --- a/testdata/kitex_gen/deep/deep.ref.go +++ b/testdata/kitex_gen/deep/deep.ref.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package deep @@ -6,8 +6,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" ) const ( @@ -42,7 +40,6 @@ func FOOFromString(s string) (FOO, error) { } func FOOPtr(v FOO) *FOO { return &v } - func (p *FOO) Scan(value interface{}) (err error) { var result sql.NullInt64 err = result.Scan(value) @@ -66,6 +63,9 @@ func NewTestStruct() *TestStruct { return &TestStruct{} } +func (p *TestStruct) InitDefault() { +} + func (p *TestStruct) GetA() (v int64) { return p.A } @@ -73,171 +73,6 @@ func (p *TestStruct) GetA() (v int64) { func (p *TestStruct) GetB() (v string) { return p.B } -func (p *TestStruct) SetA(val int64) { - p.A = val -} -func (p *TestStruct) SetB(val string) { - p.B = val -} - -var fieldIDToName_TestStruct = map[int16]string{ - 1: "a", - 2: "b", -} - -func (p *TestStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TestStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TestStruct) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.A = v - } - return nil -} - -func (p *TestStruct) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.B = v - } - return nil -} - -func (p *TestStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TestStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *TestStruct) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *TestStruct) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} func (p *TestStruct) String() string { if p == nil { @@ -246,32 +81,7 @@ func (p *TestStruct) String() string { return fmt.Sprintf("TestStruct(%+v)", *p) } -func (p *TestStruct) DeepEqual(ano *TestStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - return true -} - -func (p *TestStruct) Field1DeepEqual(src int64) bool { - - if p.A != src { - return false - } - return true -} -func (p *TestStruct) Field2DeepEqual(src string) bool { - - if strings.Compare(p.B, src) != 0 { - return false - } - return true +var fieldIDToName_TestStruct = map[int16]string{ + 1: "a", + 2: "b", } diff --git a/testdata/kitex_gen/deep/k-deep.ref.go b/testdata/kitex_gen/deep/k-deep.ref.go index f72f93e1..934bb260 100644 --- a/testdata/kitex_gen/deep/k-deep.ref.go +++ b/testdata/kitex_gen/deep/k-deep.ref.go @@ -1,202 +1,95 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package deep import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) +func (p *TestStruct) BLength() int { + if p == nil { + return 1 + } + off := 0 -func (p *TestStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError + // p.A ID:1 thrift.I64 + off += 3 + off += 8 + + // p.B ID:2 thrift.STRING + off += 3 + off += 4 + len(p.B) + return off + 1 +} + +func (p *TestStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *TestStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } + off := 0 + + // p.A ID:1 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.A)) + off += 8 + + // p.B ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.B) + + b[off] = 0 + return off + 1 +} +func (p *TestStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10a: // p.A ID:1 thrift.I64 + p.A, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20b: // p.B ID:2 thrift.STRING + p.B, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TestStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_TestStruct[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TestStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.A = v - - } - return offset, nil -} - -func (p *TestStruct) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.B = v - - } - return offset, nil -} - -// for compatibility -func (p *TestStruct) FastWrite(buf []byte) int { - return 0 -} - -func (p *TestStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TestStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *TestStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TestStruct") - if p != nil { - l += p.field1Length() - l += p.field2Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *TestStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "a", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.A) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TestStruct) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "b", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.B) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TestStruct) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("a", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.A) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *TestStruct) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("b", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.B) - - l += bthrift.Binary.FieldEndLength() - return l + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/example/example.go b/testdata/kitex_gen/example/example.go index 3a65bd95..5bd50357 100644 --- a/testdata/kitex_gen/example/example.go +++ b/testdata/kitex_gen/example/example.go @@ -1,16 +1,14 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package example import ( - "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" - "github.com/cloudwego/dynamicgo/testdata/kitex_gen/deep" "context" "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" + "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" + "github.com/cloudwego/dynamicgo/testdata/kitex_gen/deep" ) type FOO int64 @@ -41,7 +39,6 @@ func FOOFromString(s string) (FOO, error) { } func FOOPtr(v FOO) *FOO { return &v } - func (p *FOO) Scan(value interface{}) (err error) { var result sql.NullInt64 err = result.Scan(value) @@ -57,7 +54,7 @@ func (p *FOO) Value() (driver.Value, error) { } type ExampleReq struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` InnerBase int32 `thrift:"InnerBase,3" json:"InnerBase"` Base *base.Base `thrift:"Base,255,required" json:"Base"` Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` @@ -67,6 +64,9 @@ func NewExampleReq() *ExampleReq { return &ExampleReq{} } +func (p *ExampleReq) InitDefault() { +} + var ExampleReq_Msg_DEFAULT string func (p *ExampleReq) GetMsg() (v string) { @@ -92,25 +92,6 @@ func (p *ExampleReq) GetBase() (v *base.Base) { func (p *ExampleReq) GetSubfix() (v float64) { return p.Subfix } -func (p *ExampleReq) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleReq) SetInnerBase(val int32) { - p.InnerBase = val -} -func (p *ExampleReq) SetBase(val *base.Base) { - p.Base = val -} -func (p *ExampleReq) SetSubfix(val float64) { - p.Subfix = val -} - -var fieldIDToName_ExampleReq = map[int16]string{ - 1: "Msg", - 3: "InnerBase", - 255: "Base", - 32767: "Subfix", -} func (p *ExampleReq) IsSetMsg() bool { return p.Msg != nil @@ -120,249 +101,6 @@ func (p *ExampleReq) IsSetBase() bool { return p.Base != nil } -func (p *ExampleReq) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - issetBase = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleReq) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.InnerBase = v - } - return nil -} - -func (p *ExampleReq) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleReq) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleReq"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleReq) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleReq) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.I32, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.InnerBase); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleReq) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleReq) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - func (p *ExampleReq) String() string { if p == nil { return "" @@ -370,63 +108,15 @@ func (p *ExampleReq) String() string { return fmt.Sprintf("ExampleReq(%+v)", *p) } -func (p *ExampleReq) DeepEqual(ano *ExampleReq) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field3DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - return true -} - -func (p *ExampleReq) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleReq) Field3DeepEqual(src int32) bool { - - if p.InnerBase != src { - return false - } - return true -} -func (p *ExampleReq) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleReq) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true +var fieldIDToName_ExampleReq = map[int16]string{ + 1: "Msg", + 3: "InnerBase", + 255: "Base", + 32767: "Subfix", } type ExampleToSnakeCase struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` ReqList []string `thrift:"req_list,2" json:"req_list"` InnerBase int32 `thrift:"InnerBase,3" json:"InnerBase"` Base *base.Base `thrift:"Base,255,required" json:"Base"` @@ -436,6 +126,9 @@ func NewExampleToSnakeCase() *ExampleToSnakeCase { return &ExampleToSnakeCase{} } +func (p *ExampleToSnakeCase) InitDefault() { +} + var ExampleToSnakeCase_Msg_DEFAULT string func (p *ExampleToSnakeCase) GetMsg() (v string) { @@ -461,25 +154,6 @@ func (p *ExampleToSnakeCase) GetBase() (v *base.Base) { } return p.Base } -func (p *ExampleToSnakeCase) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleToSnakeCase) SetReqList(val []string) { - p.ReqList = val -} -func (p *ExampleToSnakeCase) SetInnerBase(val int32) { - p.InnerBase = val -} -func (p *ExampleToSnakeCase) SetBase(val *base.Base) { - p.Base = val -} - -var fieldIDToName_ExampleToSnakeCase = map[int16]string{ - 1: "Msg", - 2: "req_list", - 3: "InnerBase", - 255: "Base", -} func (p *ExampleToSnakeCase) IsSetMsg() bool { return p.Msg != nil @@ -489,270 +163,6 @@ func (p *ExampleToSnakeCase) IsSetBase() bool { return p.Base != nil } -func (p *ExampleToSnakeCase) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.LIST { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - issetBase = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleToSnakeCase[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleToSnakeCase[fieldId])) -} - -func (p *ExampleToSnakeCase) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleToSnakeCase) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ReqList = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.ReqList = append(p.ReqList, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleToSnakeCase) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.InnerBase = v - } - return nil -} - -func (p *ExampleToSnakeCase) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleToSnakeCase) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleToSnakeCase"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleToSnakeCase) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleToSnakeCase) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req_list", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRING, len(p.ReqList)); err != nil { - return err - } - for _, v := range p.ReqList { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleToSnakeCase) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.I32, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.InnerBase); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleToSnakeCase) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - func (p *ExampleToSnakeCase) String() string { if p == nil { return "" @@ -760,69 +170,15 @@ func (p *ExampleToSnakeCase) String() string { return fmt.Sprintf("ExampleToSnakeCase(%+v)", *p) } -func (p *ExampleToSnakeCase) DeepEqual(ano *ExampleToSnakeCase) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.ReqList) { - return false - } - if !p.Field3DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true -} - -func (p *ExampleToSnakeCase) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleToSnakeCase) Field2DeepEqual(src []string) bool { - - if len(p.ReqList) != len(src) { - return false - } - for i, v := range p.ReqList { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleToSnakeCase) Field3DeepEqual(src int32) bool { - - if p.InnerBase != src { - return false - } - return true -} -func (p *ExampleToSnakeCase) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleToSnakeCase = map[int16]string{ + 1: "Msg", + 2: "req_list", + 3: "InnerBase", + 255: "Base", } type ExampleResp struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` RequiredField string `thrift:"required_field,2,required" json:"required_field"` BaseResp *base.BaseResp `thrift:"BaseResp,32767" json:"BaseResp"` } @@ -831,6 +187,9 @@ func NewExampleResp() *ExampleResp { return &ExampleResp{} } +func (p *ExampleResp) InitDefault() { +} + var ExampleResp_Msg_DEFAULT string func (p *ExampleResp) GetMsg() (v string) { @@ -852,21 +211,6 @@ func (p *ExampleResp) GetBaseResp() (v *base.BaseResp) { } return p.BaseResp } -func (p *ExampleResp) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleResp) SetRequiredField(val string) { - p.RequiredField = val -} -func (p *ExampleResp) SetBaseResp(val *base.BaseResp) { - p.BaseResp = val -} - -var fieldIDToName_ExampleResp = map[int16]string{ - 1: "Msg", - 2: "required_field", - 32767: "BaseResp", -} func (p *ExampleResp) IsSetMsg() bool { return p.Msg != nil @@ -876,209 +220,6 @@ func (p *ExampleResp) IsSetBaseResp() bool { return p.BaseResp != nil } -func (p *ExampleResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetRequiredField bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - issetRequiredField = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetRequiredField { - fieldId = 2 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.RequiredField = v - } - return nil -} - -func (p *ExampleResp) ReadField32767(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleResp) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleResp) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("required_field", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.RequiredField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleResp) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 32767); err != nil { - goto WriteFieldBeginError - } - if err := p.BaseResp.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - func (p *ExampleResp) String() string { if p == nil { return "" @@ -1086,49 +227,10 @@ func (p *ExampleResp) String() string { return fmt.Sprintf("ExampleResp(%+v)", *p) } -func (p *ExampleResp) DeepEqual(ano *ExampleResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.RequiredField) { - return false - } - if !p.Field32767DeepEqual(ano.BaseResp) { - return false - } - return true -} - -func (p *ExampleResp) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleResp) Field2DeepEqual(src string) bool { - - if strings.Compare(p.RequiredField, src) != 0 { - return false - } - return true -} -func (p *ExampleResp) Field32767DeepEqual(src *base.BaseResp) bool { - - if !p.BaseResp.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleResp = map[int16]string{ + 1: "Msg", + 2: "required_field", + 32767: "BaseResp", } type A struct { @@ -1140,6 +242,9 @@ func NewA() *A { return &A{} } +func (p *A) InitDefault() { +} + func (p *A) GetSelf() (v string) { return p.Self } @@ -1147,11 +252,12 @@ func (p *A) GetSelf() (v string) { func (p *A) GetFoo() (v FOO) { return p.Foo } -func (p *A) SetSelf(val string) { - p.Self = val -} -func (p *A) SetFoo(val FOO) { - p.Foo = val + +func (p *A) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("A(%+v)", *p) } var fieldIDToName_A = map[int16]string{ @@ -1159,208 +265,17 @@ var fieldIDToName_A = map[int16]string{ 2: "foo", } -func (p *A) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_A[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *A) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Self = v - } - return nil -} - -func (p *A) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Foo = FOO(v) - } - return nil -} - -func (p *A) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("A"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *A) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("self", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Self); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *A) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("foo", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(int32(p.Foo)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *A) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("A(%+v)", *p) -} - -func (p *A) DeepEqual(ano *A) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Self) { - return false - } - if !p.Field2DeepEqual(ano.Foo) { - return false - } - return true -} - -func (p *A) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Self, src) != 0 { - return false - } - return true -} -func (p *A) Field2DeepEqual(src FOO) bool { - - if p.Foo != src { - return false - } - return true -} - -type ExampleDefaultValue struct { - String_ string `thrift:"String,1" json:"String"` - Int int32 `thrift:"Int,2" json:"Int"` - Double float64 `thrift:"Double,3" json:"Double"` - Bool bool `thrift:"Bool,4" json:"Bool"` - List []string `thrift:"List,5" json:"List"` - Map map[string]string `thrift:"Map,6" json:"Map"` - Set []string `thrift:"Set,7" json:"Set"` - ConstString string `thrift:"ConstString,8" json:"ConstString"` - Enum FOO `thrift:"Enum,9" json:"Enum"` -} +type ExampleDefaultValue struct { + String_ string `thrift:"String,1" json:"String"` + Int int32 `thrift:"Int,2" json:"Int"` + Double float64 `thrift:"Double,3" json:"Double"` + Bool bool `thrift:"Bool,4" json:"Bool"` + List []string `thrift:"List,5" json:"List"` + Map map[string]string `thrift:"Map,6" json:"Map"` + Set []string `thrift:"Set,7" json:"Set"` + ConstString string `thrift:"ConstString,8" json:"ConstString"` + Enum FOO `thrift:"Enum,9" json:"Enum"` +} func NewExampleDefaultValue() *ExampleDefaultValue { return &ExampleDefaultValue{ @@ -1385,6 +300,26 @@ func NewExampleDefaultValue() *ExampleDefaultValue { } } +func (p *ExampleDefaultValue) InitDefault() { + p.String_ = "default" + p.Int = 1 + p.Double = 1.1 + p.Bool = true + p.List = []string{ + "a", + "b", + } + p.Map = map[string]string{ + "a": "b", + } + p.Set = []string{ + "a", + "b", + } + p.ConstString = deep.ConstString + p.Enum = FOO_A +} + func (p *ExampleDefaultValue) GetString() (v string) { return p.String_ } @@ -1420,32 +355,12 @@ func (p *ExampleDefaultValue) GetConstString() (v string) { func (p *ExampleDefaultValue) GetEnum() (v FOO) { return p.Enum } -func (p *ExampleDefaultValue) SetString(val string) { - p.String_ = val -} -func (p *ExampleDefaultValue) SetInt(val int32) { - p.Int = val -} -func (p *ExampleDefaultValue) SetDouble(val float64) { - p.Double = val -} -func (p *ExampleDefaultValue) SetBool(val bool) { - p.Bool = val -} -func (p *ExampleDefaultValue) SetList(val []string) { - p.List = val -} -func (p *ExampleDefaultValue) SetMap(val map[string]string) { - p.Map = val -} -func (p *ExampleDefaultValue) SetSet(val []string) { - p.Set = val -} -func (p *ExampleDefaultValue) SetConstString(val string) { - p.ConstString = val -} -func (p *ExampleDefaultValue) SetEnum(val FOO) { - p.Enum = val + +func (p *ExampleDefaultValue) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ExampleDefaultValue(%+v)", *p) } var fieldIDToName_ExampleDefaultValue = map[int16]string{ @@ -1460,652 +375,6 @@ var fieldIDToName_ExampleDefaultValue = map[int16]string{ 9: "Enum", } -func (p *ExampleDefaultValue) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.LIST { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.SET { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRING { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.I32 { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDefaultValue[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Int = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Bool = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.List = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.List = append(p.List, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleDefaultValue) ReadField6(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Map = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Map[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleDefaultValue) ReadField7(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.Set = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.Set = append(p.Set, _elem) - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleDefaultValue) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.ConstString = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Enum = FOO(v) - } - return nil -} - -func (p *ExampleDefaultValue) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDefaultValue"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Int); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Bool", thrift.BOOL, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Bool); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("List", thrift.LIST, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRING, len(p.List)); err != nil { - return err - } - for _, v := range p.List { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Map", thrift.MAP, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Map)); err != nil { - return err - } - for k, v := range p.Map { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Set", thrift.SET, 7); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Set)); err != nil { - return err - } - for i := 0; i < len(p.Set); i++ { - for j := i + 1; j < len(p.Set); j++ { - if func(tgt, src string) bool { - if strings.Compare(tgt, src) != 0 { - return false - } - return true - }(p.Set[i], p.Set[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.Set[i])) - } - } - } - for _, v := range p.Set { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ConstString", thrift.STRING, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.ConstString); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Enum", thrift.I32, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(int32(p.Enum)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} - -func (p *ExampleDefaultValue) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleDefaultValue(%+v)", *p) -} - -func (p *ExampleDefaultValue) DeepEqual(ano *ExampleDefaultValue) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.String_) { - return false - } - if !p.Field2DeepEqual(ano.Int) { - return false - } - if !p.Field3DeepEqual(ano.Double) { - return false - } - if !p.Field4DeepEqual(ano.Bool) { - return false - } - if !p.Field5DeepEqual(ano.List) { - return false - } - if !p.Field6DeepEqual(ano.Map) { - return false - } - if !p.Field7DeepEqual(ano.Set) { - return false - } - if !p.Field8DeepEqual(ano.ConstString) { - return false - } - if !p.Field9DeepEqual(ano.Enum) { - return false - } - return true -} - -func (p *ExampleDefaultValue) Field1DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *ExampleDefaultValue) Field2DeepEqual(src int32) bool { - - if p.Int != src { - return false - } - return true -} -func (p *ExampleDefaultValue) Field3DeepEqual(src float64) bool { - - if p.Double != src { - return false - } - return true -} -func (p *ExampleDefaultValue) Field4DeepEqual(src bool) bool { - - if p.Bool != src { - return false - } - return true -} -func (p *ExampleDefaultValue) Field5DeepEqual(src []string) bool { - - if len(p.List) != len(src) { - return false - } - for i, v := range p.List { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleDefaultValue) Field6DeepEqual(src map[string]string) bool { - - if len(p.Map) != len(src) { - return false - } - for k, v := range p.Map { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleDefaultValue) Field7DeepEqual(src []string) bool { - - if len(p.Set) != len(src) { - return false - } - for i, v := range p.Set { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleDefaultValue) Field8DeepEqual(src string) bool { - - if strings.Compare(p.ConstString, src) != 0 { - return false - } - return true -} -func (p *ExampleDefaultValue) Field9DeepEqual(src FOO) bool { - - if p.Enum != src { - return false - } - return true -} - type DeepRef struct { DeepRef *deep.TestStruct `thrift:"DeepRef,1" json:"DeepRef"` } @@ -2114,6 +383,9 @@ func NewDeepRef() *DeepRef { return &DeepRef{} } +func (p *DeepRef) InitDefault() { +} + var DeepRef_DeepRef_DEFAULT *deep.TestStruct func (p *DeepRef) GetDeepRef() (v *deep.TestStruct) { @@ -2122,131 +394,11 @@ func (p *DeepRef) GetDeepRef() (v *deep.TestStruct) { } return p.DeepRef } -func (p *DeepRef) SetDeepRef(val *deep.TestStruct) { - p.DeepRef = val -} - -var fieldIDToName_DeepRef = map[int16]string{ - 1: "DeepRef", -} func (p *DeepRef) IsSetDeepRef() bool { return p.DeepRef != nil } -func (p *DeepRef) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DeepRef[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *DeepRef) ReadField1(iprot thrift.TProtocol) error { - p.DeepRef = deep.NewTestStruct() - if err := p.DeepRef.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *DeepRef) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("DeepRef"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *DeepRef) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("DeepRef", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.DeepRef.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *DeepRef) String() string { if p == nil { return "" @@ -2254,24 +406,8 @@ func (p *DeepRef) String() string { return fmt.Sprintf("DeepRef(%+v)", *p) } -func (p *DeepRef) DeepEqual(ano *DeepRef) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.DeepRef) { - return false - } - return true -} - -func (p *DeepRef) Field1DeepEqual(src *deep.TestStruct) bool { - - if !p.DeepRef.DeepEqual(src) { - return false - } - return true +var fieldIDToName_DeepRef = map[int16]string{ + 1: "DeepRef", } type Exception struct { @@ -2283,6 +419,9 @@ func NewException() *Exception { return &Exception{} } +func (p *Exception) InitDefault() { +} + func (p *Exception) GetCode() (v int32) { return p.Code } @@ -2290,171 +429,6 @@ func (p *Exception) GetCode() (v int32) { func (p *Exception) GetMsg() (v string) { return p.Msg } -func (p *Exception) SetCode(val int32) { - p.Code = val -} -func (p *Exception) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_Exception = map[int16]string{ - 1: "code", - 255: "msg", -} - -func (p *Exception) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRING { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Exception) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Code = v - } - return nil -} - -func (p *Exception) ReadField255(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil -} - -func (p *Exception) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Exception"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Exception) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Exception) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 255); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} func (p *Exception) String() string { if p == nil { @@ -2466,34 +440,9 @@ func (p *Exception) Error() string { return p.String() } -func (p *Exception) DeepEqual(ano *Exception) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Code) { - return false - } - if !p.Field255DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *Exception) Field1DeepEqual(src int32) bool { - - if p.Code != src { - return false - } - return true -} -func (p *Exception) Field255DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_Exception = map[int16]string{ + 1: "code", + 255: "msg", } type ExampleService interface { @@ -2503,526 +452,15 @@ type ExampleService interface { Foo(ctx context.Context, req *A) (r *A, err error) - Ping(ctx context.Context, msg string) (r string, err error) - - Oneway(ctx context.Context, msg string) (err error) - - Void(ctx context.Context, msg string) (err error) - - ExampleToSnakeCase(ctx context.Context, req *ExampleToSnakeCase) (err error) - - ExampleDefaultValue(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) -} - -type ExampleServiceClient struct { - c thrift.TClient -} - -func NewExampleServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewExampleServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewExampleServiceClient(c thrift.TClient) *ExampleServiceClient { - return &ExampleServiceClient{ - c: c, - } -} - -func (p *ExampleServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *ExampleServiceClient) ExampleDeepRef(ctx context.Context, req *DeepRef) (r *DeepRef, err error) { - var _args ExampleServiceExampleDeepRefArgs - _args.Req = req - var _result ExampleServiceExampleDeepRefResult - if err = p.Client_().Call(ctx, "ExampleDeepRef", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *ExampleServiceClient) ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) { - var _args ExampleServiceExampleMethodArgs - _args.Req = req - var _result ExampleServiceExampleMethodResult - if err = p.Client_().Call(ctx, "ExampleMethod", &_args, &_result); err != nil { - return - } - switch { - case _result.Err != nil: - return r, _result.Err - } - return _result.GetSuccess(), nil -} - -func (p *ExampleServiceClient) Foo(ctx context.Context, req *A) (r *A, err error) { - var _args ExampleServiceFooArgs - _args.Req = req - var _result ExampleServiceFooResult - if err = p.Client_().Call(ctx, "Foo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *ExampleServiceClient) Ping(ctx context.Context, msg string) (r string, err error) { - var _args ExampleServicePingArgs - _args.Msg = msg - var _result ExampleServicePingResult - if err = p.Client_().Call(ctx, "Ping", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *ExampleServiceClient) Oneway(ctx context.Context, msg string) (err error) { - var _args ExampleServiceOnewayArgs - _args.Msg = msg - if err = p.Client_().Call(ctx, "Oneway", &_args, nil); err != nil { - return - } - return nil -} - -func (p *ExampleServiceClient) Void(ctx context.Context, msg string) (err error) { - var _args ExampleServiceVoidArgs - _args.Msg = msg - var _result ExampleServiceVoidResult - if err = p.Client_().Call(ctx, "Void", &_args, &_result); err != nil { - return - } - return nil -} - -func (p *ExampleServiceClient) ExampleToSnakeCase(ctx context.Context, req *ExampleToSnakeCase) (err error) { - var _args ExampleServiceExampleToSnakeCaseArgs - _args.Req = req - var _result ExampleServiceExampleToSnakeCaseResult - if err = p.Client_().Call(ctx, "ExampleToSnakeCase", &_args, &_result); err != nil { - return - } - return nil -} - -func (p *ExampleServiceClient) ExampleDefaultValue(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) { - var _args ExampleServiceExampleDefaultValueArgs - _args.Req = req - var _result ExampleServiceExampleDefaultValueResult - if err = p.Client_().Call(ctx, "ExampleDefaultValue", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type ExampleServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ExampleService -} - -func (p *ExampleServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ExampleServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *ExampleServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewExampleServiceProcessor(handler ExampleService) *ExampleServiceProcessor { - self := &ExampleServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("ExampleDeepRef", &exampleServiceProcessorExampleDeepRef{handler: handler}) - self.AddToProcessorMap("ExampleMethod", &exampleServiceProcessorExampleMethod{handler: handler}) - self.AddToProcessorMap("Foo", &exampleServiceProcessorFoo{handler: handler}) - self.AddToProcessorMap("Ping", &exampleServiceProcessorPing{handler: handler}) - self.AddToProcessorMap("Oneway", &exampleServiceProcessorOneway{handler: handler}) - self.AddToProcessorMap("Void", &exampleServiceProcessorVoid{handler: handler}) - self.AddToProcessorMap("ExampleToSnakeCase", &exampleServiceProcessorExampleToSnakeCase{handler: handler}) - self.AddToProcessorMap("ExampleDefaultValue", &exampleServiceProcessorExampleDefaultValue{handler: handler}) - return self -} -func (p *ExampleServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type exampleServiceProcessorExampleDeepRef struct { - handler ExampleService -} - -func (p *exampleServiceProcessorExampleDeepRef) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleDeepRefArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleDeepRef", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleDeepRefResult{} - var retval *DeepRef - if retval, err2 = p.handler.ExampleDeepRef(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleDeepRef: "+err2.Error()) - oprot.WriteMessageBegin("ExampleDeepRef", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleDeepRef", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorExampleMethod struct { - handler ExampleService -} - -func (p *exampleServiceProcessorExampleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleMethodResult{} - var retval *ExampleResp - if retval, err2 = p.handler.ExampleMethod(ctx, args.Req); err2 != nil { - switch v := err2.(type) { - case *Exception: - result.Err = v - default: - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleMethod: "+err2.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorFoo struct { - handler ExampleService -} - -func (p *exampleServiceProcessorFoo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceFooArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceFooResult{} - var retval *A - if retval, err2 = p.handler.Foo(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Foo: "+err2.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Foo", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorPing struct { - handler ExampleService -} - -func (p *exampleServiceProcessorPing) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServicePingArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServicePingResult{} - var retval string - if retval, err2 = p.handler.Ping(ctx, args.Msg); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Ping: "+err2.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = &retval - } - if err2 = oprot.WriteMessageBegin("Ping", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorOneway struct { - handler ExampleService -} - -func (p *exampleServiceProcessorOneway) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceOnewayArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - if err2 = p.handler.Oneway(ctx, args.Msg); err2 != nil { - return true, err2 - } - return true, nil -} - -type exampleServiceProcessorVoid struct { - handler ExampleService -} - -func (p *exampleServiceProcessorVoid) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceVoidArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Void", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceVoidResult{} - if err2 = p.handler.Void(ctx, args.Msg); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Void: "+err2.Error()) - oprot.WriteMessageBegin("Void", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - if err2 = oprot.WriteMessageBegin("Void", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorExampleToSnakeCase struct { - handler ExampleService -} - -func (p *exampleServiceProcessorExampleToSnakeCase) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleToSnakeCaseArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleToSnakeCase", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleToSnakeCaseResult{} - if err2 = p.handler.ExampleToSnakeCase(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleToSnakeCase: "+err2.Error()) - oprot.WriteMessageBegin("ExampleToSnakeCase", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - if err2 = oprot.WriteMessageBegin("ExampleToSnakeCase", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type exampleServiceProcessorExampleDefaultValue struct { - handler ExampleService -} + Ping(ctx context.Context, msg string) (r string, err error) -func (p *exampleServiceProcessorExampleDefaultValue) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleDefaultValueArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleDefaultValue", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } + Oneway(ctx context.Context, msg string) (err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleDefaultValueResult{} - var retval *ExampleDefaultValue - if retval, err2 = p.handler.ExampleDefaultValue(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleDefaultValue: "+err2.Error()) - oprot.WriteMessageBegin("ExampleDefaultValue", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleDefaultValue", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err + Void(ctx context.Context, msg string) (err error) + + ExampleToSnakeCase(ctx context.Context, req *ExampleToSnakeCase) (err error) + + ExampleDefaultValue(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) } type ExampleServiceExampleDeepRefArgs struct { @@ -3033,6 +471,9 @@ func NewExampleServiceExampleDeepRefArgs() *ExampleServiceExampleDeepRefArgs { return &ExampleServiceExampleDeepRefArgs{} } +func (p *ExampleServiceExampleDeepRefArgs) InitDefault() { +} + var ExampleServiceExampleDeepRefArgs_Req_DEFAULT *DeepRef func (p *ExampleServiceExampleDeepRefArgs) GetReq() (v *DeepRef) { @@ -3041,131 +482,11 @@ func (p *ExampleServiceExampleDeepRefArgs) GetReq() (v *DeepRef) { } return p.Req } -func (p *ExampleServiceExampleDeepRefArgs) SetReq(val *DeepRef) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleDeepRefArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleDeepRefArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleDeepRefArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDeepRefArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewDeepRef() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleDeepRefArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDeepRef_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDeepRefArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleDeepRefArgs) String() string { if p == nil { return "" @@ -3173,34 +494,21 @@ func (p *ExampleServiceExampleDeepRefArgs) String() string { return fmt.Sprintf("ExampleServiceExampleDeepRefArgs(%+v)", *p) } -func (p *ExampleServiceExampleDeepRefArgs) DeepEqual(ano *ExampleServiceExampleDeepRefArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleDeepRefArgs) Field1DeepEqual(src *DeepRef) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleDeepRefArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleDeepRefResult struct { - Success *DeepRef `thrift:"success,0" json:"success,omitempty"` + Success *DeepRef `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceExampleDeepRefResult() *ExampleServiceExampleDeepRefResult { return &ExampleServiceExampleDeepRefResult{} } +func (p *ExampleServiceExampleDeepRefResult) InitDefault() { +} + var ExampleServiceExampleDeepRefResult_Success_DEFAULT *DeepRef func (p *ExampleServiceExampleDeepRefResult) GetSuccess() (v *DeepRef) { @@ -3209,133 +517,11 @@ func (p *ExampleServiceExampleDeepRefResult) GetSuccess() (v *DeepRef) { } return p.Success } -func (p *ExampleServiceExampleDeepRefResult) SetSuccess(x interface{}) { - p.Success = x.(*DeepRef) -} - -var fieldIDToName_ExampleServiceExampleDeepRefResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceExampleDeepRefResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceExampleDeepRefResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDeepRefResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewDeepRef() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleDeepRefResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDeepRef_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDeepRefResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceExampleDeepRefResult) String() string { if p == nil { return "" @@ -3343,24 +529,8 @@ func (p *ExampleServiceExampleDeepRefResult) String() string { return fmt.Sprintf("ExampleServiceExampleDeepRefResult(%+v)", *p) } -func (p *ExampleServiceExampleDeepRefResult) DeepEqual(ano *ExampleServiceExampleDeepRefResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceExampleDeepRefResult) Field0DeepEqual(src *DeepRef) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleDeepRefResult = map[int16]string{ + 0: "success", } type ExampleServiceExampleMethodArgs struct { @@ -3371,6 +541,9 @@ func NewExampleServiceExampleMethodArgs() *ExampleServiceExampleMethodArgs { return &ExampleServiceExampleMethodArgs{} } +func (p *ExampleServiceExampleMethodArgs) InitDefault() { +} + var ExampleServiceExampleMethodArgs_Req_DEFAULT *ExampleReq func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { @@ -3379,131 +552,11 @@ func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { } return p.Req } -func (p *ExampleServiceExampleMethodArgs) SetReq(val *ExampleReq) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleReq() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleMethodArgs) String() string { if p == nil { return "" @@ -3511,35 +564,22 @@ func (p *ExampleServiceExampleMethodArgs) String() string { return fmt.Sprintf("ExampleServiceExampleMethodArgs(%+v)", *p) } -func (p *ExampleServiceExampleMethodArgs) DeepEqual(ano *ExampleServiceExampleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodArgs) Field1DeepEqual(src *ExampleReq) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleMethodResult struct { - Success *ExampleResp `thrift:"success,0" json:"success,omitempty"` - Err *Exception `thrift:"err,1" json:"err,omitempty"` + Success *ExampleResp `thrift:"success,0,optional" json:"success,omitempty"` + Err *Exception `thrift:"err,1,optional" json:"err,omitempty"` } func NewExampleServiceExampleMethodResult() *ExampleServiceExampleMethodResult { return &ExampleServiceExampleMethodResult{} } +func (p *ExampleServiceExampleMethodResult) InitDefault() { +} + var ExampleServiceExampleMethodResult_Success_DEFAULT *ExampleResp func (p *ExampleServiceExampleMethodResult) GetSuccess() (v *ExampleResp) { @@ -3557,17 +597,6 @@ func (p *ExampleServiceExampleMethodResult) GetErr() (v *Exception) { } return p.Err } -func (p *ExampleServiceExampleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleResp) -} -func (p *ExampleServiceExampleMethodResult) SetErr(val *Exception) { - p.Err = val -} - -var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ - 0: "success", - 1: "err", -} func (p *ExampleServiceExampleMethodResult) IsSetSuccess() bool { return p.Success != nil @@ -3577,162 +606,6 @@ func (p *ExampleServiceExampleMethodResult) IsSetErr() bool { return p.Err != nil } -func (p *ExampleServiceExampleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleResp() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodResult) ReadField1(iprot thrift.TProtocol) error { - p.Err = NewException() - if err := p.Err.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetErr() { - if err = oprot.WriteFieldBegin("err", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Err.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleMethodResult) String() string { if p == nil { return "" @@ -3740,34 +613,9 @@ func (p *ExampleServiceExampleMethodResult) String() string { return fmt.Sprintf("ExampleServiceExampleMethodResult(%+v)", *p) } -func (p *ExampleServiceExampleMethodResult) DeepEqual(ano *ExampleServiceExampleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - if !p.Field1DeepEqual(ano.Err) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodResult) Field0DeepEqual(src *ExampleResp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleServiceExampleMethodResult) Field1DeepEqual(src *Exception) bool { - - if !p.Err.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ + 0: "success", + 1: "err", } type ExampleServiceFooArgs struct { @@ -3778,6 +626,9 @@ func NewExampleServiceFooArgs() *ExampleServiceFooArgs { return &ExampleServiceFooArgs{} } +func (p *ExampleServiceFooArgs) InitDefault() { +} + var ExampleServiceFooArgs_Req_DEFAULT *A func (p *ExampleServiceFooArgs) GetReq() (v *A) { @@ -3786,131 +637,11 @@ func (p *ExampleServiceFooArgs) GetReq() (v *A) { } return p.Req } -func (p *ExampleServiceFooArgs) SetReq(val *A) { - p.Req = val -} - -var fieldIDToName_ExampleServiceFooArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceFooArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceFooArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFooArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewA() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFooArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFooArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceFooArgs) String() string { if p == nil { return "" @@ -3918,34 +649,21 @@ func (p *ExampleServiceFooArgs) String() string { return fmt.Sprintf("ExampleServiceFooArgs(%+v)", *p) } -func (p *ExampleServiceFooArgs) DeepEqual(ano *ExampleServiceFooArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceFooArgs) Field1DeepEqual(src *A) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFooArgs = map[int16]string{ + 1: "req", } type ExampleServiceFooResult struct { - Success *A `thrift:"success,0" json:"success,omitempty"` + Success *A `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceFooResult() *ExampleServiceFooResult { return &ExampleServiceFooResult{} } +func (p *ExampleServiceFooResult) InitDefault() { +} + var ExampleServiceFooResult_Success_DEFAULT *A func (p *ExampleServiceFooResult) GetSuccess() (v *A) { @@ -3954,133 +672,11 @@ func (p *ExampleServiceFooResult) GetSuccess() (v *A) { } return p.Success } -func (p *ExampleServiceFooResult) SetSuccess(x interface{}) { - p.Success = x.(*A) -} - -var fieldIDToName_ExampleServiceFooResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceFooResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceFooResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFooResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewA() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFooResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFooResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceFooResult) String() string { if p == nil { return "" @@ -4088,24 +684,8 @@ func (p *ExampleServiceFooResult) String() string { return fmt.Sprintf("ExampleServiceFooResult(%+v)", *p) } -func (p *ExampleServiceFooResult) DeepEqual(ano *ExampleServiceFooResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceFooResult) Field0DeepEqual(src *A) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFooResult = map[int16]string{ + 0: "success", } type ExampleServicePingArgs struct { @@ -4116,129 +696,11 @@ func NewExampleServicePingArgs() *ExampleServicePingArgs { return &ExampleServicePingArgs{} } -func (p *ExampleServicePingArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServicePingArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServicePingArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServicePingArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServicePingArgs) InitDefault() { } -func (p *ExampleServicePingArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Ping_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePingArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServicePingArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServicePingArgs) String() string { @@ -4248,34 +710,21 @@ func (p *ExampleServicePingArgs) String() string { return fmt.Sprintf("ExampleServicePingArgs(%+v)", *p) } -func (p *ExampleServicePingArgs) DeepEqual(ano *ExampleServicePingArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServicePingArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServicePingArgs = map[int16]string{ + 1: "msg", } type ExampleServicePingResult struct { - Success *string `thrift:"success,0" json:"success,omitempty"` + Success *string `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServicePingResult() *ExampleServicePingResult { return &ExampleServicePingResult{} } +func (p *ExampleServicePingResult) InitDefault() { +} + var ExampleServicePingResult_Success_DEFAULT string func (p *ExampleServicePingResult) GetSuccess() (v string) { @@ -4284,134 +733,11 @@ func (p *ExampleServicePingResult) GetSuccess() (v string) { } return *p.Success } -func (p *ExampleServicePingResult) SetSuccess(x interface{}) { - p.Success = x.(*string) -} - -var fieldIDToName_ExampleServicePingResult = map[int16]string{ - 0: "success", -} func (p *ExampleServicePingResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServicePingResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingResult) ReadField0(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Success = &v - } - return nil -} - -func (p *ExampleServicePingResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Ping_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePingResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Success); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServicePingResult) String() string { if p == nil { return "" @@ -4419,29 +745,8 @@ func (p *ExampleServicePingResult) String() string { return fmt.Sprintf("ExampleServicePingResult(%+v)", *p) } -func (p *ExampleServicePingResult) DeepEqual(ano *ExampleServicePingResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServicePingResult) Field0DeepEqual(src *string) bool { - - if p.Success == src { - return true - } else if p.Success == nil || src == nil { - return false - } - if strings.Compare(*p.Success, *src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServicePingResult = map[int16]string{ + 0: "success", } type ExampleServiceOnewayArgs struct { @@ -4452,129 +757,11 @@ func NewExampleServiceOnewayArgs() *ExampleServiceOnewayArgs { return &ExampleServiceOnewayArgs{} } -func (p *ExampleServiceOnewayArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServiceOnewayArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServiceOnewayArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServiceOnewayArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOnewayArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceOnewayArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServiceOnewayArgs) InitDefault() { } -func (p *ExampleServiceOnewayArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Oneway_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceOnewayArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceOnewayArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServiceOnewayArgs) String() string { @@ -4584,24 +771,8 @@ func (p *ExampleServiceOnewayArgs) String() string { return fmt.Sprintf("ExampleServiceOnewayArgs(%+v)", *p) } -func (p *ExampleServiceOnewayArgs) DeepEqual(ano *ExampleServiceOnewayArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServiceOnewayArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceOnewayArgs = map[int16]string{ + 1: "msg", } type ExampleServiceVoidArgs struct { @@ -4612,129 +783,11 @@ func NewExampleServiceVoidArgs() *ExampleServiceVoidArgs { return &ExampleServiceVoidArgs{} } -func (p *ExampleServiceVoidArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServiceVoidArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServiceVoidArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServiceVoidArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceVoidArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceVoidArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServiceVoidArgs) InitDefault() { } -func (p *ExampleServiceVoidArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Void_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceVoidArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceVoidArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServiceVoidArgs) String() string { @@ -4744,24 +797,8 @@ func (p *ExampleServiceVoidArgs) String() string { return fmt.Sprintf("ExampleServiceVoidArgs(%+v)", *p) } -func (p *ExampleServiceVoidArgs) DeepEqual(ano *ExampleServiceVoidArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServiceVoidArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceVoidArgs = map[int16]string{ + 1: "msg", } type ExampleServiceVoidResult struct { @@ -4771,71 +808,7 @@ func NewExampleServiceVoidResult() *ExampleServiceVoidResult { return &ExampleServiceVoidResult{} } -var fieldIDToName_ExampleServiceVoidResult = map[int16]string{} - -func (p *ExampleServiceVoidResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceVoidResult) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("Void_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +func (p *ExampleServiceVoidResult) InitDefault() { } func (p *ExampleServiceVoidResult) String() string { @@ -4845,14 +818,7 @@ func (p *ExampleServiceVoidResult) String() string { return fmt.Sprintf("ExampleServiceVoidResult(%+v)", *p) } -func (p *ExampleServiceVoidResult) DeepEqual(ano *ExampleServiceVoidResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} +var fieldIDToName_ExampleServiceVoidResult = map[int16]string{} type ExampleServiceExampleToSnakeCaseArgs struct { Req *ExampleToSnakeCase `thrift:"req,1" json:"req"` @@ -4862,6 +828,9 @@ func NewExampleServiceExampleToSnakeCaseArgs() *ExampleServiceExampleToSnakeCase return &ExampleServiceExampleToSnakeCaseArgs{} } +func (p *ExampleServiceExampleToSnakeCaseArgs) InitDefault() { +} + var ExampleServiceExampleToSnakeCaseArgs_Req_DEFAULT *ExampleToSnakeCase func (p *ExampleServiceExampleToSnakeCaseArgs) GetReq() (v *ExampleToSnakeCase) { @@ -4870,131 +839,11 @@ func (p *ExampleServiceExampleToSnakeCaseArgs) GetReq() (v *ExampleToSnakeCase) } return p.Req } -func (p *ExampleServiceExampleToSnakeCaseArgs) SetReq(val *ExampleToSnakeCase) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleToSnakeCaseArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleToSnakeCaseArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleToSnakeCaseArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleToSnakeCaseArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleToSnakeCaseArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleToSnakeCase() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleToSnakeCaseArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleToSnakeCase_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleToSnakeCaseArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleToSnakeCaseArgs) String() string { if p == nil { return "" @@ -5002,24 +851,8 @@ func (p *ExampleServiceExampleToSnakeCaseArgs) String() string { return fmt.Sprintf("ExampleServiceExampleToSnakeCaseArgs(%+v)", *p) } -func (p *ExampleServiceExampleToSnakeCaseArgs) DeepEqual(ano *ExampleServiceExampleToSnakeCaseArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleToSnakeCaseArgs) Field1DeepEqual(src *ExampleToSnakeCase) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleToSnakeCaseArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleToSnakeCaseResult struct { @@ -5029,71 +862,7 @@ func NewExampleServiceExampleToSnakeCaseResult() *ExampleServiceExampleToSnakeCa return &ExampleServiceExampleToSnakeCaseResult{} } -var fieldIDToName_ExampleServiceExampleToSnakeCaseResult = map[int16]string{} - -func (p *ExampleServiceExampleToSnakeCaseResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleToSnakeCaseResult) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("ExampleToSnakeCase_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +func (p *ExampleServiceExampleToSnakeCaseResult) InitDefault() { } func (p *ExampleServiceExampleToSnakeCaseResult) String() string { @@ -5103,14 +872,7 @@ func (p *ExampleServiceExampleToSnakeCaseResult) String() string { return fmt.Sprintf("ExampleServiceExampleToSnakeCaseResult(%+v)", *p) } -func (p *ExampleServiceExampleToSnakeCaseResult) DeepEqual(ano *ExampleServiceExampleToSnakeCaseResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} +var fieldIDToName_ExampleServiceExampleToSnakeCaseResult = map[int16]string{} type ExampleServiceExampleDefaultValueArgs struct { Req *ExampleDefaultValue `thrift:"req,1" json:"req"` @@ -5120,6 +882,9 @@ func NewExampleServiceExampleDefaultValueArgs() *ExampleServiceExampleDefaultVal return &ExampleServiceExampleDefaultValueArgs{} } +func (p *ExampleServiceExampleDefaultValueArgs) InitDefault() { +} + var ExampleServiceExampleDefaultValueArgs_Req_DEFAULT *ExampleDefaultValue func (p *ExampleServiceExampleDefaultValueArgs) GetReq() (v *ExampleDefaultValue) { @@ -5128,131 +893,11 @@ func (p *ExampleServiceExampleDefaultValueArgs) GetReq() (v *ExampleDefaultValue } return p.Req } -func (p *ExampleServiceExampleDefaultValueArgs) SetReq(val *ExampleDefaultValue) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleDefaultValueArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleDefaultValueArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleDefaultValueArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDefaultValueArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleDefaultValue() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleDefaultValueArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDefaultValue_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDefaultValueArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleDefaultValueArgs) String() string { if p == nil { return "" @@ -5260,34 +905,21 @@ func (p *ExampleServiceExampleDefaultValueArgs) String() string { return fmt.Sprintf("ExampleServiceExampleDefaultValueArgs(%+v)", *p) } -func (p *ExampleServiceExampleDefaultValueArgs) DeepEqual(ano *ExampleServiceExampleDefaultValueArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleDefaultValueArgs) Field1DeepEqual(src *ExampleDefaultValue) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleDefaultValueArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleDefaultValueResult struct { - Success *ExampleDefaultValue `thrift:"success,0" json:"success,omitempty"` + Success *ExampleDefaultValue `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceExampleDefaultValueResult() *ExampleServiceExampleDefaultValueResult { return &ExampleServiceExampleDefaultValueResult{} } +func (p *ExampleServiceExampleDefaultValueResult) InitDefault() { +} + var ExampleServiceExampleDefaultValueResult_Success_DEFAULT *ExampleDefaultValue func (p *ExampleServiceExampleDefaultValueResult) GetSuccess() (v *ExampleDefaultValue) { @@ -5296,133 +928,11 @@ func (p *ExampleServiceExampleDefaultValueResult) GetSuccess() (v *ExampleDefaul } return p.Success } -func (p *ExampleServiceExampleDefaultValueResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleDefaultValue) -} - -var fieldIDToName_ExampleServiceExampleDefaultValueResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceExampleDefaultValueResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceExampleDefaultValueResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDefaultValueResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleDefaultValue() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleDefaultValueResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDefaultValue_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleDefaultValueResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceExampleDefaultValueResult) String() string { if p == nil { return "" @@ -5430,22 +940,11 @@ func (p *ExampleServiceExampleDefaultValueResult) String() string { return fmt.Sprintf("ExampleServiceExampleDefaultValueResult(%+v)", *p) } -func (p *ExampleServiceExampleDefaultValueResult) DeepEqual(ano *ExampleServiceExampleDefaultValueResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleDefaultValueResult = map[int16]string{ + 0: "success", } -func (p *ExampleServiceExampleDefaultValueResult) Field0DeepEqual(src *ExampleDefaultValue) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} +// exceptions of methods in ExampleService. +var ( + _ error = (*Exception)(nil) +) diff --git a/testdata/kitex_gen/example/k-example.go b/testdata/kitex_gen/example/k-example.go index dbf0586e..b44ca597 100644 --- a/testdata/kitex_gen/example/k-example.go +++ b/testdata/kitex_gen/example/k-example.go @@ -1,3902 +1,1991 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package example import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" + "unsafe" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/deep" - "github.com/cloudwego/dynamicgo/testdata/kitex_gen/ref" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) _ = base.KitexUnusedProtection _ = deep.KitexUnusedProtection - _ = ref.KitexUnusedProtection ) -func (p *ExampleReq) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetBase = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.InnerBase = v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleReq) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleReq) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleReq") - if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - func (p *ExampleReq) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleReq") - if p != nil { - l += p.field1Length() - l += p.field3Length() - l += p.field255Length() - l += p.field32767Length() + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset -} -func (p *ExampleReq) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.InnerBase) + // p.InnerBase ID:3 thrift.I32 + off += 3 + off += 4 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() -func (p *ExampleReq) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 } -func (p *ExampleReq) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) +func (p *ExampleReq) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Msg) - - l += bthrift.Binary.FieldEndLength() +func (p *ExampleReq) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l -} + off := 0 -func (p *ExampleReq) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.InnerBase) + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) + } - l += bthrift.Binary.FieldEndLength() - return l -} + // p.InnerBase ID:3 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.InnerBase)) + off += 4 -func (p *ExampleReq) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) -func (p *ExampleReq) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleToSnakeCase) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleReq) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - case 2: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x308: // p.InnerBase ID:3 thrift.I32 + p.InnerBase, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetBase = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - if !issetBase { - fieldId = 255 + if isset&0x1 == 0 { + fid = 255 // Base goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleToSnakeCase[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleReq[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleToSnakeCase[fieldId])) -} - -func (p *ExampleToSnakeCase) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleToSnakeCase) FastReadField2(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ReqList = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ReqList = append(p.ReqList, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleToSnakeCase) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.InnerBase = v - - } - return offset, nil -} - -func (p *ExampleToSnakeCase) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleToSnakeCase) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleToSnakeCase) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase") - if p != nil { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleReq[fid])) } func (p *ExampleToSnakeCase) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field255Length() + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleToSnakeCase) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset -} -func (p *ExampleToSnakeCase) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req_list", thrift.LIST, 2) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.ReqList)) + // p.ReqList ID:2 thrift.LIST + off += 3 + off += 5 for _, v := range p.ReqList { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - + off += 4 + len(v) } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} -func (p *ExampleToSnakeCase) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.InnerBase) + // p.InnerBase ID:3 thrift.I32 + off += 3 + off += 4 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() + return off + 1 } -func (p *ExampleToSnakeCase) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *ExampleToSnakeCase) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleToSnakeCase) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Msg) +func (p *ExampleToSnakeCase) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - l += bthrift.Binary.FieldEndLength() + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) } - return l -} -func (p *ExampleToSnakeCase) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req_list", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.ReqList)) + // p.ReqList ID:2 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ReqList))) + off += 5 for _, v := range p.ReqList { - l += bthrift.Binary.StringLengthNocopy(v) - + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} -func (p *ExampleToSnakeCase) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.InnerBase) + // p.InnerBase ID:3 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.InnerBase)) + off += 4 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) -func (p *ExampleToSnakeCase) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleResp) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleToSnakeCase) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetRequiredField bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetRequiredField = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 32767: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField32767(buf[offset:]) - offset += l + case 0x20f: // p.ReqList ID:2 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ReqList = make([]string, sz) + for i := 0; i < sz; i++ { + p.ReqList[i], l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } + case 0x308: // p.InnerBase ID:3 thrift.I32 + p.InnerBase, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetRequiredField { - fieldId = 2 + if isset&0x1 == 0 { + fid = 255 // Base goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleToSnakeCase[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.RequiredField = v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField32767(buf []byte) (int, error) { - offset := 0 - p.BaseResp = base.NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleResp) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleResp") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleToSnakeCase[fid])) } func (p *ExampleResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleResp") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field32767Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required_field", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RequiredField) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BaseResp", thrift.STRUCT, 32767) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Msg) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleResp) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("required_field", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.RequiredField) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 32767) - l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *A) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if p == nil { + return 1 } + off := 0 - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_A[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *A) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Self = v - + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset, nil -} -func (p *A) FastReadField2(buf []byte) (int, error) { - offset := 0 + // p.RequiredField ID:2 thrift.STRING + off += 3 + off += 4 + len(p.RequiredField) - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Foo = FOO(v) - - } - return offset, nil + // p.BaseResp ID:32767 thrift.STRUCT + off += 3 + off += p.BaseResp.BLength() + return off + 1 } -// for compatibility -func (p *A) FastWrite(buf []byte) int { - return 0 -} +func (p *ExampleResp) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *A) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "A") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) +func (p *ExampleResp) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *A) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("A") - if p != nil { - l += p.field1Length() - l += p.field2Length() + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *A) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "self", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Self) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *A) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "foo", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Foo)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *A) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("self", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Self) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.RequiredField ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.RequiredField) -func (p *A) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("foo", thrift.I32, 2) - l += bthrift.Binary.I32Length(int32(p.Foo)) + // p.BaseResp ID:32767 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + off += p.BaseResp.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleDefaultValue) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleResp) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.SET { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 8: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20b: // p.RequiredField ID:2 thrift.STRING + p.RequiredField, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + isset |= 0x1 + case 0x7fff0c: // p.BaseResp ID:32767 thrift.STRUCT + p.BaseResp = base.NewBaseResp() + l, err = p.BaseResp.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 2 // RequiredField + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDefaultValue[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleResp[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Bool = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField5(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.List = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.List = append(p.List, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField6(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Map = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Map[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField7(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Set = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.Set = append(p.Set, _elem) - } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField8(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.ConstString = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField9(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Enum = FOO(v) - - } - return offset, nil -} - -// for compatibility -func (p *ExampleDefaultValue) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleDefaultValue) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDefaultValue") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field9Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleDefaultValue) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Int) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "List", thrift.LIST, 5) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.List)) - for _, v := range p.List { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Map", thrift.MAP, 6) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Map)) - for k, v := range p.Map { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Set", thrift.SET, 7) - offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.STRING, len(p.Set)) - - for i := 0; i < len(p.Set); i++ { - for j := i + 1; j < len(p.Set); j++ { - if func(tgt, src string) bool { - if strings.Compare(tgt, src) != 0 { - return false - } - return true - }(p.Set[i], p.Set[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Set[i])) - } - } - } - for _, v := range p.Set { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ConstString", thrift.STRING, 8) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.ConstString) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Enum", thrift.I32, 9) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Enum)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int", thrift.I32, 2) - l += bthrift.Binary.I32Length(p.Int) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.Double) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(p.Bool) - - l += bthrift.Binary.FieldEndLength() - return l + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleResp[fid])) } -func (p *ExampleDefaultValue) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("List", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.List)) - for _, v := range p.List { - l += bthrift.Binary.StringLengthNocopy(v) - +func (p *A) BLength() int { + if p == nil { + return 1 } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} + off := 0 -func (p *ExampleDefaultValue) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Map", thrift.MAP, 6) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Map)) - for k, v := range p.Map { - - l += bthrift.Binary.StringLengthNocopy(k) + // p.Self ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Self) - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l + // p.Foo ID:2 thrift.I32 + off += 3 + off += 4 + return off + 1 } -func (p *ExampleDefaultValue) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Set", thrift.SET, 7) - l += bthrift.Binary.SetBeginLength(thrift.STRING, len(p.Set)) - - for i := 0; i < len(p.Set); i++ { - for j := i + 1; j < len(p.Set); j++ { - if func(tgt, src string) bool { - if strings.Compare(tgt, src) != 0 { - return false - } - return true - }(p.Set[i], p.Set[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Set[i])) - } - } - } - for _, v := range p.Set { - l += bthrift.Binary.StringLengthNocopy(v) +func (p *A) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *A) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ConstString", thrift.STRING, 8) - l += bthrift.Binary.StringLengthNocopy(p.ConstString) + off := 0 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Self ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Self) -func (p *ExampleDefaultValue) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Enum", thrift.I32, 9) - l += bthrift.Binary.I32Length(int32(p.Enum)) + // p.Foo ID:2 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Foo)) + off += 4 - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *DeepRef) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *A) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var enum int32 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Self ID:1 thrift.STRING + p.Self, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x208: // p.Foo ID:2 thrift.I32 + enum, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } + p.Foo = FOO(enum) default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DeepRef[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_A[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *DeepRef) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.DeepRef = deep.NewTestStruct() - if l, err := p.DeepRef.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleDefaultValue) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *DeepRef) FastWrite(buf []byte) int { - return 0 -} + // p.String_ ID:1 thrift.STRING + off += 3 + off += 4 + len(p.String_) + + // p.Int ID:2 thrift.I32 + off += 3 + off += 4 -func (p *DeepRef) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DeepRef") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Double ID:3 thrift.DOUBLE + off += 3 + off += 8 + + // p.Bool ID:4 thrift.BOOL + off += 3 + off += 1 + + // p.List ID:5 thrift.LIST + off += 3 + off += 5 + for _, v := range p.List { + off += 4 + len(v) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} -func (p *DeepRef) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("DeepRef") - if p != nil { - l += p.field1Length() + // p.Map ID:6 thrift.MAP + off += 3 + off += 6 + for k, v := range p.Map { + off += 4 + len(k) + off += 4 + len(v) } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} -func (p *DeepRef) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DeepRef", thrift.STRUCT, 1) - offset += p.DeepRef.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Set ID:7 thrift.SET + off += 3 + off += 5 + for _, v := range p.Set { + off += 4 + len(v) + } + + // p.ConstString ID:8 thrift.STRING + off += 3 + off += 4 + len(p.ConstString) + + // p.Enum ID:9 thrift.I32 + off += 3 + off += 4 + return off + 1 +} + +func (p *ExampleDefaultValue) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExampleDefaultValue) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.String_ ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) + + // p.Int ID:2 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Int)) + off += 4 + + // p.Double ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Double))) + off += 8 + + // p.Bool ID:4 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Bool))) + off++ + + // p.List ID:5 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.List))) + off += 5 + for _, v := range p.List { + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } -func (p *DeepRef) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("DeepRef", thrift.STRUCT, 1) - l += p.DeepRef.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Map ID:6 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Map))) + off += 6 + for k, v := range p.Map { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } -func (p *Exception) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError + // p.Set ID:7 thrift.SET + b[off] = 14 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.Set))) + off += 5 + for _, v := range p.Set { + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) } + // p.ConstString ID:8 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.ConstString) + + // p.Enum ID:9 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Enum)) + off += 4 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleDefaultValue) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var enum int32 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField1(buf[offset:]) - offset += l + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.String_ ID:1 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x208: // p.Int ID:2 thrift.I32 + p.Int, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x304: // p.Double ID:3 thrift.DOUBLE + p.Double, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x402: // p.Bool ID:4 thrift.BOOL + p.Bool, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x50f: // p.List ID:5 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.List = make([]string, sz) + for i := 0; i < sz; i++ { + p.List[i], l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + } + case 0x60d: // p.Map ID:6 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Map = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } - } - case 255: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField255(buf[offset:]) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + p.Map[k] = v + } + case 0x70e: // p.Set ID:7 thrift.SET + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Set = make([]string, sz) + for i := 0; i < sz; i++ { + p.Set[i], l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } } + case 0x80b: // p.ConstString ID:8 thrift.STRING + p.ConstString, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x908: // p.Enum ID:9 thrift.I32 + enum, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Enum = FOO(enum) default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleDefaultValue[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Exception) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - +func (p *DeepRef) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *Exception) FastReadField255(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.DeepRef ID:1 thrift.STRUCT + off += 3 + off += p.DeepRef.BLength() + return off + 1 +} - p.Msg = v +func (p *DeepRef) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *DeepRef) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} + off := 0 + + // p.DeepRef ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.DeepRef.FastWriteNocopy(b[off:], w) -// for compatibility -func (p *Exception) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *Exception) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Exception") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) +func (p *DeepRef) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.DeepRef ID:1 thrift.STRUCT + p.DeepRef = deep.NewTestStruct() + l, err = p.DeepRef.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_DeepRef[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *Exception) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Exception") - if p != nil { - l += p.field1Length() - l += p.field255Length() + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *Exception) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Code) + // p.Code ID:1 thrift.I32 + off += 3 + off += 4 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Msg ID:255 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *Exception) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 255) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) +func (p *Exception) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Exception) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(p.Code) +func (p *Exception) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Code ID:1 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Code)) + off += 4 -func (p *Exception) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 255) - l += bthrift.Binary.StringLengthNocopy(p.Msg) + // p.Msg ID:255 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleDeepRefArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Exception) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x108: // p.Code ID:1 thrift.I32 + p.Code, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0b: // p.Msg ID:255 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Exception[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleDeepRefArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewDeepRef() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleDeepRefArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleDeepRefArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleDeepRefArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDeepRef_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceExampleDeepRefArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleDeepRefArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDeepRef_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceExampleDeepRefArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceExampleDeepRefArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleDeepRefArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleDeepRefResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleDeepRefArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewDeepRef() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDeepRefResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleDeepRefArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleDeepRefResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewDeepRef() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleDeepRefResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceExampleDeepRefResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceExampleDeepRefResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDeepRef_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleDeepRefResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDeepRef_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceExampleDeepRefResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleDeepRefResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleDeepRefResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleDeepRefResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleDeepRefResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewDeepRef() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleDeepRefResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleReq() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceExampleMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceExampleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleReq() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleResp() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleServiceExampleMethodResult) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Err = NewException() - if l, err := p.Err.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceExampleMethodResult) FastWrite(buf []byte) int { - return 0 -} -func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + off += 3 + off += p.Err.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_result") - if p != nil { - l += p.field0Length() - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExampleMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleMethodResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetErr() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "err", thrift.STRUCT, 1) - offset += p.Err.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return offset -} -func (p *ExampleServiceExampleMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Err.FastWriteNocopy(b[off:], w) } - return l -} -func (p *ExampleServiceExampleMethodResult) field1Length() int { - l := 0 - if p.IsSetErr() { - l += bthrift.Binary.FieldBeginLength("err", thrift.STRUCT, 1) - l += p.Err.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFooArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleResp() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x10c: // p.Err ID:1 thrift.STRUCT + p.Err = NewException() + l, err = p.Err.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFooArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewA() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFooArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceFooArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceFooArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFooArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceFooArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceFooArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFooResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFooArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewA() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFooArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFooResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewA() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFooResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceFooResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceFooResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceFooResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceFooResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceFooResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServicePingArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFooResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewA() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFooResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePingArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - +func (p *ExampleServicePingArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServicePingArgs) FastWrite(buf []byte) int { - return 0 + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServicePingArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServicePingArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePingArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServicePingArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServicePingArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + b[off] = 0 + return off + 1 } -func (p *ExampleServicePingArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleServicePingResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePingArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePingArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Success = &v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleServicePingResult) FastWrite(buf []byte) int { - return 0 + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePingResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) +func (p *ExampleServicePingResult) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServicePingResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_result") - if p != nil { - l += p.field0Length() + // p.Success ID:0 thrift.STRING + if p.Success != nil { + off += 3 + off += 4 + len(*p.Success) } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + return off + 1 } -func (p *ExampleServicePingResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRING, 0) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Success) +func (p *ExampleServicePingResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServicePingResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} - -func (p *ExampleServicePingResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRING, 0) - l += bthrift.Binary.StringLengthNocopy(*p.Success) + off := 0 - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRING + if p.Success != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Success) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceOnewayArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePingResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xb: // p.Success ID:0 thrift.STRING + if p.Success == nil { + p.Success = new(string) + } + *p.Success, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOnewayArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePingResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceOnewayArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - +func (p *ExampleServiceOnewayArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceOnewayArgs) FastWrite(buf []byte) int { - return 0 + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServiceOnewayArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Oneway_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceOnewayArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceOnewayArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Oneway_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceOnewayArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceOnewayArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + b[off] = 0 + return off + 1 } -func (p *ExampleServiceOnewayArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleServiceVoidArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceOnewayArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceVoidArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceOnewayArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceVoidArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - +func (p *ExampleServiceVoidArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceVoidArgs) FastWrite(buf []byte) int { - return 0 + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServiceVoidArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceVoidArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceVoidArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Void_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceVoidArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleServiceVoidArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceVoidArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceVoidResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceVoidArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldTypeError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) - -SkipFieldTypeError: - return offset, thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -// for compatibility -func (p *ExampleServiceVoidResult) FastWrite(buf []byte) int { - return 0 + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceVoidArgs[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceVoidResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_result") - if p != nil { +func (p *ExampleServiceVoidResult) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + off := 0 + return off + 1 } -func (p *ExampleServiceVoidResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Void_result") - if p != nil { +func (p *ExampleServiceVoidResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExampleServiceVoidResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + off := 0 + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleToSnakeCaseArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceVoidResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } + switch uint32(fid)<<8 | uint32(ftyp) { default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleToSnakeCaseArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleToSnakeCaseArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleToSnakeCase() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleToSnakeCaseArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleToSnakeCaseArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleToSnakeCaseArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceExampleToSnakeCaseArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleToSnakeCaseArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceExampleToSnakeCaseArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceExampleToSnakeCaseArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleToSnakeCaseArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleToSnakeCaseResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleToSnakeCaseArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldTypeError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleToSnakeCase() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) - -SkipFieldTypeError: - return offset, thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleToSnakeCaseArgs[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -// for compatibility -func (p *ExampleServiceExampleToSnakeCaseResult) FastWrite(buf []byte) int { - return 0 +func (p *ExampleServiceExampleToSnakeCaseResult) BLength() int { + if p == nil { + return 1 + } + off := 0 + return off + 1 } -func (p *ExampleServiceExampleToSnakeCaseResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleToSnakeCase_result") - if p != nil { - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceExampleToSnakeCaseResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleToSnakeCaseResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleToSnakeCase_result") - if p != nil { +func (p *ExampleServiceExampleToSnakeCaseResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + off := 0 + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleDefaultValueArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleToSnakeCaseResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } + switch uint32(fid)<<8 | uint32(ftyp) { default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleDefaultValueArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleDefaultValue() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleDefaultValueArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleDefaultValueArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleDefaultValueArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceExampleDefaultValueArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleDefaultValueArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDefaultValue_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceExampleDefaultValueArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceExampleDefaultValueArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleDefaultValueArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleDefaultValueResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleDefaultValueArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleDefaultValue() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleDefaultValueResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleDefaultValueArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleDefaultValueResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleDefaultValue() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleDefaultValueResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleDefaultValueResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceExampleDefaultValueResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleDefaultValueResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDefaultValue_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceExampleDefaultValueResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleDefaultValueResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleDefaultValueResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleDefaultValueResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l -} - -func (p *ExampleServiceExampleDeepRefArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleDeepRefResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceExampleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceFooArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceFooResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServicePingArgs) GetFirstArgument() interface{} { - return p.Msg -} - -func (p *ExampleServicePingResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceOnewayArgs) GetFirstArgument() interface{} { - return p.Msg -} -func (p *ExampleServiceVoidArgs) GetFirstArgument() interface{} { - return p.Msg + b[off] = 0 + return off + 1 } -func (p *ExampleServiceVoidResult) GetResult() interface{} { - return nil -} - -func (p *ExampleServiceExampleToSnakeCaseArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleToSnakeCaseResult) GetResult() interface{} { - return nil -} - -func (p *ExampleServiceExampleDefaultValueArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleDefaultValueResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleReq) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} -func (p *ExampleToSnakeCase) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} - -func (p *ExampleResp) GetOrSetBaseResp() interface{} { - if p.BaseResp == nil { - p.BaseResp = base.NewBaseResp() +func (p *ExampleServiceExampleDefaultValueResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleDefaultValue() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - return p.BaseResp + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleDefaultValueResult[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/example2/example2.go b/testdata/kitex_gen/example2/example2.go index 91ea4514..2aa578cb 100644 --- a/testdata/kitex_gen/example2/example2.go +++ b/testdata/kitex_gen/example2/example2.go @@ -1,16 +1,13 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package example2 import ( - "bytes" - "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" "context" "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" + "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" ) type FOO int64 @@ -36,7 +33,6 @@ func FOOFromString(s string) (FOO, error) { } func FOOPtr(v FOO) *FOO { return &v } - func (p *FOO) Scan(value interface{}) (err error) { var result sql.NullInt64 err = result.Scan(value) @@ -61,7 +57,7 @@ type InnerBase struct { String_ string `thrift:"String,7" json:"String"` ListInt32 []int32 `thrift:"ListInt32,8" json:"ListInt32"` MapStringString map[string]string `thrift:"MapStringString,9" json:"MapStringString"` - SetInt32_ []int32 `thrift:"SetInt32,10" json:"SetInt32"` + SetInt32 []int32 `thrift:"SetInt32,10" json:"SetInt32"` Foo FOO `thrift:"Foo,11" json:"Foo"` MapInt32String map[int32]string `thrift:"MapInt32String,12" json:"MapInt32String"` Binary []byte `thrift:"Binary,13" json:"Binary"` @@ -78,6 +74,9 @@ func NewInnerBase() *InnerBase { return &InnerBase{} } +func (p *InnerBase) InitDefault() { +} + func (p *InnerBase) GetBool() (v bool) { return p.Bool } @@ -115,7 +114,7 @@ func (p *InnerBase) GetMapStringString() (v map[string]string) { } func (p *InnerBase) GetSetInt32() (v []int32) { - return p.SetInt32_ + return p.SetInt32 } func (p *InnerBase) GetFoo() (v FOO) { @@ -162,65 +161,16 @@ func (p *InnerBase) GetBase() (v *base.Base) { } return p.Base } -func (p *InnerBase) SetBool(val bool) { - p.Bool = val -} -func (p *InnerBase) SetByte(val int8) { - p.Byte = val -} -func (p *InnerBase) SetInt16(val int16) { - p.Int16 = val -} -func (p *InnerBase) SetInt32(val int32) { - p.Int32 = val -} -func (p *InnerBase) SetInt64(val int64) { - p.Int64 = val -} -func (p *InnerBase) SetDouble(val float64) { - p.Double = val -} -func (p *InnerBase) SetString(val string) { - p.String_ = val -} -func (p *InnerBase) SetListInt32(val []int32) { - p.ListInt32 = val -} -func (p *InnerBase) SetMapStringString(val map[string]string) { - p.MapStringString = val -} -func (p *InnerBase) SetSetInt32(val []int32) { - p.SetInt32_ = val -} -func (p *InnerBase) SetFoo(val FOO) { - p.Foo = val -} -func (p *InnerBase) SetMapInt32String(val map[int32]string) { - p.MapInt32String = val -} -func (p *InnerBase) SetBinary(val []byte) { - p.Binary = val -} -func (p *InnerBase) SetMapInt8String(val map[int8]string) { - p.MapInt8String = val -} -func (p *InnerBase) SetMapInt16String(val map[int16]string) { - p.MapInt16String = val -} -func (p *InnerBase) SetMapInt64String(val map[int64]string) { - p.MapInt64String = val -} -func (p *InnerBase) SetMapDoubleString(val map[float64]string) { - p.MapDoubleString = val -} -func (p *InnerBase) SetListInnerBase(val []*InnerBase) { - p.ListInnerBase = val -} -func (p *InnerBase) SetMapInnerBaseInnerBase(val map[*InnerBase]*InnerBase) { - p.MapInnerBaseInnerBase = val + +func (p *InnerBase) IsSetBase() bool { + return p.Base != nil } -func (p *InnerBase) SetBase(val *base.Base) { - p.Base = val + +func (p *InnerBase) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("InnerBase(%+v)", *p) } var fieldIDToName_InnerBase = map[int16]string{ @@ -246,5241 +196,572 @@ var fieldIDToName_InnerBase = map[int16]string{ 255: "Base", } -func (p *InnerBase) IsSetBase() bool { - return p.Base != nil +type InnerBasePartial struct { + Bool bool `thrift:"Bool,1" json:"Bool"` + ListInt32 []int32 `thrift:"ListInt32,8" json:"ListInt32"` + MapStringString map[string]string `thrift:"MapStringString,9" json:"MapStringString"` + MapDoubleString map[float64]string `thrift:"MapDoubleString,17" json:"MapDoubleString"` + ListInnerBase []*InnerBasePartial `thrift:"ListInnerBase,18" json:"ListInnerBase"` + MapInnerBaseInnerBase map[*InnerBasePartial]*InnerBasePartial `thrift:"MapInnerBaseInnerBase,19" json:"MapInnerBaseInnerBase"` + MapStringString2 map[string]string `thrift:"MapStringString2,127" json:"MapStringString2"` } -func (p *InnerBase) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 +func NewInnerBasePartial() *InnerBasePartial { + return &InnerBasePartial{} +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *InnerBasePartial) InitDefault() { +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I16 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.I64 { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRING { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.LIST { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.MAP { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 10: - if fieldTypeId == thrift.SET { - if err = p.ReadField10(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 11: - if fieldTypeId == thrift.I32 { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 12: - if fieldTypeId == thrift.MAP { - if err = p.ReadField12(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 13: - if fieldTypeId == thrift.STRING { - if err = p.ReadField13(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 14: - if fieldTypeId == thrift.MAP { - if err = p.ReadField14(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 15: - if fieldTypeId == thrift.MAP { - if err = p.ReadField15(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 16: - if fieldTypeId == thrift.MAP { - if err = p.ReadField16(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 17: - if fieldTypeId == thrift.MAP { - if err = p.ReadField17(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 18: - if fieldTypeId == thrift.LIST { - if err = p.ReadField18(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 19: - if fieldTypeId == thrift.MAP { - if err = p.ReadField19(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +func (p *InnerBasePartial) GetBool() (v bool) { + return p.Bool +} - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBase[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBase) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Bool = v - } - return nil +func (p *InnerBasePartial) GetListInt32() (v []int32) { + return p.ListInt32 } -func (p *InnerBase) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil +func (p *InnerBasePartial) GetMapStringString() (v map[string]string) { + return p.MapStringString } -func (p *InnerBase) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - p.Int16 = v - } - return nil +func (p *InnerBasePartial) GetMapDoubleString() (v map[float64]string) { + return p.MapDoubleString } -func (p *InnerBase) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Int32 = v - } - return nil +func (p *InnerBasePartial) GetListInnerBase() (v []*InnerBasePartial) { + return p.ListInnerBase } -func (p *InnerBase) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Int64 = v - } - return nil +func (p *InnerBasePartial) GetMapInnerBaseInnerBase() (v map[*InnerBasePartial]*InnerBasePartial) { + return p.MapInnerBaseInnerBase } -func (p *InnerBase) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil +func (p *InnerBasePartial) GetMapStringString2() (v map[string]string) { + return p.MapStringString2 } -func (p *InnerBase) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v +func (p *InnerBasePartial) String() string { + if p == nil { + return "" } - return nil + return fmt.Sprintf("InnerBasePartial(%+v)", *p) } -func (p *InnerBase) ReadField8(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.ListInt32 = append(p.ListInt32, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil +var fieldIDToName_InnerBasePartial = map[int16]string{ + 1: "Bool", + 8: "ListInt32", + 9: "MapStringString", + 17: "MapDoubleString", + 18: "ListInnerBase", + 19: "MapInnerBaseInnerBase", + 127: "MapStringString2", } -func (p *InnerBase) ReadField9(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +type BasePartial struct { + TrafficEnv *base.TrafficEnv `thrift:"TrafficEnv,5,optional" json:"TrafficEnv,omitempty"` } -func (p *InnerBase) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.SetInt32_ = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.SetInt32_ = append(p.SetInt32_, _elem) - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil +func NewBasePartial() *BasePartial { + return &BasePartial{} } -func (p *InnerBase) ReadField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Foo = FOO(v) - } - return nil +func (p *BasePartial) InitDefault() { } -func (p *InnerBase) ReadField12(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt32String = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt32String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err +var BasePartial_TrafficEnv_DEFAULT *base.TrafficEnv + +func (p *BasePartial) GetTrafficEnv() (v *base.TrafficEnv) { + if !p.IsSetTrafficEnv() { + return BasePartial_TrafficEnv_DEFAULT } - return nil + return p.TrafficEnv } -func (p *InnerBase) ReadField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil +func (p *BasePartial) IsSetTrafficEnv() bool { + return p.TrafficEnv != nil } -func (p *InnerBase) ReadField14(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt8String = make(map[int8]string, size) - for i := 0; i < size; i++ { - var _key int8 - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt8String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err +func (p *BasePartial) String() string { + if p == nil { + return "" } - return nil + return fmt.Sprintf("BasePartial(%+v)", *p) } -func (p *InnerBase) ReadField15(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt16String = make(map[int16]string, size) - for i := 0; i < size; i++ { - var _key int16 - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt16String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +var fieldIDToName_BasePartial = map[int16]string{ + 5: "TrafficEnv", } -func (p *InnerBase) ReadField16(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt64String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +type ExampleReq struct { + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` + A *int32 `thrift:"A,2,optional" json:"A,omitempty"` + InnerBase *InnerBase `thrift:"InnerBase,3" json:"InnerBase"` + Base *base.Base `thrift:"Base,255,required" json:"Base"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` } -func (p *InnerBase) ReadField17(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapDoubleString = make(map[float64]string, size) - for i := 0; i < size; i++ { - var _key float64 - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapDoubleString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func NewExampleReq() *ExampleReq { + return &ExampleReq{} } -func (p *InnerBase) ReadField18(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInnerBase = make([]*InnerBase, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBase() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) InitDefault() { } -func (p *InnerBase) ReadField19(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, size) - for i := 0; i < size; i++ { - _key := NewInnerBase() - if err := _key.Read(iprot); err != nil { - return err - } - _val := NewInnerBase() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err +var ExampleReq_Msg_DEFAULT string + +func (p *ExampleReq) GetMsg() (v string) { + if !p.IsSetMsg() { + return ExampleReq_Msg_DEFAULT } - return nil + return *p.Msg } -func (p *InnerBase) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err +var ExampleReq_A_DEFAULT int32 + +func (p *ExampleReq) GetA() (v int32) { + if !p.IsSetA() { + return ExampleReq_A_DEFAULT } - return nil + return *p.A } -func (p *InnerBase) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerBase"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField10(oprot); err != nil { - fieldId = 10 - goto WriteFieldError - } - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - if err = p.writeField12(oprot); err != nil { - fieldId = 12 - goto WriteFieldError - } - if err = p.writeField13(oprot); err != nil { - fieldId = 13 - goto WriteFieldError - } - if err = p.writeField14(oprot); err != nil { - fieldId = 14 - goto WriteFieldError - } - if err = p.writeField15(oprot); err != nil { - fieldId = 15 - goto WriteFieldError - } - if err = p.writeField16(oprot); err != nil { - fieldId = 16 - goto WriteFieldError - } - if err = p.writeField17(oprot); err != nil { - fieldId = 17 - goto WriteFieldError - } - if err = p.writeField18(oprot); err != nil { - fieldId = 18 - goto WriteFieldError - } - if err = p.writeField19(oprot); err != nil { - fieldId = 19 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } +var ExampleReq_InnerBase_DEFAULT *InnerBase +func (p *ExampleReq) GetInnerBase() (v *InnerBase) { + if !p.IsSetInnerBase() { + return ExampleReq_InnerBase_DEFAULT } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerBase) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Bool", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Bool); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) + return p.InnerBase } -func (p *InnerBase) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +var ExampleReq_Base_DEFAULT *base.Base + +func (p *ExampleReq) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return ExampleReq_Base_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) + return p.Base } -func (p *InnerBase) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int16", thrift.I16, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI16(p.Int16); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +func (p *ExampleReq) GetSubfix() (v float64) { + return p.Subfix } -func (p *InnerBase) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int32", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Int32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +func (p *ExampleReq) IsSetMsg() bool { + return p.Msg != nil } -func (p *InnerBase) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int64", thrift.I64, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Int64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +func (p *ExampleReq) IsSetA() bool { + return p.A != nil } -func (p *InnerBase) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +func (p *ExampleReq) IsSetInnerBase() bool { + return p.InnerBase != nil } -func (p *InnerBase) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 7); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +func (p *ExampleReq) IsSetBase() bool { + return p.Base != nil } -func (p *InnerBase) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInt32", thrift.LIST, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I32, len(p.ListInt32)); err != nil { - return err - } - for _, v := range p.ListInt32 { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +func (p *ExampleReq) String() string { + if p == nil { + return "" } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) + return fmt.Sprintf("ExampleReq(%+v)", *p) } -func (p *InnerBase) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { - return err - } - for k, v := range p.MapStringString { +var fieldIDToName_ExampleReq = map[int16]string{ + 1: "Msg", + 2: "A", + 3: "InnerBase", + 255: "Base", + 32767: "Subfix", +} - if err := oprot.WriteString(k); err != nil { - return err - } +type ExampleSuper struct { + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` + A *int32 `thrift:"A,2,optional" json:"A,omitempty"` + InnerBase *InnerBase `thrift:"InnerBase,3" json:"InnerBase"` + Ex1 string `thrift:"Ex1,4" json:"Ex1"` + Ex2 *string `thrift:"Ex2,5,optional" json:"Ex2,omitempty"` + Ex3 *string `thrift:"Ex3,6,optional" json:"Ex3,omitempty"` + Ex4 string `thrift:"Ex4,7,required" json:"Ex4"` + SelfRef *SelfRef `thrift:"SelfRef,9" json:"SelfRef"` + Base *base.Base `thrift:"Base,255,required" json:"Base"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` +} - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) +func NewExampleSuper() *ExampleSuper { + return &ExampleSuper{} } -func (p *InnerBase) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SetInt32", thrift.SET, 10); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.SetInt32_)); err != nil { - return err - } - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - for _, v := range p.SetInt32_ { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) +func (p *ExampleSuper) InitDefault() { } -func (p *InnerBase) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Foo", thrift.I32, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(int32(p.Foo)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +var ExampleSuper_Msg_DEFAULT string + +func (p *ExampleSuper) GetMsg() (v string) { + if !p.IsSetMsg() { + return ExampleSuper_Msg_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) + return *p.Msg } -func (p *InnerBase) writeField12(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt32String", thrift.MAP, 12); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.MapInt32String)); err != nil { - return err +var ExampleSuper_A_DEFAULT int32 + +func (p *ExampleSuper) GetA() (v int32) { + if !p.IsSetA() { + return ExampleSuper_A_DEFAULT } - for k, v := range p.MapInt32String { + return *p.A +} - if err := oprot.WriteI32(k); err != nil { - return err - } +var ExampleSuper_InnerBase_DEFAULT *InnerBase - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +func (p *ExampleSuper) GetInnerBase() (v *InnerBase) { + if !p.IsSetInnerBase() { + return ExampleSuper_InnerBase_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) + return p.InnerBase } -func (p *InnerBase) writeField13(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 13); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) +func (p *ExampleSuper) GetEx1() (v string) { + return p.Ex1 } -func (p *InnerBase) writeField14(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt8String", thrift.MAP, 14); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.BYTE, thrift.STRING, len(p.MapInt8String)); err != nil { - return err - } - for k, v := range p.MapInt8String { - - if err := oprot.WriteByte(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) -} - -func (p *InnerBase) writeField15(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt16String", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I16, thrift.STRING, len(p.MapInt16String)); err != nil { - return err - } - for k, v := range p.MapInt16String { - - if err := oprot.WriteI16(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) -} - -func (p *InnerBase) writeField16(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt64String", thrift.MAP, 16); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, len(p.MapInt64String)); err != nil { - return err - } - for k, v := range p.MapInt64String { - - if err := oprot.WriteI64(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 16 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 16 end error: ", p), err) -} - -func (p *InnerBase) writeField17(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapDoubleString", thrift.MAP, 17); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)); err != nil { - return err - } - for k, v := range p.MapDoubleString { - - if err := oprot.WriteDouble(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 17 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 17 end error: ", p), err) -} - -func (p *InnerBase) writeField18(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInnerBase", thrift.LIST, 18); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListInnerBase)); err != nil { - return err - } - for _, v := range p.ListInnerBase { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 end error: ", p), err) -} - -func (p *InnerBase) writeField19(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInnerBaseInnerBase", thrift.MAP, 19); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)); err != nil { - return err - } - for k, v := range p.MapInnerBaseInnerBase { - - if err := k.Write(oprot); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 end error: ", p), err) -} - -func (p *InnerBase) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *InnerBase) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerBase(%+v)", *p) -} - -func (p *InnerBase) DeepEqual(ano *InnerBase) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Bool) { - return false - } - if !p.Field2DeepEqual(ano.Byte) { - return false - } - if !p.Field3DeepEqual(ano.Int16) { - return false - } - if !p.Field4DeepEqual(ano.Int32) { - return false - } - if !p.Field5DeepEqual(ano.Int64) { - return false - } - if !p.Field6DeepEqual(ano.Double) { - return false - } - if !p.Field7DeepEqual(ano.String_) { - return false - } - if !p.Field8DeepEqual(ano.ListInt32) { - return false - } - if !p.Field9DeepEqual(ano.MapStringString) { - return false - } - if !p.Field10DeepEqual(ano.SetInt32_) { - return false - } - if !p.Field11DeepEqual(ano.Foo) { - return false - } - if !p.Field12DeepEqual(ano.MapInt32String) { - return false - } - if !p.Field13DeepEqual(ano.Binary) { - return false - } - if !p.Field14DeepEqual(ano.MapInt8String) { - return false - } - if !p.Field15DeepEqual(ano.MapInt16String) { - return false - } - if !p.Field16DeepEqual(ano.MapInt64String) { - return false - } - if !p.Field17DeepEqual(ano.MapDoubleString) { - return false - } - if !p.Field18DeepEqual(ano.ListInnerBase) { - return false - } - if !p.Field19DeepEqual(ano.MapInnerBaseInnerBase) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true -} - -func (p *InnerBase) Field1DeepEqual(src bool) bool { - - if p.Bool != src { - return false - } - return true -} -func (p *InnerBase) Field2DeepEqual(src int8) bool { - - if p.Byte != src { - return false - } - return true -} -func (p *InnerBase) Field3DeepEqual(src int16) bool { - - if p.Int16 != src { - return false - } - return true -} -func (p *InnerBase) Field4DeepEqual(src int32) bool { - - if p.Int32 != src { - return false - } - return true -} -func (p *InnerBase) Field5DeepEqual(src int64) bool { - - if p.Int64 != src { - return false - } - return true -} -func (p *InnerBase) Field6DeepEqual(src float64) bool { - - if p.Double != src { - return false - } - return true -} -func (p *InnerBase) Field7DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *InnerBase) Field8DeepEqual(src []int32) bool { - - if len(p.ListInt32) != len(src) { - return false - } - for i, v := range p.ListInt32 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *InnerBase) Field9DeepEqual(src map[string]string) bool { - - if len(p.MapStringString) != len(src) { - return false - } - for k, v := range p.MapStringString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field10DeepEqual(src []int32) bool { - - if len(p.SetInt32_) != len(src) { - return false - } - for i, v := range p.SetInt32_ { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *InnerBase) Field11DeepEqual(src FOO) bool { - - if p.Foo != src { - return false - } - return true -} -func (p *InnerBase) Field12DeepEqual(src map[int32]string) bool { - - if len(p.MapInt32String) != len(src) { - return false - } - for k, v := range p.MapInt32String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field13DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true -} -func (p *InnerBase) Field14DeepEqual(src map[int8]string) bool { - - if len(p.MapInt8String) != len(src) { - return false - } - for k, v := range p.MapInt8String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field15DeepEqual(src map[int16]string) bool { - - if len(p.MapInt16String) != len(src) { - return false - } - for k, v := range p.MapInt16String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field16DeepEqual(src map[int64]string) bool { - - if len(p.MapInt64String) != len(src) { - return false - } - for k, v := range p.MapInt64String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field17DeepEqual(src map[float64]string) bool { - - if len(p.MapDoubleString) != len(src) { - return false - } - for k, v := range p.MapDoubleString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBase) Field18DeepEqual(src []*InnerBase) bool { - - if len(p.ListInnerBase) != len(src) { - return false - } - for i, v := range p.ListInnerBase { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *InnerBase) Field19DeepEqual(src map[*InnerBase]*InnerBase) bool { - - if len(p.MapInnerBaseInnerBase) != len(src) { - return false - } - for k, v := range p.MapInnerBaseInnerBase { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *InnerBase) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} - -type InnerBasePartial struct { - Bool bool `thrift:"Bool,1" json:"Bool"` - ListInt32 []int32 `thrift:"ListInt32,8" json:"ListInt32"` - MapStringString map[string]string `thrift:"MapStringString,9" json:"MapStringString"` - MapDoubleString map[float64]string `thrift:"MapDoubleString,17" json:"MapDoubleString"` - ListInnerBase []*InnerBasePartial `thrift:"ListInnerBase,18" json:"ListInnerBase"` - MapInnerBaseInnerBase map[*InnerBasePartial]*InnerBasePartial `thrift:"MapInnerBaseInnerBase,19" json:"MapInnerBaseInnerBase"` - MapStringString2 map[string]string `thrift:"MapStringString2,127" json:"MapStringString2"` -} - -func NewInnerBasePartial() *InnerBasePartial { - return &InnerBasePartial{} -} - -func (p *InnerBasePartial) GetBool() (v bool) { - return p.Bool -} - -func (p *InnerBasePartial) GetListInt32() (v []int32) { - return p.ListInt32 -} - -func (p *InnerBasePartial) GetMapStringString() (v map[string]string) { - return p.MapStringString -} - -func (p *InnerBasePartial) GetMapDoubleString() (v map[float64]string) { - return p.MapDoubleString -} - -func (p *InnerBasePartial) GetListInnerBase() (v []*InnerBasePartial) { - return p.ListInnerBase -} - -func (p *InnerBasePartial) GetMapInnerBaseInnerBase() (v map[*InnerBasePartial]*InnerBasePartial) { - return p.MapInnerBaseInnerBase -} - -func (p *InnerBasePartial) GetMapStringString2() (v map[string]string) { - return p.MapStringString2 -} -func (p *InnerBasePartial) SetBool(val bool) { - p.Bool = val -} -func (p *InnerBasePartial) SetListInt32(val []int32) { - p.ListInt32 = val -} -func (p *InnerBasePartial) SetMapStringString(val map[string]string) { - p.MapStringString = val -} -func (p *InnerBasePartial) SetMapDoubleString(val map[float64]string) { - p.MapDoubleString = val -} -func (p *InnerBasePartial) SetListInnerBase(val []*InnerBasePartial) { - p.ListInnerBase = val -} -func (p *InnerBasePartial) SetMapInnerBaseInnerBase(val map[*InnerBasePartial]*InnerBasePartial) { - p.MapInnerBaseInnerBase = val -} -func (p *InnerBasePartial) SetMapStringString2(val map[string]string) { - p.MapStringString2 = val -} - -var fieldIDToName_InnerBasePartial = map[int16]string{ - 1: "Bool", - 8: "ListInt32", - 9: "MapStringString", - 17: "MapDoubleString", - 18: "ListInnerBase", - 19: "MapInnerBaseInnerBase", - 127: "MapStringString2", -} - -func (p *InnerBasePartial) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.LIST { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.MAP { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 17: - if fieldTypeId == thrift.MAP { - if err = p.ReadField17(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 18: - if fieldTypeId == thrift.LIST { - if err = p.ReadField18(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 19: - if fieldTypeId == thrift.MAP { - if err = p.ReadField19(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 127: - if fieldTypeId == thrift.MAP { - if err = p.ReadField127(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBasePartial[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBasePartial) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Bool = v - } - return nil -} - -func (p *InnerBasePartial) ReadField8(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.ListInt32 = append(p.ListInt32, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) ReadField9(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) ReadField17(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapDoubleString = make(map[float64]string, size) - for i := 0; i < size; i++ { - var _key float64 - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapDoubleString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) ReadField18(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInnerBase = make([]*InnerBasePartial, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBasePartial() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) ReadField19(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInnerBaseInnerBase = make(map[*InnerBasePartial]*InnerBasePartial, size) - for i := 0; i < size; i++ { - _key := NewInnerBasePartial() - if err := _key.Read(iprot); err != nil { - return err - } - _val := NewInnerBasePartial() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) ReadField127(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString2 = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString2[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerBasePartial"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField17(oprot); err != nil { - fieldId = 17 - goto WriteFieldError - } - if err = p.writeField18(oprot); err != nil { - fieldId = 18 - goto WriteFieldError - } - if err = p.writeField19(oprot); err != nil { - fieldId = 19 - goto WriteFieldError - } - if err = p.writeField127(oprot); err != nil { - fieldId = 127 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerBasePartial) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Bool", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Bool); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInt32", thrift.LIST, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I32, len(p.ListInt32)); err != nil { - return err - } - for _, v := range p.ListInt32 { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { - return err - } - for k, v := range p.MapStringString { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField17(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapDoubleString", thrift.MAP, 17); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)); err != nil { - return err - } - for k, v := range p.MapDoubleString { - - if err := oprot.WriteDouble(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 17 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 17 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField18(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInnerBase", thrift.LIST, 18); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListInnerBase)); err != nil { - return err - } - for _, v := range p.ListInnerBase { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField19(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInnerBaseInnerBase", thrift.MAP, 19); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)); err != nil { - return err - } - for k, v := range p.MapInnerBaseInnerBase { - - if err := k.Write(oprot); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField127(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringString2", thrift.MAP, 127); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString2)); err != nil { - return err - } - for k, v := range p.MapStringString2 { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 127 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 127 end error: ", p), err) -} - -func (p *InnerBasePartial) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerBasePartial(%+v)", *p) -} - -func (p *InnerBasePartial) DeepEqual(ano *InnerBasePartial) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Bool) { - return false - } - if !p.Field8DeepEqual(ano.ListInt32) { - return false - } - if !p.Field9DeepEqual(ano.MapStringString) { - return false - } - if !p.Field17DeepEqual(ano.MapDoubleString) { - return false - } - if !p.Field18DeepEqual(ano.ListInnerBase) { - return false - } - if !p.Field19DeepEqual(ano.MapInnerBaseInnerBase) { - return false - } - if !p.Field127DeepEqual(ano.MapStringString2) { - return false - } - return true -} - -func (p *InnerBasePartial) Field1DeepEqual(src bool) bool { - - if p.Bool != src { - return false - } - return true -} -func (p *InnerBasePartial) Field8DeepEqual(src []int32) bool { - - if len(p.ListInt32) != len(src) { - return false - } - for i, v := range p.ListInt32 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *InnerBasePartial) Field9DeepEqual(src map[string]string) bool { - - if len(p.MapStringString) != len(src) { - return false - } - for k, v := range p.MapStringString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBasePartial) Field17DeepEqual(src map[float64]string) bool { - - if len(p.MapDoubleString) != len(src) { - return false - } - for k, v := range p.MapDoubleString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *InnerBasePartial) Field18DeepEqual(src []*InnerBasePartial) bool { - - if len(p.ListInnerBase) != len(src) { - return false - } - for i, v := range p.ListInnerBase { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *InnerBasePartial) Field19DeepEqual(src map[*InnerBasePartial]*InnerBasePartial) bool { - - if len(p.MapInnerBaseInnerBase) != len(src) { - return false - } - for k, v := range p.MapInnerBaseInnerBase { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *InnerBasePartial) Field127DeepEqual(src map[string]string) bool { - - if len(p.MapStringString2) != len(src) { - return false - } - for k, v := range p.MapStringString2 { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} - -type BasePartial struct { - TrafficEnv *base.TrafficEnv `thrift:"TrafficEnv,5" json:"TrafficEnv,omitempty"` -} - -func NewBasePartial() *BasePartial { - return &BasePartial{} -} - -var BasePartial_TrafficEnv_DEFAULT *base.TrafficEnv - -func (p *BasePartial) GetTrafficEnv() (v *base.TrafficEnv) { - if !p.IsSetTrafficEnv() { - return BasePartial_TrafficEnv_DEFAULT - } - return p.TrafficEnv -} -func (p *BasePartial) SetTrafficEnv(val *base.TrafficEnv) { - p.TrafficEnv = val -} - -var fieldIDToName_BasePartial = map[int16]string{ - 5: "TrafficEnv", -} - -func (p *BasePartial) IsSetTrafficEnv() bool { - return p.TrafficEnv != nil -} - -func (p *BasePartial) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 5: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BasePartial[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BasePartial) ReadField5(iprot thrift.TProtocol) error { - p.TrafficEnv = base.NewTrafficEnv() - if err := p.TrafficEnv.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BasePartial) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("BasePartial"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BasePartial) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetTrafficEnv() { - if err = oprot.WriteFieldBegin("TrafficEnv", thrift.STRUCT, 5); err != nil { - goto WriteFieldBeginError - } - if err := p.TrafficEnv.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *BasePartial) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BasePartial(%+v)", *p) -} - -func (p *BasePartial) DeepEqual(ano *BasePartial) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field5DeepEqual(ano.TrafficEnv) { - return false - } - return true -} - -func (p *BasePartial) Field5DeepEqual(src *base.TrafficEnv) bool { - - if !p.TrafficEnv.DeepEqual(src) { - return false - } - return true -} - -type ExampleReq struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` - A *int32 `thrift:"A,2" json:"A,omitempty"` - InnerBase *InnerBase `thrift:"InnerBase,3" json:"InnerBase"` - Base *base.Base `thrift:"Base,255,required" json:"Base"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` -} - -func NewExampleReq() *ExampleReq { - return &ExampleReq{} -} - -var ExampleReq_Msg_DEFAULT string - -func (p *ExampleReq) GetMsg() (v string) { - if !p.IsSetMsg() { - return ExampleReq_Msg_DEFAULT - } - return *p.Msg -} - -var ExampleReq_A_DEFAULT int32 - -func (p *ExampleReq) GetA() (v int32) { - if !p.IsSetA() { - return ExampleReq_A_DEFAULT - } - return *p.A -} - -var ExampleReq_InnerBase_DEFAULT *InnerBase - -func (p *ExampleReq) GetInnerBase() (v *InnerBase) { - if !p.IsSetInnerBase() { - return ExampleReq_InnerBase_DEFAULT - } - return p.InnerBase -} - -var ExampleReq_Base_DEFAULT *base.Base - -func (p *ExampleReq) GetBase() (v *base.Base) { - if !p.IsSetBase() { - return ExampleReq_Base_DEFAULT - } - return p.Base -} - -func (p *ExampleReq) GetSubfix() (v float64) { - return p.Subfix -} -func (p *ExampleReq) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleReq) SetA(val *int32) { - p.A = val -} -func (p *ExampleReq) SetInnerBase(val *InnerBase) { - p.InnerBase = val -} -func (p *ExampleReq) SetBase(val *base.Base) { - p.Base = val -} -func (p *ExampleReq) SetSubfix(val float64) { - p.Subfix = val -} - -var fieldIDToName_ExampleReq = map[int16]string{ - 1: "Msg", - 2: "A", - 3: "InnerBase", - 255: "Base", - 32767: "Subfix", -} - -func (p *ExampleReq) IsSetMsg() bool { - return p.Msg != nil -} - -func (p *ExampleReq) IsSetA() bool { - return p.A != nil -} - -func (p *ExampleReq) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExampleReq) IsSetBase() bool { - return p.Base != nil -} - -func (p *ExampleReq) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - issetBase = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleReq) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.A = &v - } - return nil -} - -func (p *ExampleReq) ReadField3(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBase() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleReq) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleReq"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleReq) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleReq) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetA() { - if err = oprot.WriteFieldBegin("A", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(*p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleReq) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleReq) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleReq) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExampleReq) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleReq(%+v)", *p) -} - -func (p *ExampleReq) DeepEqual(ano *ExampleReq) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.A) { - return false - } - if !p.Field3DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - return true -} - -func (p *ExampleReq) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleReq) Field2DeepEqual(src *int32) bool { - - if p.A == src { - return true - } else if p.A == nil || src == nil { - return false - } - if *p.A != *src { - return false - } - return true -} -func (p *ExampleReq) Field3DeepEqual(src *InnerBase) bool { - - if !p.InnerBase.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleReq) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleReq) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true -} - -type ExampleSuper struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` - A *int32 `thrift:"A,2" json:"A,omitempty"` - InnerBase *InnerBase `thrift:"InnerBase,3" json:"InnerBase"` - Ex1 string `thrift:"Ex1,4" json:"Ex1"` - Ex2 *string `thrift:"Ex2,5" json:"Ex2,omitempty"` - Ex3 *string `thrift:"Ex3,6" json:"Ex3,omitempty"` - Ex4 string `thrift:"Ex4,7,required" json:"Ex4"` - SelfRef *SelfRef `thrift:"SelfRef,9" json:"SelfRef"` - Base *base.Base `thrift:"Base,255,required" json:"Base"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` -} - -func NewExampleSuper() *ExampleSuper { - return &ExampleSuper{} -} - -var ExampleSuper_Msg_DEFAULT string - -func (p *ExampleSuper) GetMsg() (v string) { - if !p.IsSetMsg() { - return ExampleSuper_Msg_DEFAULT - } - return *p.Msg -} - -var ExampleSuper_A_DEFAULT int32 - -func (p *ExampleSuper) GetA() (v int32) { - if !p.IsSetA() { - return ExampleSuper_A_DEFAULT - } - return *p.A -} - -var ExampleSuper_InnerBase_DEFAULT *InnerBase - -func (p *ExampleSuper) GetInnerBase() (v *InnerBase) { - if !p.IsSetInnerBase() { - return ExampleSuper_InnerBase_DEFAULT - } - return p.InnerBase -} - -func (p *ExampleSuper) GetEx1() (v string) { - return p.Ex1 -} - -var ExampleSuper_Ex2_DEFAULT string - -func (p *ExampleSuper) GetEx2() (v string) { - if !p.IsSetEx2() { - return ExampleSuper_Ex2_DEFAULT - } - return *p.Ex2 -} - -var ExampleSuper_Ex3_DEFAULT string - -func (p *ExampleSuper) GetEx3() (v string) { - if !p.IsSetEx3() { - return ExampleSuper_Ex3_DEFAULT - } - return *p.Ex3 -} - -func (p *ExampleSuper) GetEx4() (v string) { - return p.Ex4 -} - -var ExampleSuper_SelfRef_DEFAULT *SelfRef - -func (p *ExampleSuper) GetSelfRef() (v *SelfRef) { - if !p.IsSetSelfRef() { - return ExampleSuper_SelfRef_DEFAULT - } - return p.SelfRef -} - -var ExampleSuper_Base_DEFAULT *base.Base - -func (p *ExampleSuper) GetBase() (v *base.Base) { - if !p.IsSetBase() { - return ExampleSuper_Base_DEFAULT - } - return p.Base -} - -func (p *ExampleSuper) GetSubfix() (v float64) { - return p.Subfix -} -func (p *ExampleSuper) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleSuper) SetA(val *int32) { - p.A = val -} -func (p *ExampleSuper) SetInnerBase(val *InnerBase) { - p.InnerBase = val -} -func (p *ExampleSuper) SetEx1(val string) { - p.Ex1 = val -} -func (p *ExampleSuper) SetEx2(val *string) { - p.Ex2 = val -} -func (p *ExampleSuper) SetEx3(val *string) { - p.Ex3 = val -} -func (p *ExampleSuper) SetEx4(val string) { - p.Ex4 = val -} -func (p *ExampleSuper) SetSelfRef(val *SelfRef) { - p.SelfRef = val -} -func (p *ExampleSuper) SetBase(val *base.Base) { - p.Base = val -} -func (p *ExampleSuper) SetSubfix(val float64) { - p.Subfix = val -} - -var fieldIDToName_ExampleSuper = map[int16]string{ - 1: "Msg", - 2: "A", - 3: "InnerBase", - 4: "Ex1", - 5: "Ex2", - 6: "Ex3", - 7: "Ex4", - 9: "SelfRef", - 255: "Base", - 32767: "Subfix", -} - -func (p *ExampleSuper) IsSetMsg() bool { - return p.Msg != nil -} - -func (p *ExampleSuper) IsSetA() bool { - return p.A != nil -} - -func (p *ExampleSuper) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExampleSuper) IsSetEx2() bool { - return p.Ex2 != nil -} - -func (p *ExampleSuper) IsSetEx3() bool { - return p.Ex3 != nil -} - -func (p *ExampleSuper) IsSetSelfRef() bool { - return p.SelfRef != nil -} - -func (p *ExampleSuper) IsSetBase() bool { - return p.Base != nil -} - -func (p *ExampleSuper) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetEx4 bool = false - var issetBase bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRING { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRING { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - issetEx4 = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - issetBase = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetEx4 { - fieldId = 7 - goto RequiredFieldNotSetError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleSuper[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleSuper[fieldId])) -} - -func (p *ExampleSuper) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleSuper) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.A = &v - } - return nil -} - -func (p *ExampleSuper) ReadField3(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBase() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleSuper) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Ex1 = v - } - return nil -} - -func (p *ExampleSuper) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Ex2 = &v - } - return nil -} - -func (p *ExampleSuper) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Ex3 = &v - } - return nil -} - -func (p *ExampleSuper) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Ex4 = v - } - return nil -} - -func (p *ExampleSuper) ReadField9(iprot thrift.TProtocol) error { - p.SelfRef = NewSelfRef() - if err := p.SelfRef.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleSuper) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleSuper) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleSuper) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleSuper"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleSuper) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleSuper) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetA() { - if err = oprot.WriteFieldBegin("A", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(*p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleSuper) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleSuper) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Ex1", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Ex1); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleSuper) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetEx2() { - if err = oprot.WriteFieldBegin("Ex2", thrift.STRING, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Ex2); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleSuper) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetEx3() { - if err = oprot.WriteFieldBegin("Ex3", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Ex3); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExampleSuper) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Ex4", thrift.STRING, 7); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Ex4); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *ExampleSuper) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SelfRef", thrift.STRUCT, 9); err != nil { - goto WriteFieldBeginError - } - if err := p.SelfRef.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} - -func (p *ExampleSuper) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleSuper) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExampleSuper) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleSuper(%+v)", *p) -} - -func (p *ExampleSuper) DeepEqual(ano *ExampleSuper) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.A) { - return false - } - if !p.Field3DeepEqual(ano.InnerBase) { - return false - } - if !p.Field4DeepEqual(ano.Ex1) { - return false - } - if !p.Field5DeepEqual(ano.Ex2) { - return false - } - if !p.Field6DeepEqual(ano.Ex3) { - return false - } - if !p.Field7DeepEqual(ano.Ex4) { - return false - } - if !p.Field9DeepEqual(ano.SelfRef) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - return true -} - -func (p *ExampleSuper) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleSuper) Field2DeepEqual(src *int32) bool { - - if p.A == src { - return true - } else if p.A == nil || src == nil { - return false - } - if *p.A != *src { - return false - } - return true -} -func (p *ExampleSuper) Field3DeepEqual(src *InnerBase) bool { - - if !p.InnerBase.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleSuper) Field4DeepEqual(src string) bool { - - if strings.Compare(p.Ex1, src) != 0 { - return false - } - return true -} -func (p *ExampleSuper) Field5DeepEqual(src *string) bool { - - if p.Ex2 == src { - return true - } else if p.Ex2 == nil || src == nil { - return false - } - if strings.Compare(*p.Ex2, *src) != 0 { - return false - } - return true -} -func (p *ExampleSuper) Field6DeepEqual(src *string) bool { - - if p.Ex3 == src { - return true - } else if p.Ex3 == nil || src == nil { - return false - } - if strings.Compare(*p.Ex3, *src) != 0 { - return false - } - return true -} -func (p *ExampleSuper) Field7DeepEqual(src string) bool { - - if strings.Compare(p.Ex4, src) != 0 { - return false - } - return true -} -func (p *ExampleSuper) Field9DeepEqual(src *SelfRef) bool { - - if !p.SelfRef.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleSuper) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleSuper) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true -} - -type SelfRef struct { - Self *SelfRef `thrift:"self,1" json:"self,omitempty"` -} - -func NewSelfRef() *SelfRef { - return &SelfRef{} -} - -var SelfRef_Self_DEFAULT *SelfRef - -func (p *SelfRef) GetSelf() (v *SelfRef) { - if !p.IsSetSelf() { - return SelfRef_Self_DEFAULT - } - return p.Self -} -func (p *SelfRef) SetSelf(val *SelfRef) { - p.Self = val -} - -var fieldIDToName_SelfRef = map[int16]string{ - 1: "self", -} - -func (p *SelfRef) IsSetSelf() bool { - return p.Self != nil -} - -func (p *SelfRef) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SelfRef[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *SelfRef) ReadField1(iprot thrift.TProtocol) error { - p.Self = NewSelfRef() - if err := p.Self.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *SelfRef) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("SelfRef"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *SelfRef) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetSelf() { - if err = oprot.WriteFieldBegin("self", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Self.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *SelfRef) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("SelfRef(%+v)", *p) -} - -func (p *SelfRef) DeepEqual(ano *SelfRef) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Self) { - return false - } - return true -} - -func (p *SelfRef) Field1DeepEqual(src *SelfRef) bool { - - if !p.Self.DeepEqual(src) { - return false - } - return true -} - -type ExampleReqPartial struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` - InnerBase *InnerBasePartial `thrift:"InnerBase,3" json:"InnerBase"` - Base *BasePartial `thrift:"Base,255" json:"Base"` -} - -func NewExampleReqPartial() *ExampleReqPartial { - return &ExampleReqPartial{} -} - -var ExampleReqPartial_Msg_DEFAULT string - -func (p *ExampleReqPartial) GetMsg() (v string) { - if !p.IsSetMsg() { - return ExampleReqPartial_Msg_DEFAULT - } - return *p.Msg -} - -var ExampleReqPartial_InnerBase_DEFAULT *InnerBasePartial - -func (p *ExampleReqPartial) GetInnerBase() (v *InnerBasePartial) { - if !p.IsSetInnerBase() { - return ExampleReqPartial_InnerBase_DEFAULT - } - return p.InnerBase -} - -var ExampleReqPartial_Base_DEFAULT *BasePartial - -func (p *ExampleReqPartial) GetBase() (v *BasePartial) { - if !p.IsSetBase() { - return ExampleReqPartial_Base_DEFAULT - } - return p.Base -} -func (p *ExampleReqPartial) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleReqPartial) SetInnerBase(val *InnerBasePartial) { - p.InnerBase = val -} -func (p *ExampleReqPartial) SetBase(val *BasePartial) { - p.Base = val -} - -var fieldIDToName_ExampleReqPartial = map[int16]string{ - 1: "Msg", - 3: "InnerBase", - 255: "Base", -} - -func (p *ExampleReqPartial) IsSetMsg() bool { - return p.Msg != nil -} - -func (p *ExampleReqPartial) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExampleReqPartial) IsSetBase() bool { - return p.Base != nil -} - -func (p *ExampleReqPartial) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReqPartial[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleReqPartial) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleReqPartial) ReadField3(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBasePartial() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReqPartial) ReadField255(iprot thrift.TProtocol) error { - p.Base = NewBasePartial() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReqPartial) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleReqPartial"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleReqPartial) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleReqPartial) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleReqPartial) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleReqPartial) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleReqPartial(%+v)", *p) -} - -func (p *ExampleReqPartial) DeepEqual(ano *ExampleReqPartial) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field3DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true -} - -func (p *ExampleReqPartial) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleReqPartial) Field3DeepEqual(src *InnerBasePartial) bool { - - if !p.InnerBase.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleReqPartial) Field255DeepEqual(src *BasePartial) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} - -type ExampleResp struct { - Msg *string `thrift:"Msg,1" json:"Msg,omitempty"` - RequiredField string `thrift:"required_field,2,required" json:"required_field"` - BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` -} - -func NewExampleResp() *ExampleResp { - return &ExampleResp{} -} - -var ExampleResp_Msg_DEFAULT string - -func (p *ExampleResp) GetMsg() (v string) { - if !p.IsSetMsg() { - return ExampleResp_Msg_DEFAULT - } - return *p.Msg -} - -func (p *ExampleResp) GetRequiredField() (v string) { - return p.RequiredField -} - -var ExampleResp_BaseResp_DEFAULT *base.BaseResp - -func (p *ExampleResp) GetBaseResp() (v *base.BaseResp) { - if !p.IsSetBaseResp() { - return ExampleResp_BaseResp_DEFAULT - } - return p.BaseResp -} -func (p *ExampleResp) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleResp) SetRequiredField(val string) { - p.RequiredField = val -} -func (p *ExampleResp) SetBaseResp(val *base.BaseResp) { - p.BaseResp = val -} - -var fieldIDToName_ExampleResp = map[int16]string{ - 1: "Msg", - 2: "required_field", - 255: "BaseResp", -} - -func (p *ExampleResp) IsSetMsg() bool { - return p.Msg != nil -} - -func (p *ExampleResp) IsSetBaseResp() bool { - return p.BaseResp != nil -} - -func (p *ExampleResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetRequiredField bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - issetRequiredField = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetRequiredField { - fieldId = 2 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.RequiredField = v - } - return nil -} - -func (p *ExampleResp) ReadField255(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleResp) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleResp) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("required_field", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.RequiredField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleResp) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.BaseResp.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleResp) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleResp(%+v)", *p) -} - -func (p *ExampleResp) DeepEqual(ano *ExampleResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.RequiredField) { - return false - } - if !p.Field255DeepEqual(ano.BaseResp) { - return false - } - return true -} - -func (p *ExampleResp) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleResp) Field2DeepEqual(src string) bool { - - if strings.Compare(p.RequiredField, src) != 0 { - return false - } - return true -} -func (p *ExampleResp) Field255DeepEqual(src *base.BaseResp) bool { - - if !p.BaseResp.DeepEqual(src) { - return false - } - return true -} - -type A struct { - Self *A `thrift:"self,1" json:"self"` -} - -func NewA() *A { - return &A{} -} - -var A_Self_DEFAULT *A - -func (p *A) GetSelf() (v *A) { - if !p.IsSetSelf() { - return A_Self_DEFAULT - } - return p.Self -} -func (p *A) SetSelf(val *A) { - p.Self = val -} - -var fieldIDToName_A = map[int16]string{ - 1: "self", -} - -func (p *A) IsSetSelf() bool { - return p.Self != nil -} - -func (p *A) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var ExampleSuper_Ex2_DEFAULT string - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_A[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *A) ReadField1(iprot thrift.TProtocol) error { - p.Self = NewA() - if err := p.Self.Read(iprot); err != nil { - return err +func (p *ExampleSuper) GetEx2() (v string) { + if !p.IsSetEx2() { + return ExampleSuper_Ex2_DEFAULT } - return nil + return *p.Ex2 } -func (p *A) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("A"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } +var ExampleSuper_Ex3_DEFAULT string +func (p *ExampleSuper) GetEx3() (v string) { + if !p.IsSetEx3() { + return ExampleSuper_Ex3_DEFAULT } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *A) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("self", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Self.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) + return *p.Ex3 } -func (p *A) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("A(%+v)", *p) +func (p *ExampleSuper) GetEx4() (v string) { + return p.Ex4 } -func (p *A) DeepEqual(ano *A) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Self) { - return false +var ExampleSuper_SelfRef_DEFAULT *SelfRef + +func (p *ExampleSuper) GetSelfRef() (v *SelfRef) { + if !p.IsSetSelfRef() { + return ExampleSuper_SelfRef_DEFAULT } - return true + return p.SelfRef } -func (p *A) Field1DeepEqual(src *A) bool { +var ExampleSuper_Base_DEFAULT *base.Base - if !p.Self.DeepEqual(src) { - return false +func (p *ExampleSuper) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return ExampleSuper_Base_DEFAULT } - return true + return p.Base } -type Exception struct { - Code int32 `thrift:"code,1" json:"code"` - Msg string `thrift:"msg,255" json:"msg"` +func (p *ExampleSuper) GetSubfix() (v float64) { + return p.Subfix } -func NewException() *Exception { - return &Exception{} +func (p *ExampleSuper) IsSetMsg() bool { + return p.Msg != nil } -func (p *Exception) GetCode() (v int32) { - return p.Code +func (p *ExampleSuper) IsSetA() bool { + return p.A != nil } -func (p *Exception) GetMsg() (v string) { - return p.Msg -} -func (p *Exception) SetCode(val int32) { - p.Code = val +func (p *ExampleSuper) IsSetInnerBase() bool { + return p.InnerBase != nil } -func (p *Exception) SetMsg(val string) { - p.Msg = val + +func (p *ExampleSuper) IsSetEx2() bool { + return p.Ex2 != nil } -var fieldIDToName_Exception = map[int16]string{ - 1: "code", - 255: "msg", +func (p *ExampleSuper) IsSetEx3() bool { + return p.Ex3 != nil } -func (p *Exception) Read(iprot thrift.TProtocol) (err error) { +func (p *ExampleSuper) IsSetSelfRef() bool { + return p.SelfRef != nil +} - var fieldTypeId thrift.TType - var fieldId int16 +func (p *ExampleSuper) IsSetBase() bool { + return p.Base != nil +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError +func (p *ExampleSuper) String() string { + if p == nil { + return "" } + return fmt.Sprintf("ExampleSuper(%+v)", *p) +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRING { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var fieldIDToName_ExampleSuper = map[int16]string{ + 1: "Msg", + 2: "A", + 3: "InnerBase", + 4: "Ex1", + 5: "Ex2", + 6: "Ex3", + 7: "Ex4", + 9: "SelfRef", + 255: "Base", + 32767: "Subfix", +} - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Exception) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Code = v - } - return nil +type SelfRef struct { + Self *SelfRef `thrift:"self,1,optional" json:"self,omitempty"` } -func (p *Exception) ReadField255(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func NewSelfRef() *SelfRef { + return &SelfRef{} } -func (p *Exception) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Exception"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } +func (p *SelfRef) InitDefault() { +} +var SelfRef_Self_DEFAULT *SelfRef + +func (p *SelfRef) GetSelf() (v *SelfRef) { + if !p.IsSetSelf() { + return SelfRef_Self_DEFAULT } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Exception) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) + return p.Self } -func (p *Exception) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 255); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +func (p *SelfRef) IsSetSelf() bool { + return p.Self != nil } -func (p *Exception) String() string { +func (p *SelfRef) String() string { if p == nil { return "" } - return fmt.Sprintf("Exception(%+v)", *p) -} -func (p *Exception) Error() string { - return p.String() + return fmt.Sprintf("SelfRef(%+v)", *p) } -func (p *Exception) DeepEqual(ano *Exception) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Code) { - return false - } - if !p.Field255DeepEqual(ano.Msg) { - return false - } - return true +var fieldIDToName_SelfRef = map[int16]string{ + 1: "self", } -func (p *Exception) Field1DeepEqual(src int32) bool { - - if p.Code != src { - return false - } - return true +type ExampleReqPartial struct { + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` + InnerBase *InnerBasePartial `thrift:"InnerBase,3" json:"InnerBase"` + Base *BasePartial `thrift:"Base,255" json:"Base"` } -func (p *Exception) Field255DeepEqual(src string) bool { - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +func NewExampleReqPartial() *ExampleReqPartial { + return &ExampleReqPartial{} } -type ExampleService interface { - ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) +func (p *ExampleReqPartial) InitDefault() { +} - ExamplePartialMethod(ctx context.Context, req *ExampleReqPartial) (r *A, err error) +var ExampleReqPartial_Msg_DEFAULT string - ExampleSuperMethod(ctx context.Context, req *ExampleSuper) (r *A, err error) +func (p *ExampleReqPartial) GetMsg() (v string) { + if !p.IsSetMsg() { + return ExampleReqPartial_Msg_DEFAULT + } + return *p.Msg +} - Foo(ctx context.Context, req *A) (r *A, err error) +var ExampleReqPartial_InnerBase_DEFAULT *InnerBasePartial - Ping(ctx context.Context, msg string) (r string, err error) +func (p *ExampleReqPartial) GetInnerBase() (v *InnerBasePartial) { + if !p.IsSetInnerBase() { + return ExampleReqPartial_InnerBase_DEFAULT + } + return p.InnerBase +} - Oneway(ctx context.Context, msg string) (err error) +var ExampleReqPartial_Base_DEFAULT *BasePartial - Void(ctx context.Context, msg string) (err error) +func (p *ExampleReqPartial) GetBase() (v *BasePartial) { + if !p.IsSetBase() { + return ExampleReqPartial_Base_DEFAULT + } + return p.Base } -type ExampleServiceClient struct { - c thrift.TClient +func (p *ExampleReqPartial) IsSetMsg() bool { + return p.Msg != nil } -func NewExampleServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } +func (p *ExampleReqPartial) IsSetInnerBase() bool { + return p.InnerBase != nil } -func NewExampleServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } +func (p *ExampleReqPartial) IsSetBase() bool { + return p.Base != nil } -func NewExampleServiceClient(c thrift.TClient) *ExampleServiceClient { - return &ExampleServiceClient{ - c: c, +func (p *ExampleReqPartial) String() string { + if p == nil { + return "" } + return fmt.Sprintf("ExampleReqPartial(%+v)", *p) } -func (p *ExampleServiceClient) Client_() thrift.TClient { - return p.c +var fieldIDToName_ExampleReqPartial = map[int16]string{ + 1: "Msg", + 3: "InnerBase", + 255: "Base", } -func (p *ExampleServiceClient) ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) { - var _args ExampleServiceExampleMethodArgs - _args.Req = req - var _result ExampleServiceExampleMethodResult - if err = p.Client_().Call(ctx, "ExampleMethod", &_args, &_result); err != nil { - return - } - switch { - case _result.Err != nil: - return r, _result.Err - } - return _result.GetSuccess(), nil +type ExampleResp struct { + Msg *string `thrift:"Msg,1,optional" json:"Msg,omitempty"` + RequiredField string `thrift:"required_field,2,required" json:"required_field"` + BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` } -func (p *ExampleServiceClient) ExamplePartialMethod(ctx context.Context, req *ExampleReqPartial) (r *A, err error) { - var _args ExampleServiceExamplePartialMethodArgs - _args.Req = req - var _result ExampleServiceExamplePartialMethodResult - if err = p.Client_().Call(ctx, "ExamplePartialMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func NewExampleResp() *ExampleResp { + return &ExampleResp{} } -func (p *ExampleServiceClient) ExampleSuperMethod(ctx context.Context, req *ExampleSuper) (r *A, err error) { - var _args ExampleServiceExampleSuperMethodArgs - _args.Req = req - var _result ExampleServiceExampleSuperMethodResult - if err = p.Client_().Call(ctx, "ExampleSuperMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleResp) InitDefault() { } -func (p *ExampleServiceClient) Foo(ctx context.Context, req *A) (r *A, err error) { - var _args ExampleServiceFooArgs - _args.Req = req - var _result ExampleServiceFooResult - if err = p.Client_().Call(ctx, "Foo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} +var ExampleResp_Msg_DEFAULT string -func (p *ExampleServiceClient) Ping(ctx context.Context, msg string) (r string, err error) { - var _args ExampleServicePingArgs - _args.Msg = msg - var _result ExampleServicePingResult - if err = p.Client_().Call(ctx, "Ping", &_args, &_result); err != nil { - return +func (p *ExampleResp) GetMsg() (v string) { + if !p.IsSetMsg() { + return ExampleResp_Msg_DEFAULT } - return _result.GetSuccess(), nil + return *p.Msg } -func (p *ExampleServiceClient) Oneway(ctx context.Context, msg string) (err error) { - var _args ExampleServiceOnewayArgs - _args.Msg = msg - if err = p.Client_().Call(ctx, "Oneway", &_args, nil); err != nil { - return - } - return nil +func (p *ExampleResp) GetRequiredField() (v string) { + return p.RequiredField } -func (p *ExampleServiceClient) Void(ctx context.Context, msg string) (err error) { - var _args ExampleServiceVoidArgs - _args.Msg = msg - var _result ExampleServiceVoidResult - if err = p.Client_().Call(ctx, "Void", &_args, &_result); err != nil { - return +var ExampleResp_BaseResp_DEFAULT *base.BaseResp + +func (p *ExampleResp) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return ExampleResp_BaseResp_DEFAULT } - return nil + return p.BaseResp } -type ExampleServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ExampleService +func (p *ExampleResp) IsSetMsg() bool { + return p.Msg != nil } -func (p *ExampleServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor +func (p *ExampleResp) IsSetBaseResp() bool { + return p.BaseResp != nil } -func (p *ExampleServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok +func (p *ExampleResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ExampleResp(%+v)", *p) } -func (p *ExampleServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap +var fieldIDToName_ExampleResp = map[int16]string{ + 1: "Msg", + 2: "required_field", + 255: "BaseResp", } -func NewExampleServiceProcessor(handler ExampleService) *ExampleServiceProcessor { - self := &ExampleServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("ExampleMethod", &exampleServiceProcessorExampleMethod{handler: handler}) - self.AddToProcessorMap("ExamplePartialMethod", &exampleServiceProcessorExamplePartialMethod{handler: handler}) - self.AddToProcessorMap("ExampleSuperMethod", &exampleServiceProcessorExampleSuperMethod{handler: handler}) - self.AddToProcessorMap("Foo", &exampleServiceProcessorFoo{handler: handler}) - self.AddToProcessorMap("Ping", &exampleServiceProcessorPing{handler: handler}) - self.AddToProcessorMap("Oneway", &exampleServiceProcessorOneway{handler: handler}) - self.AddToProcessorMap("Void", &exampleServiceProcessorVoid{handler: handler}) - return self +type A struct { + Self *A `thrift:"self,1" json:"self"` } -func (p *ExampleServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type exampleServiceProcessorExampleMethod struct { - handler ExampleService -} - -func (p *exampleServiceProcessorExampleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleMethodResult{} - var retval *ExampleResp - if retval, err2 = p.handler.ExampleMethod(ctx, args.Req); err2 != nil { - switch v := err2.(type) { - case *Exception: - result.Err = v - default: - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleMethod: "+err2.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +func NewA() *A { + return &A{} } -type exampleServiceProcessorExamplePartialMethod struct { - handler ExampleService +func (p *A) InitDefault() { } -func (p *exampleServiceProcessorExamplePartialMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExamplePartialMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExamplePartialMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +var A_Self_DEFAULT *A - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExamplePartialMethodResult{} - var retval *A - if retval, err2 = p.handler.ExamplePartialMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExamplePartialMethod: "+err2.Error()) - oprot.WriteMessageBegin("ExamplePartialMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExamplePartialMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *A) GetSelf() (v *A) { + if !p.IsSetSelf() { + return A_Self_DEFAULT } - return true, err + return p.Self } -type exampleServiceProcessorExampleSuperMethod struct { - handler ExampleService +func (p *A) IsSetSelf() bool { + return p.Self != nil } -func (p *exampleServiceProcessorExampleSuperMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleSuperMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleSuperMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err +func (p *A) String() string { + if p == nil { + return "" } + return fmt.Sprintf("A(%+v)", *p) +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleSuperMethodResult{} - var retval *A - if retval, err2 = p.handler.ExampleSuperMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleSuperMethod: "+err2.Error()) - oprot.WriteMessageBegin("ExampleSuperMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleSuperMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +var fieldIDToName_A = map[int16]string{ + 1: "self", } -type exampleServiceProcessorFoo struct { - handler ExampleService +type Exception struct { + Code int32 `thrift:"code,1" json:"code"` + Msg string `thrift:"msg,255" json:"msg"` } -func (p *exampleServiceProcessorFoo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceFooArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +func NewException() *Exception { + return &Exception{} +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceFooResult{} - var retval *A - if retval, err2 = p.handler.Foo(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Foo: "+err2.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Foo", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +func (p *Exception) InitDefault() { } -type exampleServiceProcessorPing struct { - handler ExampleService +func (p *Exception) GetCode() (v int32) { + return p.Code } -func (p *exampleServiceProcessorPing) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServicePingArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +func (p *Exception) GetMsg() (v string) { + return p.Msg +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServicePingResult{} - var retval string - if retval, err2 = p.handler.Ping(ctx, args.Msg); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Ping: "+err2.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = &retval - } - if err2 = oprot.WriteMessageBegin("Ping", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *Exception) String() string { + if p == nil { + return "" } - return true, err + return fmt.Sprintf("Exception(%+v)", *p) +} +func (p *Exception) Error() string { + return p.String() } -type exampleServiceProcessorOneway struct { - handler ExampleService +var fieldIDToName_Exception = map[int16]string{ + 1: "code", + 255: "msg", } -func (p *exampleServiceProcessorOneway) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceOnewayArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - return false, err - } +type ExampleService interface { + ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) - iprot.ReadMessageEnd() - var err2 error - if err2 = p.handler.Oneway(ctx, args.Msg); err2 != nil { - return true, err2 - } - return true, nil -} + ExamplePartialMethod(ctx context.Context, req *ExampleReqPartial) (r *A, err error) -type exampleServiceProcessorVoid struct { - handler ExampleService -} + ExampleSuperMethod(ctx context.Context, req *ExampleSuper) (r *A, err error) -func (p *exampleServiceProcessorVoid) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceVoidArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Void", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } + Foo(ctx context.Context, req *A) (r *A, err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceVoidResult{} - if err2 = p.handler.Void(ctx, args.Msg); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Void: "+err2.Error()) - oprot.WriteMessageBegin("Void", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - if err2 = oprot.WriteMessageBegin("Void", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err + Ping(ctx context.Context, msg string) (r string, err error) + + Oneway(ctx context.Context, msg string) (err error) + + Void(ctx context.Context, msg string) (err error) } type ExampleServiceExampleMethodArgs struct { @@ -5491,6 +772,9 @@ func NewExampleServiceExampleMethodArgs() *ExampleServiceExampleMethodArgs { return &ExampleServiceExampleMethodArgs{} } +func (p *ExampleServiceExampleMethodArgs) InitDefault() { +} + var ExampleServiceExampleMethodArgs_Req_DEFAULT *ExampleReq func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { @@ -5499,131 +783,11 @@ func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { } return p.Req } -func (p *ExampleServiceExampleMethodArgs) SetReq(val *ExampleReq) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleReq() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleMethodArgs) String() string { if p == nil { return "" @@ -5631,35 +795,22 @@ func (p *ExampleServiceExampleMethodArgs) String() string { return fmt.Sprintf("ExampleServiceExampleMethodArgs(%+v)", *p) } -func (p *ExampleServiceExampleMethodArgs) DeepEqual(ano *ExampleServiceExampleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodArgs) Field1DeepEqual(src *ExampleReq) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleMethodResult struct { - Success *ExampleResp `thrift:"success,0" json:"success,omitempty"` - Err *Exception `thrift:"err,1" json:"err,omitempty"` + Success *ExampleResp `thrift:"success,0,optional" json:"success,omitempty"` + Err *Exception `thrift:"err,1,optional" json:"err,omitempty"` } func NewExampleServiceExampleMethodResult() *ExampleServiceExampleMethodResult { return &ExampleServiceExampleMethodResult{} } +func (p *ExampleServiceExampleMethodResult) InitDefault() { +} + var ExampleServiceExampleMethodResult_Success_DEFAULT *ExampleResp func (p *ExampleServiceExampleMethodResult) GetSuccess() (v *ExampleResp) { @@ -5677,17 +828,6 @@ func (p *ExampleServiceExampleMethodResult) GetErr() (v *Exception) { } return p.Err } -func (p *ExampleServiceExampleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleResp) -} -func (p *ExampleServiceExampleMethodResult) SetErr(val *Exception) { - p.Err = val -} - -var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ - 0: "success", - 1: "err", -} func (p *ExampleServiceExampleMethodResult) IsSetSuccess() bool { return p.Success != nil @@ -5697,162 +837,6 @@ func (p *ExampleServiceExampleMethodResult) IsSetErr() bool { return p.Err != nil } -func (p *ExampleServiceExampleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleResp() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodResult) ReadField1(iprot thrift.TProtocol) error { - p.Err = NewException() - if err := p.Err.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetErr() { - if err = oprot.WriteFieldBegin("err", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Err.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleMethodResult) String() string { if p == nil { return "" @@ -5860,34 +844,9 @@ func (p *ExampleServiceExampleMethodResult) String() string { return fmt.Sprintf("ExampleServiceExampleMethodResult(%+v)", *p) } -func (p *ExampleServiceExampleMethodResult) DeepEqual(ano *ExampleServiceExampleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - if !p.Field1DeepEqual(ano.Err) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodResult) Field0DeepEqual(src *ExampleResp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleServiceExampleMethodResult) Field1DeepEqual(src *Exception) bool { - - if !p.Err.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ + 0: "success", + 1: "err", } type ExampleServiceExamplePartialMethodArgs struct { @@ -5898,6 +857,9 @@ func NewExampleServiceExamplePartialMethodArgs() *ExampleServiceExamplePartialMe return &ExampleServiceExamplePartialMethodArgs{} } +func (p *ExampleServiceExamplePartialMethodArgs) InitDefault() { +} + var ExampleServiceExamplePartialMethodArgs_Req_DEFAULT *ExampleReqPartial func (p *ExampleServiceExamplePartialMethodArgs) GetReq() (v *ExampleReqPartial) { @@ -5906,131 +868,11 @@ func (p *ExampleServiceExamplePartialMethodArgs) GetReq() (v *ExampleReqPartial) } return p.Req } -func (p *ExampleServiceExamplePartialMethodArgs) SetReq(val *ExampleReqPartial) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExamplePartialMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExamplePartialMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExamplePartialMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExamplePartialMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExamplePartialMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleReqPartial() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExamplePartialMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExamplePartialMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExamplePartialMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExamplePartialMethodArgs) String() string { if p == nil { return "" @@ -6038,34 +880,21 @@ func (p *ExampleServiceExamplePartialMethodArgs) String() string { return fmt.Sprintf("ExampleServiceExamplePartialMethodArgs(%+v)", *p) } -func (p *ExampleServiceExamplePartialMethodArgs) DeepEqual(ano *ExampleServiceExamplePartialMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExamplePartialMethodArgs) Field1DeepEqual(src *ExampleReqPartial) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExamplePartialMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceExamplePartialMethodResult struct { - Success *A `thrift:"success,0" json:"success,omitempty"` + Success *A `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceExamplePartialMethodResult() *ExampleServiceExamplePartialMethodResult { return &ExampleServiceExamplePartialMethodResult{} } +func (p *ExampleServiceExamplePartialMethodResult) InitDefault() { +} + var ExampleServiceExamplePartialMethodResult_Success_DEFAULT *A func (p *ExampleServiceExamplePartialMethodResult) GetSuccess() (v *A) { @@ -6074,133 +903,11 @@ func (p *ExampleServiceExamplePartialMethodResult) GetSuccess() (v *A) { } return p.Success } -func (p *ExampleServiceExamplePartialMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*A) -} - -var fieldIDToName_ExampleServiceExamplePartialMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceExamplePartialMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceExamplePartialMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExamplePartialMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExamplePartialMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewA() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExamplePartialMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExamplePartialMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExamplePartialMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceExamplePartialMethodResult) String() string { if p == nil { return "" @@ -6208,24 +915,8 @@ func (p *ExampleServiceExamplePartialMethodResult) String() string { return fmt.Sprintf("ExampleServiceExamplePartialMethodResult(%+v)", *p) } -func (p *ExampleServiceExamplePartialMethodResult) DeepEqual(ano *ExampleServiceExamplePartialMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceExamplePartialMethodResult) Field0DeepEqual(src *A) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExamplePartialMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceExampleSuperMethodArgs struct { @@ -6236,6 +927,9 @@ func NewExampleServiceExampleSuperMethodArgs() *ExampleServiceExampleSuperMethod return &ExampleServiceExampleSuperMethodArgs{} } +func (p *ExampleServiceExampleSuperMethodArgs) InitDefault() { +} + var ExampleServiceExampleSuperMethodArgs_Req_DEFAULT *ExampleSuper func (p *ExampleServiceExampleSuperMethodArgs) GetReq() (v *ExampleSuper) { @@ -6244,131 +938,11 @@ func (p *ExampleServiceExampleSuperMethodArgs) GetReq() (v *ExampleSuper) { } return p.Req } -func (p *ExampleServiceExampleSuperMethodArgs) SetReq(val *ExampleSuper) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleSuperMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleSuperMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleSuperMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleSuperMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleSuperMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleSuper() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleSuperMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleSuperMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleSuperMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleSuperMethodArgs) String() string { if p == nil { return "" @@ -6376,167 +950,32 @@ func (p *ExampleServiceExampleSuperMethodArgs) String() string { return fmt.Sprintf("ExampleServiceExampleSuperMethodArgs(%+v)", *p) } -func (p *ExampleServiceExampleSuperMethodArgs) DeepEqual(ano *ExampleServiceExampleSuperMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleSuperMethodArgs) Field1DeepEqual(src *ExampleSuper) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleSuperMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleSuperMethodResult struct { - Success *A `thrift:"success,0" json:"success,omitempty"` + Success *A `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceExampleSuperMethodResult() *ExampleServiceExampleSuperMethodResult { return &ExampleServiceExampleSuperMethodResult{} } -var ExampleServiceExampleSuperMethodResult_Success_DEFAULT *A - -func (p *ExampleServiceExampleSuperMethodResult) GetSuccess() (v *A) { - if !p.IsSetSuccess() { - return ExampleServiceExampleSuperMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *ExampleServiceExampleSuperMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*A) -} - -var fieldIDToName_ExampleServiceExampleSuperMethodResult = map[int16]string{ - 0: "success", -} - -func (p *ExampleServiceExampleSuperMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ExampleServiceExampleSuperMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *ExampleServiceExampleSuperMethodResult) InitDefault() { +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var ExampleServiceExampleSuperMethodResult_Success_DEFAULT *A - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleSuperMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleSuperMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewA() - if err := p.Success.Read(iprot); err != nil { - return err +func (p *ExampleServiceExampleSuperMethodResult) GetSuccess() (v *A) { + if !p.IsSetSuccess() { + return ExampleServiceExampleSuperMethodResult_Success_DEFAULT } - return nil + return p.Success } -func (p *ExampleServiceExampleSuperMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleSuperMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleSuperMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +func (p *ExampleServiceExampleSuperMethodResult) IsSetSuccess() bool { + return p.Success != nil } func (p *ExampleServiceExampleSuperMethodResult) String() string { @@ -6546,24 +985,8 @@ func (p *ExampleServiceExampleSuperMethodResult) String() string { return fmt.Sprintf("ExampleServiceExampleSuperMethodResult(%+v)", *p) } -func (p *ExampleServiceExampleSuperMethodResult) DeepEqual(ano *ExampleServiceExampleSuperMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceExampleSuperMethodResult) Field0DeepEqual(src *A) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleSuperMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceFooArgs struct { @@ -6574,6 +997,9 @@ func NewExampleServiceFooArgs() *ExampleServiceFooArgs { return &ExampleServiceFooArgs{} } +func (p *ExampleServiceFooArgs) InitDefault() { +} + var ExampleServiceFooArgs_Req_DEFAULT *A func (p *ExampleServiceFooArgs) GetReq() (v *A) { @@ -6582,131 +1008,11 @@ func (p *ExampleServiceFooArgs) GetReq() (v *A) { } return p.Req } -func (p *ExampleServiceFooArgs) SetReq(val *A) { - p.Req = val -} - -var fieldIDToName_ExampleServiceFooArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceFooArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceFooArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFooArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewA() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFooArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFooArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceFooArgs) String() string { if p == nil { return "" @@ -6714,34 +1020,21 @@ func (p *ExampleServiceFooArgs) String() string { return fmt.Sprintf("ExampleServiceFooArgs(%+v)", *p) } -func (p *ExampleServiceFooArgs) DeepEqual(ano *ExampleServiceFooArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceFooArgs) Field1DeepEqual(src *A) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFooArgs = map[int16]string{ + 1: "req", } type ExampleServiceFooResult struct { - Success *A `thrift:"success,0" json:"success,omitempty"` + Success *A `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceFooResult() *ExampleServiceFooResult { return &ExampleServiceFooResult{} } +func (p *ExampleServiceFooResult) InitDefault() { +} + var ExampleServiceFooResult_Success_DEFAULT *A func (p *ExampleServiceFooResult) GetSuccess() (v *A) { @@ -6750,133 +1043,11 @@ func (p *ExampleServiceFooResult) GetSuccess() (v *A) { } return p.Success } -func (p *ExampleServiceFooResult) SetSuccess(x interface{}) { - p.Success = x.(*A) -} - -var fieldIDToName_ExampleServiceFooResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceFooResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceFooResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFooResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewA() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFooResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFooResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceFooResult) String() string { if p == nil { return "" @@ -6884,24 +1055,8 @@ func (p *ExampleServiceFooResult) String() string { return fmt.Sprintf("ExampleServiceFooResult(%+v)", *p) } -func (p *ExampleServiceFooResult) DeepEqual(ano *ExampleServiceFooResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceFooResult) Field0DeepEqual(src *A) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFooResult = map[int16]string{ + 0: "success", } type ExampleServicePingArgs struct { @@ -6912,129 +1067,11 @@ func NewExampleServicePingArgs() *ExampleServicePingArgs { return &ExampleServicePingArgs{} } -func (p *ExampleServicePingArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServicePingArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServicePingArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServicePingArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServicePingArgs) InitDefault() { } -func (p *ExampleServicePingArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Ping_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePingArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServicePingArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServicePingArgs) String() string { @@ -7044,34 +1081,21 @@ func (p *ExampleServicePingArgs) String() string { return fmt.Sprintf("ExampleServicePingArgs(%+v)", *p) } -func (p *ExampleServicePingArgs) DeepEqual(ano *ExampleServicePingArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServicePingArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServicePingArgs = map[int16]string{ + 1: "msg", } type ExampleServicePingResult struct { - Success *string `thrift:"success,0" json:"success,omitempty"` + Success *string `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServicePingResult() *ExampleServicePingResult { return &ExampleServicePingResult{} } +func (p *ExampleServicePingResult) InitDefault() { +} + var ExampleServicePingResult_Success_DEFAULT string func (p *ExampleServicePingResult) GetSuccess() (v string) { @@ -7080,134 +1104,11 @@ func (p *ExampleServicePingResult) GetSuccess() (v string) { } return *p.Success } -func (p *ExampleServicePingResult) SetSuccess(x interface{}) { - p.Success = x.(*string) -} - -var fieldIDToName_ExampleServicePingResult = map[int16]string{ - 0: "success", -} func (p *ExampleServicePingResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServicePingResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingResult) ReadField0(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Success = &v - } - return nil -} - -func (p *ExampleServicePingResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Ping_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePingResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Success); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServicePingResult) String() string { if p == nil { return "" @@ -7215,29 +1116,8 @@ func (p *ExampleServicePingResult) String() string { return fmt.Sprintf("ExampleServicePingResult(%+v)", *p) } -func (p *ExampleServicePingResult) DeepEqual(ano *ExampleServicePingResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServicePingResult) Field0DeepEqual(src *string) bool { - - if p.Success == src { - return true - } else if p.Success == nil || src == nil { - return false - } - if strings.Compare(*p.Success, *src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServicePingResult = map[int16]string{ + 0: "success", } type ExampleServiceOnewayArgs struct { @@ -7248,129 +1128,11 @@ func NewExampleServiceOnewayArgs() *ExampleServiceOnewayArgs { return &ExampleServiceOnewayArgs{} } -func (p *ExampleServiceOnewayArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServiceOnewayArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServiceOnewayArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServiceOnewayArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOnewayArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceOnewayArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServiceOnewayArgs) InitDefault() { } -func (p *ExampleServiceOnewayArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Oneway_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceOnewayArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceOnewayArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServiceOnewayArgs) String() string { @@ -7380,24 +1142,8 @@ func (p *ExampleServiceOnewayArgs) String() string { return fmt.Sprintf("ExampleServiceOnewayArgs(%+v)", *p) } -func (p *ExampleServiceOnewayArgs) DeepEqual(ano *ExampleServiceOnewayArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServiceOnewayArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceOnewayArgs = map[int16]string{ + 1: "msg", } type ExampleServiceVoidArgs struct { @@ -7408,129 +1154,11 @@ func NewExampleServiceVoidArgs() *ExampleServiceVoidArgs { return &ExampleServiceVoidArgs{} } -func (p *ExampleServiceVoidArgs) GetMsg() (v string) { - return p.Msg -} -func (p *ExampleServiceVoidArgs) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExampleServiceVoidArgs = map[int16]string{ - 1: "msg", -} - -func (p *ExampleServiceVoidArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceVoidArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceVoidArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleServiceVoidArgs) InitDefault() { } -func (p *ExampleServiceVoidArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Void_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceVoidArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceVoidArgs) GetMsg() (v string) { + return p.Msg } func (p *ExampleServiceVoidArgs) String() string { @@ -7540,24 +1168,8 @@ func (p *ExampleServiceVoidArgs) String() string { return fmt.Sprintf("ExampleServiceVoidArgs(%+v)", *p) } -func (p *ExampleServiceVoidArgs) DeepEqual(ano *ExampleServiceVoidArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExampleServiceVoidArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceVoidArgs = map[int16]string{ + 1: "msg", } type ExampleServiceVoidResult struct { @@ -7567,71 +1179,7 @@ func NewExampleServiceVoidResult() *ExampleServiceVoidResult { return &ExampleServiceVoidResult{} } -var fieldIDToName_ExampleServiceVoidResult = map[int16]string{} - -func (p *ExampleServiceVoidResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceVoidResult) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("Void_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +func (p *ExampleServiceVoidResult) InitDefault() { } func (p *ExampleServiceVoidResult) String() string { @@ -7641,11 +1189,9 @@ func (p *ExampleServiceVoidResult) String() string { return fmt.Sprintf("ExampleServiceVoidResult(%+v)", *p) } -func (p *ExampleServiceVoidResult) DeepEqual(ano *ExampleServiceVoidResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} +var fieldIDToName_ExampleServiceVoidResult = map[int16]string{} + +// exceptions of methods in ExampleService. +var ( + _ error = (*Exception)(nil) +) diff --git a/testdata/kitex_gen/example2/k-example2.go b/testdata/kitex_gen/example2/k-example2.go index 368b161b..1b32838a 100644 --- a/testdata/kitex_gen/example2/k-example2.go +++ b/testdata/kitex_gen/example2/k-example2.go @@ -1,5687 +1,2854 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package example2 import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" + "unsafe" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) _ = base.KitexUnusedProtection ) -func (p *InnerBase) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError +func (p *InnerBase) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + off += 3 + off += 1 + + // p.Byte ID:2 thrift.I08 + off += 3 + off += 1 + + // p.Int16 ID:3 thrift.I16 + off += 3 + off += 2 + + // p.Int32 ID:4 thrift.I32 + off += 3 + off += 4 + + // p.Int64 ID:5 thrift.I64 + off += 3 + off += 8 + + // p.Double ID:6 thrift.DOUBLE + off += 3 + off += 8 + + // p.String_ ID:7 thrift.STRING + off += 3 + off += 4 + len(p.String_) + + // p.ListInt32 ID:8 thrift.LIST + off += 3 + off += 5 + off += len(p.ListInt32) * 4 + + // p.MapStringString ID:9 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringString { + off += 4 + len(k) + off += 4 + len(v) + } + + // p.SetInt32 ID:10 thrift.SET + off += 3 + off += 5 + off += len(p.SetInt32) * 4 + + // p.Foo ID:11 thrift.I32 + off += 3 + off += 4 + + // p.MapInt32String ID:12 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt32String) * 4 + for _, v := range p.MapInt32String { + off += 4 + len(v) + } + + // p.Binary ID:13 thrift.STRING + off += 3 + off += 4 + len(p.Binary) + + // p.MapInt8String ID:14 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt8String) * 1 + for _, v := range p.MapInt8String { + off += 4 + len(v) + } + + // p.MapInt16String ID:15 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt16String) * 2 + for _, v := range p.MapInt16String { + off += 4 + len(v) + } + + // p.MapInt64String ID:16 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt64String) * 8 + for _, v := range p.MapInt64String { + off += 4 + len(v) + } + + // p.MapDoubleString ID:17 thrift.MAP + off += 3 + off += 6 + off += len(p.MapDoubleString) * 8 + for _, v := range p.MapDoubleString { + off += 4 + len(v) + } + + // p.ListInnerBase ID:18 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListInnerBase { + off += v.BLength() + } + + // p.MapInnerBaseInnerBase ID:19 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.BLength() + off += v.BLength() + } + + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() + return off + 1 +} + +func (p *InnerBase) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *InnerBase) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Bool))) + off++ + + // p.Byte ID:2 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = byte(p.Byte) + off++ + + // p.Int16 ID:3 thrift.I16 + b[off] = 6 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint16(b[off:], uint16(p.Int16)) + off += 2 + + // p.Int32 ID:4 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Int32)) + off += 4 + + // p.Int64 ID:5 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Int64)) + off += 8 + + // p.Double ID:6 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Double))) + off += 8 + + // p.String_ ID:7 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) + + // p.ListInt32 ID:8 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInt32))) + off += 5 + for _, v := range p.ListInt32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.MapStringString ID:9 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringString))) + off += 6 + for k, v := range p.MapStringString { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.SetInt32 ID:10 thrift.SET + b[off] = 14 + binary.BigEndian.PutUint16(b[off+1:], 10) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.SetInt32))) + off += 5 + for _, v := range p.SetInt32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.Foo ID:11 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 11) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Foo)) + off += 4 + + // p.MapInt32String ID:12 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 12) + off += 3 + b[off] = 8 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt32String))) + off += 6 + for k, v := range p.MapInt32String { + binary.BigEndian.PutUint32(b[off:], uint32(k)) + off += 4 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.Binary ID:13 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 13) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary) + + // p.MapInt8String ID:14 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 14) + off += 3 + b[off] = 3 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt8String))) + off += 6 + for k, v := range p.MapInt8String { + b[off] = byte(k) + off++ + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapInt16String ID:15 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 15) + off += 3 + b[off] = 6 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt16String))) + off += 6 + for k, v := range p.MapInt16String { + binary.BigEndian.PutUint16(b[off:], uint16(k)) + off += 2 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapInt64String ID:16 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 16) + off += 3 + b[off] = 10 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt64String))) + off += 6 + for k, v := range p.MapInt64String { + binary.BigEndian.PutUint64(b[off:], uint64(k)) + off += 8 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapDoubleString ID:17 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 17) + off += 3 + b[off] = 4 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapDoubleString))) + off += 6 + for k, v := range p.MapDoubleString { + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&k))) + off += 8 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.ListInnerBase ID:18 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 18) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInnerBase))) + off += 5 + for _, v := range p.ListInnerBase { + off += v.FastWriteNocopy(b[off:], w) + } + + // p.MapInnerBaseInnerBase ID:19 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 19) + off += 3 + b[off] = 12 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInnerBaseInnerBase))) + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.FastWriteNocopy(b[off:], w) + off += v.FastWriteNocopy(b[off:], w) } + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) + + b[off] = 0 + return off + 1 +} + +func (p *InnerBase) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var enum int32 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x102: // p.Bool ID:1 thrift.BOOL + p.Bool, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x203: // p.Byte ID:2 thrift.I08 + p.Byte, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.I16 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x306: // p.Int16 ID:3 thrift.I16 + p.Int16, l, err = x.ReadI16(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x408: // p.Int32 ID:4 thrift.I32 + p.Int32, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x50a: // p.Int64 ID:5 thrift.I64 + p.Int64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x604: // p.Double ID:6 thrift.DOUBLE + p.Double, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x70b: // p.String_ ID:7 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x80f: // p.ListInt32 ID:8 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField5(buf[offset:]) - offset += l + p.ListInt32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.ListInt32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 6: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField6(buf[offset:]) - offset += l + case 0x90d: // p.MapStringString ID:9 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapStringString = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringString[k] = v + } + case 0xa0e: // p.SetInt32 ID:10 thrift.SET + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 7: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField7(buf[offset:]) - offset += l + p.SetInt32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.SetInt32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 8: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField8(buf[offset:]) - offset += l + case 0xb08: // p.Foo ID:11 thrift.I32 + enum, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Foo = FOO(enum) + case 0xc0d: // p.MapInt32String ID:12 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapInt32String = make(map[int32]string, sz) + for i := 0; i < sz; i++ { + var k int32 + var v string + k, l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt32String[k] = v + } + case 0xd0b: // p.Binary ID:13 thrift.STRING + p.Binary, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xe0d: // p.MapInt8String ID:14 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField9(buf[offset:]) - offset += l + p.MapInt8String = make(map[int8]string, sz) + for i := 0; i < sz; i++ { + var k int8 + var v string + k, l, err = x.ReadByte(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt8String[k] = v } - case 10: - if fieldTypeId == thrift.SET { - l, err = p.FastReadField10(buf[offset:]) - offset += l + case 0xf0d: // p.MapInt16String ID:15 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapInt16String = make(map[int16]string, sz) + for i := 0; i < sz; i++ { + var k int16 + var v string + k, l, err = x.ReadI16(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt16String[k] = v + } + case 0x100d: // p.MapInt64String ID:16 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 11: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField11(buf[offset:]) - offset += l + p.MapInt64String = make(map[int64]string, sz) + for i := 0; i < sz; i++ { + var k int64 + var v string + k, l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt64String[k] = v + } + case 0x110d: // p.MapDoubleString ID:17 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 12: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField12(buf[offset:]) - offset += l + p.MapDoubleString = make(map[float64]string, sz) + for i := 0; i < sz; i++ { + var k float64 + var v string + k, l, err = x.ReadDouble(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapDoubleString[k] = v + } + case 0x120f: // p.ListInnerBase ID:18 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 13: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField13(buf[offset:]) - offset += l + p.ListInnerBase = make([]*InnerBase, sz) + for i := 0; i < sz; i++ { + p.ListInnerBase[i] = NewInnerBase() + l, err = p.ListInnerBase[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 14: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField14(buf[offset:]) - offset += l + case 0x130d: // p.MapInnerBaseInnerBase ID:19 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, sz) + for i := 0; i < sz; i++ { + var k *InnerBase + var v *InnerBase + k = NewInnerBase() + l, err = k.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v = NewInnerBase() + l, err = v.FastRead(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInnerBaseInnerBase[k] = v + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerBase[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +} + +func (p *InnerBasePartial) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + off += 3 + off += 1 + + // p.ListInt32 ID:8 thrift.LIST + off += 3 + off += 5 + off += len(p.ListInt32) * 4 + + // p.MapStringString ID:9 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringString { + off += 4 + len(k) + off += 4 + len(v) + } + + // p.MapDoubleString ID:17 thrift.MAP + off += 3 + off += 6 + off += len(p.MapDoubleString) * 8 + for _, v := range p.MapDoubleString { + off += 4 + len(v) + } + + // p.ListInnerBase ID:18 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListInnerBase { + off += v.BLength() + } + + // p.MapInnerBaseInnerBase ID:19 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.BLength() + off += v.BLength() + } + + // p.MapStringString2 ID:127 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringString2 { + off += 4 + len(k) + off += 4 + len(v) + } + return off + 1 +} + +func (p *InnerBasePartial) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *InnerBasePartial) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Bool))) + off++ + + // p.ListInt32 ID:8 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInt32))) + off += 5 + for _, v := range p.ListInt32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.MapStringString ID:9 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringString))) + off += 6 + for k, v := range p.MapStringString { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapDoubleString ID:17 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 17) + off += 3 + b[off] = 4 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapDoubleString))) + off += 6 + for k, v := range p.MapDoubleString { + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&k))) + off += 8 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.ListInnerBase ID:18 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 18) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInnerBase))) + off += 5 + for _, v := range p.ListInnerBase { + off += v.FastWriteNocopy(b[off:], w) + } + + // p.MapInnerBaseInnerBase ID:19 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 19) + off += 3 + b[off] = 12 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInnerBaseInnerBase))) + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.FastWriteNocopy(b[off:], w) + off += v.FastWriteNocopy(b[off:], w) + } + + // p.MapStringString2 ID:127 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 127) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringString2))) + off += 6 + for k, v := range p.MapStringString2 { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + b[off] = 0 + return off + 1 +} + +func (p *InnerBasePartial) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x102: // p.Bool ID:1 thrift.BOOL + p.Bool, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x80f: // p.ListInt32 ID:8 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 15: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField15(buf[offset:]) - offset += l + p.ListInt32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.ListInt32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 16: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField16(buf[offset:]) - offset += l + case 0x90d: // p.MapStringString ID:9 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapStringString = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringString[k] = v + } + case 0x110d: // p.MapDoubleString ID:17 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 17: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField17(buf[offset:]) - offset += l + p.MapDoubleString = make(map[float64]string, sz) + for i := 0; i < sz; i++ { + var k float64 + var v string + k, l, err = x.ReadDouble(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapDoubleString[k] = v } - case 18: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField18(buf[offset:]) - offset += l + case 0x120f: // p.ListInnerBase ID:18 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListInnerBase = make([]*InnerBasePartial, sz) + for i := 0; i < sz; i++ { + p.ListInnerBase[i] = NewInnerBasePartial() + l, err = p.ListInnerBase[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 19: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField19(buf[offset:]) - offset += l + case 0x130d: // p.MapInnerBaseInnerBase ID:19 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapInnerBaseInnerBase = make(map[*InnerBasePartial]*InnerBasePartial, sz) + for i := 0; i < sz; i++ { + var k *InnerBasePartial + var v *InnerBasePartial + k = NewInnerBasePartial() + l, err = k.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v = NewInnerBasePartial() + l, err = v.FastRead(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInnerBaseInnerBase[k] = v + } + case 0x7f0d: // p.MapStringString2 ID:127 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l + p.MapStringString2 = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringString2[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBase[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerBasePartial[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *InnerBase) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Bool = v - +func (p *BasePartial) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *InnerBase) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v + off := 0 + // p.TrafficEnv ID:5 thrift.STRUCT + if p.TrafficEnv != nil { + off += 3 + off += p.TrafficEnv.BLength() } - return offset, nil + return off + 1 } -func (p *InnerBase) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int16 = v +func (p *BasePartial) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *BasePartial) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} - -func (p *InnerBase) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int32 = v + off := 0 + // p.TrafficEnv ID:5 thrift.STRUCT + if p.TrafficEnv != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += p.TrafficEnv.FastWriteNocopy(b[off:], w) } - return offset, nil -} - -func (p *InnerBase) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Int64 = v - - } - return offset, nil + b[off] = 0 + return off + 1 } -func (p *InnerBase) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - +func (p *BasePartial) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x50c: // p.TrafficEnv ID:5 thrift.STRUCT + p.TrafficEnv = base.NewTrafficEnv() + l, err = p.TrafficEnv.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - return offset, nil + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_BasePartial[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *InnerBase) FastReadField7(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - +func (p *ExampleReq) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *InnerBase) FastReadField8(buf []byte) (int, error) { - offset := 0 + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) + } - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err + // p.A ID:2 thrift.I32 + if p.A != nil { + off += 3 + off += 4 } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - _elem = v + // p.InnerBase ID:3 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() - } + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() - p.ListInt32 = append(p.ListInt32, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 } -func (p *InnerBase) FastReadField9(buf []byte) (int, error) { - offset := 0 +func (p *ExampleReq) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err +func (p *ExampleReq) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - _key = v + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) + } - } + // p.A ID:2 thrift.I32 + if p.A != nil { + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(*p.A)) + off += 4 + } - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.InnerBase ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) - _val = v + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) - } + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 - p.MapStringString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil + b[off] = 0 + return off + 1 } -func (p *InnerBase) FastReadField10(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.SetInt32_ = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.SetInt32_ = append(p.SetInt32_, _elem) - } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField11(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Foo = FOO(v) - - } - return offset, nil -} - -func (p *InnerBase) FastReadField12(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt32String = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt32String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField13(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *InnerBase) FastReadField14(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt8String = make(map[int8]string, size) - for i := 0; i < size; i++ { - var _key int8 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt8String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField15(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt16String = make(map[int16]string, size) - for i := 0; i < size; i++ { - var _key int16 - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt16String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField16(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt64String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField17(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapDoubleString = make(map[float64]string, size) - for i := 0; i < size; i++ { - var _key float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapDoubleString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField18(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListInnerBase = make([]*InnerBase, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBase() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField19(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, size) - for i := 0; i < size; i++ { - _key := NewInnerBase() - if l, err := _key.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - _val := NewInnerBase() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *InnerBase) FastWrite(buf []byte) int { - return 0 -} - -func (p *InnerBase) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerBase") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField10(buf[offset:], binaryWriter) - offset += p.fastWriteField11(buf[offset:], binaryWriter) - offset += p.fastWriteField12(buf[offset:], binaryWriter) - offset += p.fastWriteField13(buf[offset:], binaryWriter) - offset += p.fastWriteField14(buf[offset:], binaryWriter) - offset += p.fastWriteField15(buf[offset:], binaryWriter) - offset += p.fastWriteField16(buf[offset:], binaryWriter) - offset += p.fastWriteField17(buf[offset:], binaryWriter) - offset += p.fastWriteField18(buf[offset:], binaryWriter) - offset += p.fastWriteField19(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerBase") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field9Length() - l += p.field10Length() - l += p.field11Length() - l += p.field12Length() - l += p.field13Length() - l += p.field14Length() - l += p.field15Length() - l += p.field16Length() - l += p.field17Length() - l += p.field18Length() - l += p.field19Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerBase) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 2) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int16", thrift.I16, 3) - offset += bthrift.Binary.WriteI16(buf[offset:], p.Int16) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int32", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Int32) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int64", thrift.I64, 5) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Int64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 6) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 7) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInt32", thrift.LIST, 8) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I32, len(p.ListInt32)) - for _, v := range p.ListInt32 { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 9) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SetInt32", thrift.SET, 10) - offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.I32, len(p.SetInt32_)) - - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - for _, v := range p.SetInt32_ { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Foo", thrift.I32, 11) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Foo)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt32String", thrift.MAP, 12) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I32, thrift.STRING, len(p.MapInt32String)) - for k, v := range p.MapInt32String { - - offset += bthrift.Binary.WriteI32(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 13) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt8String", thrift.MAP, 14) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.BYTE, thrift.STRING, len(p.MapInt8String)) - for k, v := range p.MapInt8String { - - offset += bthrift.Binary.WriteByte(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt16String", thrift.MAP, 15) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I16, thrift.STRING, len(p.MapInt16String)) - for k, v := range p.MapInt16String { - - offset += bthrift.Binary.WriteI16(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField16(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt64String", thrift.MAP, 16) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I64, thrift.STRING, len(p.MapInt64String)) - for k, v := range p.MapInt64String { - - offset += bthrift.Binary.WriteI64(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField17(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapDoubleString", thrift.MAP, 17) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)) - for k, v := range p.MapDoubleString { - - offset += bthrift.Binary.WriteDouble(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField18(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInnerBase", thrift.LIST, 18) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField19(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInnerBaseInnerBase", thrift.MAP, 19) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - offset += k.FastWriteNocopy(buf[offset:], binaryWriter) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Bool) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 2) - l += bthrift.Binary.ByteLength(p.Byte) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int16", thrift.I16, 3) - l += bthrift.Binary.I16Length(p.Int16) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int32", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.Int32) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int64", thrift.I64, 5) - l += bthrift.Binary.I64Length(p.Int64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 6) - l += bthrift.Binary.DoubleLength(p.Double) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 7) - l += bthrift.Binary.StringLength(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInt32", thrift.LIST, 8) - l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListInt32)) - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.ListInt32) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 9) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field10Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SetInt32", thrift.SET, 10) - l += bthrift.Binary.SetBeginLength(thrift.I32, len(p.SetInt32_)) - - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.SetInt32_) - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Foo", thrift.I32, 11) - l += bthrift.Binary.I32Length(int32(p.Foo)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field12Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt32String", thrift.MAP, 12) - l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.STRING, len(p.MapInt32String)) - for k, v := range p.MapInt32String { - - l += bthrift.Binary.I32Length(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field13Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 13) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field14Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt8String", thrift.MAP, 14) - l += bthrift.Binary.MapBeginLength(thrift.BYTE, thrift.STRING, len(p.MapInt8String)) - for k, v := range p.MapInt8String { - - l += bthrift.Binary.ByteLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field15Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt16String", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.I16, thrift.STRING, len(p.MapInt16String)) - for k, v := range p.MapInt16String { - - l += bthrift.Binary.I16Length(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field16Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt64String", thrift.MAP, 16) - l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, len(p.MapInt64String)) - for k, v := range p.MapInt64String { - - l += bthrift.Binary.I64Length(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field17Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapDoubleString", thrift.MAP, 17) - l += bthrift.Binary.MapBeginLength(thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)) - for k, v := range p.MapDoubleString { - - l += bthrift.Binary.DoubleLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field18Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInnerBase", thrift.LIST, 18) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field19Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInnerBaseInnerBase", thrift.MAP, 19) - l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - l += k.BLength() - - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 17: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField17(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 18: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField18(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 19: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField19(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 127: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField127(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBasePartial[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBasePartial) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Bool = v - - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField8(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListInt32 = append(p.ListInt32, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField9(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapStringString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField17(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapDoubleString = make(map[float64]string, size) - for i := 0; i < size; i++ { - var _key float64 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapDoubleString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField18(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListInnerBase = make([]*InnerBasePartial, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBasePartial() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField19(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInnerBaseInnerBase = make(map[*InnerBasePartial]*InnerBasePartial, size) - for i := 0; i < size; i++ { - _key := NewInnerBasePartial() - if l, err := _key.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - _val := NewInnerBasePartial() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField127(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringString2 = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapStringString2[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *InnerBasePartial) FastWrite(buf []byte) int { - return 0 -} - -func (p *InnerBasePartial) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerBasePartial") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField17(buf[offset:], binaryWriter) - offset += p.fastWriteField18(buf[offset:], binaryWriter) - offset += p.fastWriteField19(buf[offset:], binaryWriter) - offset += p.fastWriteField127(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerBasePartial") - if p != nil { - l += p.field1Length() - l += p.field8Length() - l += p.field9Length() - l += p.field17Length() - l += p.field18Length() - l += p.field19Length() - l += p.field127Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerBasePartial) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInt32", thrift.LIST, 8) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I32, len(p.ListInt32)) - for _, v := range p.ListInt32 { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 9) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField17(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapDoubleString", thrift.MAP, 17) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)) - for k, v := range p.MapDoubleString { - - offset += bthrift.Binary.WriteDouble(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField18(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInnerBase", thrift.LIST, 18) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField19(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInnerBaseInnerBase", thrift.MAP, 19) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - offset += k.FastWriteNocopy(buf[offset:], binaryWriter) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField127(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString2", thrift.MAP, 127) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.MapStringString2)) - for k, v := range p.MapStringString2 { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Bool) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInt32", thrift.LIST, 8) - l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListInt32)) - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.ListInt32) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 9) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field17Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapDoubleString", thrift.MAP, 17) - l += bthrift.Binary.MapBeginLength(thrift.DOUBLE, thrift.STRING, len(p.MapDoubleString)) - for k, v := range p.MapDoubleString { - - l += bthrift.Binary.DoubleLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field18Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInnerBase", thrift.LIST, 18) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field19Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInnerBaseInnerBase", thrift.MAP, 19) - l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - l += k.BLength() - - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field127Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString2", thrift.MAP, 127) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString2)) - for k, v := range p.MapStringString2 { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BasePartial) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 5: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BasePartial[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BasePartial) FastReadField5(buf []byte) (int, error) { - offset := 0 - p.TrafficEnv = base.NewTrafficEnv() - if l, err := p.TrafficEnv.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *BasePartial) FastWrite(buf []byte) int { - return 0 -} - -func (p *BasePartial) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BasePartial") - if p != nil { - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BasePartial) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("BasePartial") - if p != nil { - l += p.field5Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BasePartial) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetTrafficEnv() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "TrafficEnv", thrift.STRUCT, 5) - offset += p.TrafficEnv.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BasePartial) field5Length() int { - l := 0 - if p.IsSetTrafficEnv() { - l += bthrift.Binary.FieldBeginLength("TrafficEnv", thrift.STRUCT, 5) - l += p.TrafficEnv.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetBase bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetBase = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetBase { - fieldId = 255 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.A = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBase() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleReq) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleReq) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleReq) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleReq") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleReq") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field255Length() - l += p.field32767Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetA() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], *p.A) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 3) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(*p.Msg) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field2Length() int { - l := 0 - if p.IsSetA() { - l += bthrift.Binary.FieldBeginLength("A", thrift.I32, 2) - l += bthrift.Binary.I32Length(*p.A) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 3) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleSuper) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleReq) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetEx4 bool = false - var issetBase bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - case 5: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x208: // p.A ID:2 thrift.I32 + if p.A == nil { + p.A = new(int32) } - case 7: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetEx4 = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.A, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30c: // p.InnerBase ID:3 thrift.STRUCT + p.InnerBase = NewInnerBase() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetBase = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + isset |= 0x1 + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetEx4 { - fieldId = 7 - goto RequiredFieldNotSetError } - - if !issetBase { - fieldId = 255 + if isset&0x1 == 0 { + fid = 255 // Base goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleSuper[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleReq[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleSuper[fieldId])) -} - -func (p *ExampleSuper) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.A = &v - - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBase() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Ex1 = v - - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Ex2 = &v - - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Ex3 = &v - - } - return offset, nil -} - -func (p *ExampleSuper) FastReadField7(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Ex4 = v - - } - return offset, nil + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleReq[fid])) } -func (p *ExampleSuper) FastReadField9(buf []byte) (int, error) { - offset := 0 - p.SelfRef = NewSelfRef() - if l, err := p.SelfRef.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleSuper) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleSuper) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset, nil -} - -func (p *ExampleSuper) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v + // p.A ID:2 thrift.I32 + if p.A != nil { + off += 3 + off += 4 } - return offset, nil -} -// for compatibility -func (p *ExampleSuper) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleSuper) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleSuper") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleSuper) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleSuper") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field9Length() - l += p.field255Length() - l += p.field32767Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + // p.InnerBase ID:3 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() -func (p *ExampleSuper) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) + // p.Ex1 ID:4 thrift.STRING + off += 3 + off += 4 + len(p.Ex1) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Ex2 ID:5 thrift.STRING + if p.Ex2 != nil { + off += 3 + off += 4 + len(*p.Ex2) } - return offset -} - -func (p *ExampleSuper) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetA() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], *p.A) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Ex3 ID:6 thrift.STRING + if p.Ex3 != nil { + off += 3 + off += 4 + len(*p.Ex3) } - return offset -} - -func (p *ExampleSuper) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 3) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} -func (p *ExampleSuper) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Ex1", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Ex1) + // p.Ex4 ID:7 thrift.STRING + off += 3 + off += 4 + len(p.Ex4) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.SelfRef ID:9 thrift.STRUCT + off += 3 + off += p.SelfRef.BLength() -func (p *ExampleSuper) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetEx2() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Ex2", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Ex2) + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 } -func (p *ExampleSuper) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetEx3() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Ex3", thrift.STRING, 6) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Ex3) +func (p *ExampleSuper) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleSuper) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} - -func (p *ExampleSuper) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Ex4", thrift.STRING, 7) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Ex4) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleSuper) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SelfRef", thrift.STRUCT, 9) - offset += p.SelfRef.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleSuper) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleSuper) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleSuper) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(*p.Msg) - - l += bthrift.Binary.FieldEndLength() + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) } - return l -} -func (p *ExampleSuper) field2Length() int { - l := 0 - if p.IsSetA() { - l += bthrift.Binary.FieldBeginLength("A", thrift.I32, 2) - l += bthrift.Binary.I32Length(*p.A) - - l += bthrift.Binary.FieldEndLength() + // p.A ID:2 thrift.I32 + if p.A != nil { + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(*p.A)) + off += 4 } - return l -} -func (p *ExampleSuper) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 3) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleSuper) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Ex1", thrift.STRING, 4) - l += bthrift.Binary.StringLength(p.Ex1) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.InnerBase ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) -func (p *ExampleSuper) field5Length() int { - l := 0 - if p.IsSetEx2() { - l += bthrift.Binary.FieldBeginLength("Ex2", thrift.STRING, 5) - l += bthrift.Binary.StringLength(*p.Ex2) + // p.Ex1 ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Ex1) - l += bthrift.Binary.FieldEndLength() + // p.Ex2 ID:5 thrift.STRING + if p.Ex2 != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Ex2) } - return l -} - -func (p *ExampleSuper) field6Length() int { - l := 0 - if p.IsSetEx3() { - l += bthrift.Binary.FieldBeginLength("Ex3", thrift.STRING, 6) - l += bthrift.Binary.StringLength(*p.Ex3) - l += bthrift.Binary.FieldEndLength() + // p.Ex3 ID:6 thrift.STRING + if p.Ex3 != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Ex3) } - return l -} - -func (p *ExampleSuper) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Ex4", thrift.STRING, 7) - l += bthrift.Binary.StringLength(p.Ex4) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleSuper) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SelfRef", thrift.STRUCT, 9) - l += p.SelfRef.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} -func (p *ExampleSuper) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Ex4 ID:7 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Ex4) -func (p *ExampleSuper) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) + // p.SelfRef ID:9 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + off += p.SelfRef.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) -func (p *SelfRef) FastRead(buf []byte) (int, error) { - var err error - var offset int + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleSuper) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + *p.Msg, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SelfRef[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *SelfRef) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Self = NewSelfRef() - if l, err := p.Self.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *SelfRef) FastWrite(buf []byte) int { - return 0 -} - -func (p *SelfRef) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SelfRef") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *SelfRef) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("SelfRef") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *SelfRef) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSelf() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "self", thrift.STRUCT, 1) - offset += p.Self.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *SelfRef) field1Length() int { - l := 0 - if p.IsSetSelf() { - l += bthrift.Binary.FieldBeginLength("self", thrift.STRUCT, 1) - l += p.Self.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReqPartial) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x208: // p.A ID:2 thrift.I32 + if p.A == nil { + p.A = new(int32) } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.A, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30c: // p.InnerBase ID:3 thrift.STRUCT + p.InnerBase = NewInnerBase() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x40b: // p.Ex1 ID:4 thrift.STRING + p.Ex1, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x50b: // p.Ex2 ID:5 thrift.STRING + if p.Ex2 == nil { + p.Ex2 = new(string) + } + *p.Ex2, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x60b: // p.Ex3 ID:6 thrift.STRING + if p.Ex3 == nil { + p.Ex3 = new(string) + } + *p.Ex3, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x70b: // p.Ex4 ID:7 thrift.STRING + p.Ex4, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x90c: // p.SelfRef ID:9 thrift.STRUCT + p.SelfRef = NewSelfRef() + l, err = p.SelfRef.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x2 + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 7 // Ex4 + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + if isset&0x2 == 0 { + fid = 255 // Base + goto RequiredFieldNotSetError + } + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReqPartial[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleSuper[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleSuper[fid])) } -func (p *ExampleReqPartial) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v +func (p *SelfRef) BLength() int { + if p == nil { + return 1 + } + off := 0 + // p.Self ID:1 thrift.STRUCT + if p.Self != nil { + off += 3 + off += p.Self.BLength() } - return offset, nil + return off + 1 } -func (p *ExampleReqPartial) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBasePartial() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *SelfRef) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *SelfRef) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleReqPartial) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = NewBasePartial() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Self ID:1 thrift.STRUCT + if p.Self != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Self.FastWriteNocopy(b[off:], w) } - return offset, nil -} -// for compatibility -func (p *ExampleReqPartial) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *ExampleReqPartial) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleReqPartial") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *SelfRef) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Self ID:1 thrift.STRUCT + p.Self = NewSelfRef() + l, err = p.Self.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_SelfRef[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *ExampleReqPartial) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleReqPartial") - if p != nil { - l += p.field1Length() - l += p.field3Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleReqPartial) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) + if p == nil { + return 1 + } + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset -} -func (p *ExampleReqPartial) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 3) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.InnerBase ID:3 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() -func (p *ExampleReqPartial) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() + return off + 1 } -func (p *ExampleReqPartial) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(*p.Msg) +func (p *ExampleReqPartial) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += bthrift.Binary.FieldEndLength() +func (p *ExampleReqPartial) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l -} + off := 0 -func (p *ExampleReqPartial) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 3) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) + } + + // p.InnerBase ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) + + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) -func (p *ExampleReqPartial) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleResp) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleReqPartial) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetRequiredField bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetRequiredField = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30c: // p.InnerBase ID:3 thrift.STRUCT + p.InnerBase = NewInnerBasePartial() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = NewBasePartial() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetRequiredField { - fieldId = 2 - goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleReqPartial[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.RequiredField = v - +func (p *ExampleResp) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleResp) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.BaseResp = base.NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset, nil -} -// for compatibility -func (p *ExampleResp) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleResp") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + // p.RequiredField ID:2 thrift.STRING + off += 3 + off += 4 + len(p.RequiredField) -func (p *ExampleResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleResp") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + // p.BaseResp ID:255 thrift.STRUCT + off += 3 + off += p.BaseResp.BLength() + return off + 1 } -func (p *ExampleResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) +func (p *ExampleResp) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleResp) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} - -func (p *ExampleResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "required_field", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RequiredField) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleResp) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BaseResp", thrift.STRUCT, 255) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(*p.Msg) - - l += bthrift.Binary.FieldEndLength() + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) } - return l -} -func (p *ExampleResp) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("required_field", thrift.STRING, 2) - l += bthrift.Binary.StringLength(p.RequiredField) + // p.RequiredField ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.RequiredField) - l += bthrift.Binary.FieldEndLength() - return l -} + // p.BaseResp ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.BaseResp.FastWriteNocopy(b[off:], w) -func (p *ExampleResp) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 255) - l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *A) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleResp) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) + } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20b: // p.RequiredField ID:2 thrift.STRING + p.RequiredField, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0xff0c: // p.BaseResp ID:255 thrift.STRUCT + p.BaseResp = base.NewBaseResp() + l, err = p.BaseResp.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 2 // RequiredField + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_A[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleResp[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleResp[fid])) } -func (p *A) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Self = NewA() - if l, err := p.Self.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *A) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *A) FastWrite(buf []byte) int { - return 0 + // p.Self ID:1 thrift.STRUCT + off += 3 + off += p.Self.BLength() + return off + 1 } -func (p *A) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "A") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *A) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *A) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("A") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *A) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *A) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "self", thrift.STRUCT, 1) - offset += p.Self.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Self ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Self.FastWriteNocopy(b[off:], w) -func (p *A) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("self", thrift.STRUCT, 1) - l += p.Self.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *Exception) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *A) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Self ID:1 thrift.STRUCT + p.Self = NewA() + l, err = p.Self.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_A[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Exception) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - +func (p *Exception) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *Exception) FastReadField255(buf []byte) (int, error) { - offset := 0 + // p.Code ID:1 thrift.I32 + off += 3 + off += 4 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil + // p.Msg ID:255 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -// for compatibility -func (p *Exception) FastWrite(buf []byte) int { - return 0 -} +func (p *Exception) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *Exception) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Exception") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) +func (p *Exception) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Exception) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Exception") - if p != nil { - l += p.field1Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Exception) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Exception) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 255) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Exception) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(p.Code) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Code ID:1 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Code)) + off += 4 -func (p *Exception) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 255) - l += bthrift.Binary.StringLength(p.Msg) + // p.Msg ID:255 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Exception) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x108: // p.Code ID:1 thrift.I32 + p.Code, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0b: // p.Msg ID:255 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Exception[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleReq() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceExampleMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceExampleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleReq() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleResp() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleServiceExampleMethodResult) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Err = NewException() - if l, err := p.Err.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceExampleMethodResult) FastWrite(buf []byte) int { - return 0 -} -func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + off += 3 + off += p.Err.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_result") - if p != nil { - l += p.field0Length() - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExampleMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleMethodResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetErr() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "err", thrift.STRUCT, 1) - offset += p.Err.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return offset -} -func (p *ExampleServiceExampleMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Err.FastWriteNocopy(b[off:], w) } - return l -} -func (p *ExampleServiceExampleMethodResult) field1Length() int { - l := 0 - if p.IsSetErr() { - l += bthrift.Binary.FieldBeginLength("err", thrift.STRUCT, 1) - l += p.Err.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExamplePartialMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleResp() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x10c: // p.Err ID:1 thrift.STRUCT + p.Err = NewException() + l, err = p.Err.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExamplePartialMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExamplePartialMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleReqPartial() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExamplePartialMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExamplePartialMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExamplePartialMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplePartialMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceExamplePartialMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExamplePartialMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExamplePartialMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExamplePartialMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceExamplePartialMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExamplePartialMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExamplePartialMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExamplePartialMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleReqPartial() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExamplePartialMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExamplePartialMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExamplePartialMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewA() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceExamplePartialMethodResult) FastWrite(buf []byte) int { - return 0 -} +func (p *ExampleServiceExamplePartialMethodResult) BLength() int { + if p == nil { + return 1 + } + off := 0 -func (p *ExampleServiceExamplePartialMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplePartialMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExamplePartialMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExamplePartialMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceExamplePartialMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExamplePartialMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExamplePartialMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExamplePartialMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleSuperMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExamplePartialMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewA() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleSuperMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExamplePartialMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleSuperMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleSuper() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleSuperMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleSuperMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleSuperMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleSuperMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceExampleSuperMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleSuperMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleSuperMethod_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExampleSuperMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceExampleSuperMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleSuperMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleSuperMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleSuperMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleSuper() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleSuperMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleSuperMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleSuperMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewA() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleSuperMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleSuperMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceExampleSuperMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleSuperMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleSuperMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleSuperMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceExampleSuperMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleSuperMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleSuperMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleSuperMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFooArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleSuperMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewA() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleSuperMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFooArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewA() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFooArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceFooArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceFooArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFooArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceFooArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceFooArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFooResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFooArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewA() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFooResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFooArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFooResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewA() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFooResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceFooResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceFooResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceFooResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceFooResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceFooResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServicePingArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFooResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewA() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFooResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePingArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleServicePingArgs) FastWrite(buf []byte) int { - return 0 + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePingArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) +func (p *ExampleServicePingArgs) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServicePingArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServicePingArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) +func (p *ExampleServicePingArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *ExampleServicePingArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServicePingArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServicePingResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePingArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePingResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePingArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePingResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Success = &v - +func (p *ExampleServicePingResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServicePingResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServicePingResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRING + if p.Success != nil { + off += 3 + off += 4 + len(*p.Success) } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServicePingResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServicePingResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePingResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRING, 0) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Success) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServicePingResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServicePingResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRING, 0) - l += bthrift.Binary.StringLength(*p.Success) - - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRING + if p.Success != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Success) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceOnewayArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePingResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xb: // p.Success ID:0 thrift.STRING + if p.Success == nil { + p.Success = new(string) + } + *p.Success, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOnewayArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePingResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceOnewayArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceOnewayArgs) FastWrite(buf []byte) int { - return 0 + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceOnewayArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Oneway_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) +func (p *ExampleServiceOnewayArgs) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceOnewayArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Oneway_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServiceOnewayArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) +func (p *ExampleServiceOnewayArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceOnewayArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceOnewayArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceVoidArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceOnewayArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceVoidArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceOnewayArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceVoidArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -// for compatibility -func (p *ExampleServiceVoidArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceVoidArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) +func (p *ExampleServiceVoidArgs) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceVoidArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Void_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *ExampleServiceVoidArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) +func (p *ExampleServiceVoidArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceVoidArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 -func (p *ExampleServiceVoidArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.Msg) + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceVoidResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceVoidArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldTypeError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) - -SkipFieldTypeError: - return offset, thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -// for compatibility -func (p *ExampleServiceVoidResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceVoidResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Void_result") - if p != nil { - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceVoidArgs[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *ExampleServiceVoidResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Void_result") - if p != nil { + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleServiceExampleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceExamplePartialMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExamplePartialMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceExampleSuperMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleSuperMethodResult) GetResult() interface{} { - return p.Success + off := 0 + return off + 1 } -func (p *ExampleServiceFooArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceFooResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServicePingArgs) GetFirstArgument() interface{} { - return p.Msg -} - -func (p *ExampleServicePingResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceOnewayArgs) GetFirstArgument() interface{} { - return p.Msg -} - -func (p *ExampleServiceVoidArgs) GetFirstArgument() interface{} { - return p.Msg -} - -func (p *ExampleServiceVoidResult) GetResult() interface{} { - return nil -} +func (p *ExampleServiceVoidResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *InnerBase) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} -func (p *ExampleReq) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} -func (p *ExampleSuper) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() +func (p *ExampleServiceVoidResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return p.Base + off := 0 + + b[off] = 0 + return off + 1 } -func (p *ExampleResp) GetOrSetBaseResp() interface{} { - if p.BaseResp == nil { - p.BaseResp = base.NewBaseResp() +func (p *ExampleServiceVoidResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - return p.BaseResp + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/example3/example3.go b/testdata/kitex_gen/example3/example3.go index bd6b7baa..557711c1 100644 --- a/testdata/kitex_gen/example3/example3.go +++ b/testdata/kitex_gen/example3/example3.go @@ -1,17 +1,14 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package example3 import ( - "bytes" "context" "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/ref" - "strings" ) type FOO int64 @@ -37,7 +34,6 @@ func FOOFromString(s string) (FOO, error) { } func FOOPtr(v FOO) *FOO { return &v } - func (p *FOO) Scan(value interface{}) (err error) { var result sql.NullInt64 err = result.Scan(value) @@ -62,7 +58,7 @@ type InnerBase struct { String_ string `thrift:"String,7" json:"String"` ListInt32 []int32 `thrift:"ListInt32,8" json:"ListInt32"` MapStringString map[string]string `thrift:"MapStringString,9" json:"MapStringString"` - SetInt32_ []int32 `thrift:"SetInt32,10" json:"SetInt32"` + SetInt32 []int32 `thrift:"SetInt32,10" json:"SetInt32"` Foo FOO `thrift:"Foo,11" json:"Foo"` MapInt32String map[int32]string `thrift:"MapInt32String,12" json:"MapInt32String"` Binary []byte `thrift:"Binary,13" json:"Binary"` @@ -79,6 +75,9 @@ func NewInnerBase() *InnerBase { return &InnerBase{} } +func (p *InnerBase) InitDefault() { +} + func (p *InnerBase) GetBool() (v bool) { return p.Bool } @@ -116,7 +115,7 @@ func (p *InnerBase) GetMapStringString() (v map[string]string) { } func (p *InnerBase) GetSetInt32() (v []int32) { - return p.SetInt32_ + return p.SetInt32 } func (p *InnerBase) GetFoo() (v FOO) { @@ -163,65 +162,16 @@ func (p *InnerBase) GetBase() (v *base.Base) { } return p.Base } -func (p *InnerBase) SetBool(val bool) { - p.Bool = val -} -func (p *InnerBase) SetByte(val int8) { - p.Byte = val -} -func (p *InnerBase) SetInt16(val int16) { - p.Int16 = val -} -func (p *InnerBase) SetInt32(val int32) { - p.Int32 = val -} -func (p *InnerBase) SetInt64(val int64) { - p.Int64 = val -} -func (p *InnerBase) SetDouble(val float64) { - p.Double = val -} -func (p *InnerBase) SetString(val string) { - p.String_ = val -} -func (p *InnerBase) SetListInt32(val []int32) { - p.ListInt32 = val -} -func (p *InnerBase) SetMapStringString(val map[string]string) { - p.MapStringString = val -} -func (p *InnerBase) SetSetInt32(val []int32) { - p.SetInt32_ = val -} -func (p *InnerBase) SetFoo(val FOO) { - p.Foo = val -} -func (p *InnerBase) SetMapInt32String(val map[int32]string) { - p.MapInt32String = val -} -func (p *InnerBase) SetBinary(val []byte) { - p.Binary = val -} -func (p *InnerBase) SetMapInt8String(val map[int8]string) { - p.MapInt8String = val -} -func (p *InnerBase) SetMapInt16String(val map[int16]string) { - p.MapInt16String = val -} -func (p *InnerBase) SetMapInt64String(val map[int64]string) { - p.MapInt64String = val -} -func (p *InnerBase) SetListInnerBase(val []*InnerBase) { - p.ListInnerBase = val -} -func (p *InnerBase) SetMapStringInnerBase(val map[string]*InnerBase) { - p.MapStringInnerBase = val -} -func (p *InnerBase) SetInnerQuery(val string) { - p.InnerQuery = val + +func (p *InnerBase) IsSetBase() bool { + return p.Base != nil } -func (p *InnerBase) SetBase(val *base.Base) { - p.Base = val + +func (p *InnerBase) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("InnerBase(%+v)", *p) } var fieldIDToName_InnerBase = map[int16]string{ @@ -247,10442 +197,1300 @@ var fieldIDToName_InnerBase = map[int16]string{ 255: "Base", } -func (p *InnerBase) IsSetBase() bool { - return p.Base != nil +type ExampleReq struct { + Msg *string `thrift:"Msg,1,optional" json:"msg"` + Cookie *float64 `thrift:"Cookie,2,optional" json:"Cookie,omitempty"` + Path string `thrift:"Path,3,required" json:"Path"` + Query []string `thrift:"Query,4,optional" json:"Query,omitempty"` + Header *bool `thrift:"Header,5,optional" json:"Header,omitempty"` + Code int64 `thrift:"Code,6" json:"code_code"` + InnerBase *InnerBase `thrift:"InnerBase,7" json:"InnerBase"` + RawUri string `thrift:"RawUri,8" json:"RawUri"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` + Base *base.Base `thrift:"Base,255" json:"Base"` } -func (p *InnerBase) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 +func NewExampleReq() *ExampleReq { + return &ExampleReq{} +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *ExampleReq) InitDefault() { +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I16 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.I64 { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRING { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.LIST { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 9: - if fieldTypeId == thrift.MAP { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 10: - if fieldTypeId == thrift.SET { - if err = p.ReadField10(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 11: - if fieldTypeId == thrift.I32 { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 12: - if fieldTypeId == thrift.MAP { - if err = p.ReadField12(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 13: - if fieldTypeId == thrift.STRING { - if err = p.ReadField13(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 14: - if fieldTypeId == thrift.MAP { - if err = p.ReadField14(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 15: - if fieldTypeId == thrift.MAP { - if err = p.ReadField15(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 16: - if fieldTypeId == thrift.MAP { - if err = p.ReadField16(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 18: - if fieldTypeId == thrift.LIST { - if err = p.ReadField18(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 19: - if fieldTypeId == thrift.MAP { - if err = p.ReadField19(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 20: - if fieldTypeId == thrift.STRING { - if err = p.ReadField20(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var ExampleReq_Msg_DEFAULT string - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBase[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBase) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Bool = v +func (p *ExampleReq) GetMsg() (v string) { + if !p.IsSetMsg() { + return ExampleReq_Msg_DEFAULT } - return nil + return *p.Msg } -func (p *InnerBase) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil -} +var ExampleReq_Cookie_DEFAULT float64 -func (p *InnerBase) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - p.Int16 = v +func (p *ExampleReq) GetCookie() (v float64) { + if !p.IsSetCookie() { + return ExampleReq_Cookie_DEFAULT } - return nil + return *p.Cookie } -func (p *InnerBase) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Int32 = v - } - return nil +func (p *ExampleReq) GetPath() (v string) { + return p.Path } -func (p *InnerBase) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Int64 = v - } - return nil -} +var ExampleReq_Query_DEFAULT []string -func (p *InnerBase) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v +func (p *ExampleReq) GetQuery() (v []string) { + if !p.IsSetQuery() { + return ExampleReq_Query_DEFAULT } - return nil + return p.Query } -func (p *InnerBase) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} +var ExampleReq_Header_DEFAULT bool -func (p *InnerBase) ReadField8(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.ListInt32 = append(p.ListInt32, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err +func (p *ExampleReq) GetHeader() (v bool) { + if !p.IsSetHeader() { + return ExampleReq_Header_DEFAULT } - return nil + return *p.Header } -func (p *InnerBase) ReadField9(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) GetCode() (v int64) { + return p.Code } -func (p *InnerBase) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.SetInt32_ = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.SetInt32_ = append(p.SetInt32_, _elem) - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil -} +var ExampleReq_InnerBase_DEFAULT *InnerBase -func (p *InnerBase) ReadField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Foo = FOO(v) +func (p *ExampleReq) GetInnerBase() (v *InnerBase) { + if !p.IsSetInnerBase() { + return ExampleReq_InnerBase_DEFAULT } - return nil + return p.InnerBase } -func (p *InnerBase) ReadField12(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt32String = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt32String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) GetRawUri() (v string) { + return p.RawUri } -func (p *InnerBase) ReadField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil +func (p *ExampleReq) GetSubfix() (v float64) { + return p.Subfix } -func (p *InnerBase) ReadField14(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt8String = make(map[int8]string, size) - for i := 0; i < size; i++ { - var _key int8 - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt8String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} +var ExampleReq_Base_DEFAULT *base.Base -func (p *InnerBase) ReadField15(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt16String = make(map[int16]string, size) - for i := 0; i < size; i++ { - var _key int16 - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt16String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err +func (p *ExampleReq) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return ExampleReq_Base_DEFAULT } - return nil + return p.Base } -func (p *InnerBase) ReadField16(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInt64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapInt64String[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) IsSetMsg() bool { + return p.Msg != nil } -func (p *InnerBase) ReadField18(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListInnerBase = make([]*InnerBase, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBase() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) IsSetCookie() bool { + return p.Cookie != nil } -func (p *InnerBase) ReadField19(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringInnerBase = make(map[string]*InnerBase, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - _val := NewInnerBase() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapStringInnerBase[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil +func (p *ExampleReq) IsSetQuery() bool { + return p.Query != nil } -func (p *InnerBase) ReadField20(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.InnerQuery = v - } - return nil +func (p *ExampleReq) IsSetHeader() bool { + return p.Header != nil } -func (p *InnerBase) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil +func (p *ExampleReq) IsSetInnerBase() bool { + return p.InnerBase != nil } -func (p *InnerBase) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerBase"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - if err = p.writeField10(oprot); err != nil { - fieldId = 10 - goto WriteFieldError - } - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - if err = p.writeField12(oprot); err != nil { - fieldId = 12 - goto WriteFieldError - } - if err = p.writeField13(oprot); err != nil { - fieldId = 13 - goto WriteFieldError - } - if err = p.writeField14(oprot); err != nil { - fieldId = 14 - goto WriteFieldError - } - if err = p.writeField15(oprot); err != nil { - fieldId = 15 - goto WriteFieldError - } - if err = p.writeField16(oprot); err != nil { - fieldId = 16 - goto WriteFieldError - } - if err = p.writeField18(oprot); err != nil { - fieldId = 18 - goto WriteFieldError - } - if err = p.writeField19(oprot); err != nil { - fieldId = 19 - goto WriteFieldError - } - if err = p.writeField20(oprot); err != nil { - fieldId = 20 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerBase) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Bool", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Bool); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleReq) IsSetBase() bool { + return p.Base != nil } -func (p *InnerBase) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +func (p *ExampleReq) String() string { + if p == nil { + return "" } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) + return fmt.Sprintf("ExampleReq(%+v)", *p) } -func (p *InnerBase) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int16", thrift.I16, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI16(p.Int16); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +var fieldIDToName_ExampleReq = map[int16]string{ + 1: "Msg", + 2: "Cookie", + 3: "Path", + 4: "Query", + 5: "Header", + 6: "Code", + 7: "InnerBase", + 8: "RawUri", + 32767: "Subfix", + 255: "Base", } -func (p *InnerBase) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int32", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Int32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +type ExampleResp struct { + Msg string `thrift:"Msg,1" json:"Msg"` + Cookie *float64 `thrift:"Cookie,2,optional" json:"Cookie,omitempty"` + Status int32 `thrift:"Status,3,required" json:"Status"` + Header *bool `thrift:"Header,4,optional" json:"Header,omitempty"` + Code int64 `thrift:"Code,6" json:"code_code"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` + InnerBase *InnerBase `thrift:"InnerBase,7" json:"InnerBase"` + BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` } -func (p *InnerBase) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int64", thrift.I64, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Int64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +func NewExampleResp() *ExampleResp { + return &ExampleResp{} } -func (p *InnerBase) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +func (p *ExampleResp) InitDefault() { } -func (p *InnerBase) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 7); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +func (p *ExampleResp) GetMsg() (v string) { + return p.Msg } -func (p *InnerBase) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInt32", thrift.LIST, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I32, len(p.ListInt32)); err != nil { - return err - } - for _, v := range p.ListInt32 { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +var ExampleResp_Cookie_DEFAULT float64 + +func (p *ExampleResp) GetCookie() (v float64) { + if !p.IsSetCookie() { + return ExampleResp_Cookie_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) + return *p.Cookie } -func (p *InnerBase) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { - return err - } - for k, v := range p.MapStringString { +func (p *ExampleResp) GetStatus() (v int32) { + return p.Status +} - if err := oprot.WriteString(k); err != nil { - return err - } +var ExampleResp_Header_DEFAULT bool - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +func (p *ExampleResp) GetHeader() (v bool) { + if !p.IsSetHeader() { + return ExampleResp_Header_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) + return *p.Header } -func (p *InnerBase) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("SetInt32", thrift.SET, 10); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.SetInt32_)); err != nil { - return err - } - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - for _, v := range p.SetInt32_ { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) +func (p *ExampleResp) GetCode() (v int64) { + return p.Code } -func (p *InnerBase) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Foo", thrift.I32, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(int32(p.Foo)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) +func (p *ExampleResp) GetSubfix() (v float64) { + return p.Subfix } -func (p *InnerBase) writeField12(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt32String", thrift.MAP, 12); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.MapInt32String)); err != nil { - return err +var ExampleResp_InnerBase_DEFAULT *InnerBase + +func (p *ExampleResp) GetInnerBase() (v *InnerBase) { + if !p.IsSetInnerBase() { + return ExampleResp_InnerBase_DEFAULT } - for k, v := range p.MapInt32String { + return p.InnerBase +} - if err := oprot.WriteI32(k); err != nil { - return err - } +var ExampleResp_BaseResp_DEFAULT *base.BaseResp - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +func (p *ExampleResp) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return ExampleResp_BaseResp_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) + return p.BaseResp } -func (p *InnerBase) writeField13(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 13); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) +func (p *ExampleResp) IsSetCookie() bool { + return p.Cookie != nil } -func (p *InnerBase) writeField14(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt8String", thrift.MAP, 14); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.BYTE, thrift.STRING, len(p.MapInt8String)); err != nil { - return err - } - for k, v := range p.MapInt8String { +func (p *ExampleResp) IsSetHeader() bool { + return p.Header != nil +} - if err := oprot.WriteByte(k); err != nil { - return err - } +func (p *ExampleResp) IsSetInnerBase() bool { + return p.InnerBase != nil +} - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) +func (p *ExampleResp) IsSetBaseResp() bool { + return p.BaseResp != nil } -func (p *InnerBase) writeField15(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt16String", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError +func (p *ExampleResp) String() string { + if p == nil { + return "" } - if err := oprot.WriteMapBegin(thrift.I16, thrift.STRING, len(p.MapInt16String)); err != nil { - return err - } - for k, v := range p.MapInt16String { - - if err := oprot.WriteI16(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) + return fmt.Sprintf("ExampleResp(%+v)", *p) } -func (p *InnerBase) writeField16(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInt64String", thrift.MAP, 16); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, len(p.MapInt64String)); err != nil { - return err - } - for k, v := range p.MapInt64String { +var fieldIDToName_ExampleResp = map[int16]string{ + 1: "Msg", + 2: "Cookie", + 3: "Status", + 4: "Header", + 6: "Code", + 32767: "Subfix", + 7: "InnerBase", + 255: "BaseResp", +} - if err := oprot.WriteI64(k); err != nil { - return err - } +type ExampleError struct { + MapInnerBaseInnerBase map[*InnerBase]*InnerBase `thrift:"MapInnerBaseInnerBase,1" json:"MapInnerBaseInnerBase"` + Base64 []byte `thrift:"Base64,2" json:"Base64"` + Query string `thrift:"Query,3,required" json:"Query"` + Header string `thrift:"Header,4" json:"Header"` + Q2 int32 `thrift:"Q2,5" json:"Q2"` +} - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 16 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 16 end error: ", p), err) +func NewExampleError() *ExampleError { + return &ExampleError{} } -func (p *InnerBase) writeField18(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ListInnerBase", thrift.LIST, 18); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListInnerBase)); err != nil { - return err - } - for _, v := range p.ListInnerBase { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 18 end error: ", p), err) +func (p *ExampleError) InitDefault() { } -func (p *InnerBase) writeField19(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapStringInnerBase", thrift.MAP, 19); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringInnerBase)); err != nil { - return err - } - for k, v := range p.MapStringInnerBase { +func (p *ExampleError) GetMapInnerBaseInnerBase() (v map[*InnerBase]*InnerBase) { + return p.MapInnerBaseInnerBase +} - if err := oprot.WriteString(k); err != nil { - return err - } +func (p *ExampleError) GetBase64() (v []byte) { + return p.Base64 +} - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 19 end error: ", p), err) +func (p *ExampleError) GetQuery() (v string) { + return p.Query } -func (p *InnerBase) writeField20(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerQuery", thrift.STRING, 20); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.InnerQuery); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 20 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 20 end error: ", p), err) +func (p *ExampleError) GetHeader() (v string) { + return p.Header } -func (p *InnerBase) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +func (p *ExampleError) GetQ2() (v int32) { + return p.Q2 } -func (p *InnerBase) String() string { +func (p *ExampleError) String() string { if p == nil { return "" } - return fmt.Sprintf("InnerBase(%+v)", *p) + return fmt.Sprintf("ExampleError(%+v)", *p) } -func (p *InnerBase) DeepEqual(ano *InnerBase) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Bool) { - return false - } - if !p.Field2DeepEqual(ano.Byte) { - return false - } - if !p.Field3DeepEqual(ano.Int16) { - return false - } - if !p.Field4DeepEqual(ano.Int32) { - return false - } - if !p.Field5DeepEqual(ano.Int64) { - return false - } - if !p.Field6DeepEqual(ano.Double) { - return false - } - if !p.Field7DeepEqual(ano.String_) { - return false - } - if !p.Field8DeepEqual(ano.ListInt32) { - return false - } - if !p.Field9DeepEqual(ano.MapStringString) { - return false - } - if !p.Field10DeepEqual(ano.SetInt32_) { - return false - } - if !p.Field11DeepEqual(ano.Foo) { - return false - } - if !p.Field12DeepEqual(ano.MapInt32String) { - return false - } - if !p.Field13DeepEqual(ano.Binary) { - return false - } - if !p.Field14DeepEqual(ano.MapInt8String) { - return false - } - if !p.Field15DeepEqual(ano.MapInt16String) { - return false - } - if !p.Field16DeepEqual(ano.MapInt64String) { - return false - } - if !p.Field18DeepEqual(ano.ListInnerBase) { - return false - } - if !p.Field19DeepEqual(ano.MapStringInnerBase) { - return false - } - if !p.Field20DeepEqual(ano.InnerQuery) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true +var fieldIDToName_ExampleError = map[int16]string{ + 1: "MapInnerBaseInnerBase", + 2: "Base64", + 3: "Query", + 4: "Header", + 5: "Q2", } -func (p *InnerBase) Field1DeepEqual(src bool) bool { - - if p.Bool != src { - return false - } - return true +type ExampleErrorResp struct { + Int64 int64 `thrift:"Int64,2" json:"Int64"` + Xjson string `thrift:"Xjson,4" json:"Xjson"` } -func (p *InnerBase) Field2DeepEqual(src int8) bool { - if p.Byte != src { - return false - } - return true +func NewExampleErrorResp() *ExampleErrorResp { + return &ExampleErrorResp{} } -func (p *InnerBase) Field3DeepEqual(src int16) bool { - if p.Int16 != src { - return false - } - return true +func (p *ExampleErrorResp) InitDefault() { } -func (p *InnerBase) Field4DeepEqual(src int32) bool { - if p.Int32 != src { - return false - } - return true +func (p *ExampleErrorResp) GetInt64() (v int64) { + return p.Int64 } -func (p *InnerBase) Field5DeepEqual(src int64) bool { - if p.Int64 != src { - return false - } - return true +func (p *ExampleErrorResp) GetXjson() (v string) { + return p.Xjson } -func (p *InnerBase) Field6DeepEqual(src float64) bool { - if p.Double != src { - return false +func (p *ExampleErrorResp) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("ExampleErrorResp(%+v)", *p) } -func (p *InnerBase) Field7DeepEqual(src string) bool { - if strings.Compare(p.String_, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleErrorResp = map[int16]string{ + 2: "Int64", + 4: "Xjson", } -func (p *InnerBase) Field8DeepEqual(src []int32) bool { - if len(p.ListInt32) != len(src) { - return false - } - for i, v := range p.ListInt32 { - _src := src[i] - if v != _src { - return false - } - } - return true +type ExampleInt2Float struct { + Int32 int32 `thrift:"Int32,1" json:"Int32"` + Float64 float64 `thrift:"Float64,2" json:"Float64"` + String_ string `thrift:"String,3" json:"中文"` + Int64 int64 `thrift:"Int64,4" json:"Int64"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` } -func (p *InnerBase) Field9DeepEqual(src map[string]string) bool { - if len(p.MapStringString) != len(src) { - return false - } - for k, v := range p.MapStringString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +func NewExampleInt2Float() *ExampleInt2Float { + return &ExampleInt2Float{} } -func (p *InnerBase) Field10DeepEqual(src []int32) bool { - if len(p.SetInt32_) != len(src) { - return false - } - for i, v := range p.SetInt32_ { - _src := src[i] - if v != _src { - return false - } - } - return true +func (p *ExampleInt2Float) InitDefault() { } -func (p *InnerBase) Field11DeepEqual(src FOO) bool { - if p.Foo != src { - return false - } - return true +func (p *ExampleInt2Float) GetInt32() (v int32) { + return p.Int32 } -func (p *InnerBase) Field12DeepEqual(src map[int32]string) bool { - if len(p.MapInt32String) != len(src) { - return false - } - for k, v := range p.MapInt32String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +func (p *ExampleInt2Float) GetFloat64() (v float64) { + return p.Float64 } -func (p *InnerBase) Field13DeepEqual(src []byte) bool { - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true +func (p *ExampleInt2Float) GetString() (v string) { + return p.String_ } -func (p *InnerBase) Field14DeepEqual(src map[int8]string) bool { - if len(p.MapInt8String) != len(src) { - return false - } - for k, v := range p.MapInt8String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +func (p *ExampleInt2Float) GetInt64() (v int64) { + return p.Int64 } -func (p *InnerBase) Field15DeepEqual(src map[int16]string) bool { - if len(p.MapInt16String) != len(src) { - return false - } - for k, v := range p.MapInt16String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +func (p *ExampleInt2Float) GetSubfix() (v float64) { + return p.Subfix } -func (p *InnerBase) Field16DeepEqual(src map[int64]string) bool { - if len(p.MapInt64String) != len(src) { - return false - } - for k, v := range p.MapInt64String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } +func (p *ExampleInt2Float) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("ExampleInt2Float(%+v)", *p) } -func (p *InnerBase) Field18DeepEqual(src []*InnerBase) bool { - if len(p.ListInnerBase) != len(src) { - return false - } - for i, v := range p.ListInnerBase { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true +var fieldIDToName_ExampleInt2Float = map[int16]string{ + 1: "Int32", + 2: "Float64", + 3: "String", + 4: "Int64", + 32767: "Subfix", } -func (p *InnerBase) Field19DeepEqual(src map[string]*InnerBase) bool { - if len(p.MapStringInnerBase) != len(src) { - return false - } - for k, v := range p.MapStringInnerBase { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true +type JSONObject struct { + A string `thrift:"A,1" json:"a"` + B int8 `thrift:"B,2" json:"b"` } -func (p *InnerBase) Field20DeepEqual(src string) bool { - if strings.Compare(p.InnerQuery, src) != 0 { - return false - } - return true +func NewJSONObject() *JSONObject { + return &JSONObject{} } -func (p *InnerBase) Field255DeepEqual(src *base.Base) bool { - if !p.Base.DeepEqual(src) { - return false - } - return true +func (p *JSONObject) InitDefault() { } -type ExampleReq struct { - Msg *string `thrift:"Msg,1" json:"msg"` - Cookie *float64 `thrift:"Cookie,2" json:"Cookie,omitempty"` - Path string `thrift:"Path,3,required" json:"Path"` - Query []string `thrift:"Query,4" json:"Query,omitempty"` - Header *bool `thrift:"Header,5" json:"Header,omitempty"` - Code int64 `thrift:"Code,6" json:"code_code"` - InnerBase *InnerBase `thrift:"InnerBase,7" json:"InnerBase"` - RawUri string `thrift:"RawUri,8" json:"RawUri"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` - Base *base.Base `thrift:"Base,255" json:"Base"` +func (p *JSONObject) GetA() (v string) { + return p.A } -func NewExampleReq() *ExampleReq { - return &ExampleReq{} +func (p *JSONObject) GetB() (v int8) { + return p.B } -var ExampleReq_Msg_DEFAULT string - -func (p *ExampleReq) GetMsg() (v string) { - if !p.IsSetMsg() { - return ExampleReq_Msg_DEFAULT +func (p *JSONObject) String() string { + if p == nil { + return "" } - return *p.Msg + return fmt.Sprintf("JSONObject(%+v)", *p) } -var ExampleReq_Cookie_DEFAULT float64 +var fieldIDToName_JSONObject = map[int16]string{ + 1: "A", + 2: "B", +} -func (p *ExampleReq) GetCookie() (v float64) { - if !p.IsSetCookie() { - return ExampleReq_Cookie_DEFAULT - } - return *p.Cookie +type ExampleJSONString struct { + Query *JSONObject `thrift:"Query,1" json:"Query"` + Query2 []string `thrift:"Query2,2,required" json:"Query2"` + Header *JSONObject `thrift:"Header,3,required" json:"Header"` + Header2 map[int32]string `thrift:"Header2,4,required" json:"Header2"` + Cookie *JSONObject `thrift:"Cookie,5" json:"Cookie"` + Cookie2 []int32 `thrift:"Cookie2,6,required" json:"Cookie2"` } -func (p *ExampleReq) GetPath() (v string) { - return p.Path +func NewExampleJSONString() *ExampleJSONString { + return &ExampleJSONString{} } -var ExampleReq_Query_DEFAULT []string +func (p *ExampleJSONString) InitDefault() { +} -func (p *ExampleReq) GetQuery() (v []string) { +var ExampleJSONString_Query_DEFAULT *JSONObject + +func (p *ExampleJSONString) GetQuery() (v *JSONObject) { if !p.IsSetQuery() { - return ExampleReq_Query_DEFAULT + return ExampleJSONString_Query_DEFAULT } return p.Query } -var ExampleReq_Header_DEFAULT bool +func (p *ExampleJSONString) GetQuery2() (v []string) { + return p.Query2 +} -func (p *ExampleReq) GetHeader() (v bool) { +var ExampleJSONString_Header_DEFAULT *JSONObject + +func (p *ExampleJSONString) GetHeader() (v *JSONObject) { if !p.IsSetHeader() { - return ExampleReq_Header_DEFAULT + return ExampleJSONString_Header_DEFAULT } - return *p.Header + return p.Header } -func (p *ExampleReq) GetCode() (v int64) { - return p.Code +func (p *ExampleJSONString) GetHeader2() (v map[int32]string) { + return p.Header2 } -var ExampleReq_InnerBase_DEFAULT *InnerBase +var ExampleJSONString_Cookie_DEFAULT *JSONObject -func (p *ExampleReq) GetInnerBase() (v *InnerBase) { - if !p.IsSetInnerBase() { - return ExampleReq_InnerBase_DEFAULT +func (p *ExampleJSONString) GetCookie() (v *JSONObject) { + if !p.IsSetCookie() { + return ExampleJSONString_Cookie_DEFAULT } - return p.InnerBase + return p.Cookie } -func (p *ExampleReq) GetRawUri() (v string) { - return p.RawUri +func (p *ExampleJSONString) GetCookie2() (v []int32) { + return p.Cookie2 } -func (p *ExampleReq) GetSubfix() (v float64) { - return p.Subfix +func (p *ExampleJSONString) IsSetQuery() bool { + return p.Query != nil } -var ExampleReq_Base_DEFAULT *base.Base - -func (p *ExampleReq) GetBase() (v *base.Base) { - if !p.IsSetBase() { - return ExampleReq_Base_DEFAULT - } - return p.Base -} -func (p *ExampleReq) SetMsg(val *string) { - p.Msg = val -} -func (p *ExampleReq) SetCookie(val *float64) { - p.Cookie = val -} -func (p *ExampleReq) SetPath(val string) { - p.Path = val -} -func (p *ExampleReq) SetQuery(val []string) { - p.Query = val -} -func (p *ExampleReq) SetHeader(val *bool) { - p.Header = val -} -func (p *ExampleReq) SetCode(val int64) { - p.Code = val -} -func (p *ExampleReq) SetInnerBase(val *InnerBase) { - p.InnerBase = val -} -func (p *ExampleReq) SetRawUri(val string) { - p.RawUri = val -} -func (p *ExampleReq) SetSubfix(val float64) { - p.Subfix = val -} -func (p *ExampleReq) SetBase(val *base.Base) { - p.Base = val -} - -var fieldIDToName_ExampleReq = map[int16]string{ - 1: "Msg", - 2: "Cookie", - 3: "Path", - 4: "Query", - 5: "Header", - 6: "Code", - 7: "InnerBase", - 8: "RawUri", - 32767: "Subfix", - 255: "Base", -} - -func (p *ExampleReq) IsSetMsg() bool { - return p.Msg != nil -} - -func (p *ExampleReq) IsSetCookie() bool { - return p.Cookie != nil -} - -func (p *ExampleReq) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ExampleReq) IsSetHeader() bool { +func (p *ExampleJSONString) IsSetHeader() bool { return p.Header != nil } -func (p *ExampleReq) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExampleReq) IsSetBase() bool { - return p.Base != nil -} - -func (p *ExampleReq) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetPath bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetPath = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.LIST { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRING { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetPath { - fieldId = 3 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = &v - } - return nil -} - -func (p *ExampleReq) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Cookie = &v - } - return nil -} - -func (p *ExampleReq) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Path = v - } - return nil -} - -func (p *ExampleReq) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.Query = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.Query = append(p.Query, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Header = &v - } - return nil -} - -func (p *ExampleReq) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Code = v - } - return nil -} - -func (p *ExampleReq) ReadField7(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBase() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.RawUri = v - } - return nil -} - -func (p *ExampleReq) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleReq) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleReq) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleReq"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleReq) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMsg() { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleReq) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetCookie() { - if err = oprot.WriteFieldBegin("Cookie", thrift.DOUBLE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(*p.Cookie); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleReq) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Path", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Path); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleReq) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetQuery() { - if err = oprot.WriteFieldBegin("Query", thrift.LIST, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Query)); err != nil { - return err - } - for _, v := range p.Query { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleReq) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetHeader() { - if err = oprot.WriteFieldBegin("Header", thrift.BOOL, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(*p.Header); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleReq) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Code", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExampleReq) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 7); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *ExampleReq) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("RawUri", thrift.STRING, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.RawUri); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} - -func (p *ExampleReq) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExampleReq) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +func (p *ExampleJSONString) IsSetCookie() bool { + return p.Cookie != nil } -func (p *ExampleReq) String() string { +func (p *ExampleJSONString) String() string { if p == nil { return "" } - return fmt.Sprintf("ExampleReq(%+v)", *p) -} - -func (p *ExampleReq) DeepEqual(ano *ExampleReq) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.Cookie) { - return false - } - if !p.Field3DeepEqual(ano.Path) { - return false - } - if !p.Field4DeepEqual(ano.Query) { - return false - } - if !p.Field5DeepEqual(ano.Header) { - return false - } - if !p.Field6DeepEqual(ano.Code) { - return false - } - if !p.Field7DeepEqual(ano.InnerBase) { - return false - } - if !p.Field8DeepEqual(ano.RawUri) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true -} - -func (p *ExampleReq) Field1DeepEqual(src *string) bool { - - if p.Msg == src { - return true - } else if p.Msg == nil || src == nil { - return false - } - if strings.Compare(*p.Msg, *src) != 0 { - return false - } - return true -} -func (p *ExampleReq) Field2DeepEqual(src *float64) bool { - - if p.Cookie == src { - return true - } else if p.Cookie == nil || src == nil { - return false - } - if *p.Cookie != *src { - return false - } - return true + return fmt.Sprintf("ExampleJSONString(%+v)", *p) } -func (p *ExampleReq) Field3DeepEqual(src string) bool { - if strings.Compare(p.Path, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleJSONString = map[int16]string{ + 1: "Query", + 2: "Query2", + 3: "Header", + 4: "Header2", + 5: "Cookie", + 6: "Cookie2", } -func (p *ExampleReq) Field4DeepEqual(src []string) bool { - if len(p.Query) != len(src) { - return false - } - for i, v := range p.Query { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true +type ExamplePartial struct { + Msg string `thrift:"Msg,1" json:"msg"` } -func (p *ExampleReq) Field5DeepEqual(src *bool) bool { - if p.Header == src { - return true - } else if p.Header == nil || src == nil { - return false - } - if *p.Header != *src { - return false - } - return true +func NewExamplePartial() *ExamplePartial { + return &ExamplePartial{} } -func (p *ExampleReq) Field6DeepEqual(src int64) bool { - if p.Code != src { - return false - } - return true +func (p *ExamplePartial) InitDefault() { } -func (p *ExampleReq) Field7DeepEqual(src *InnerBase) bool { - if !p.InnerBase.DeepEqual(src) { - return false - } - return true +func (p *ExamplePartial) GetMsg() (v string) { + return p.Msg } -func (p *ExampleReq) Field8DeepEqual(src string) bool { - if strings.Compare(p.RawUri, src) != 0 { - return false +func (p *ExamplePartial) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("ExamplePartial(%+v)", *p) } -func (p *ExampleReq) Field32767DeepEqual(src float64) bool { - if p.Subfix != src { - return false - } - return true +var fieldIDToName_ExamplePartial = map[int16]string{ + 1: "Msg", } -func (p *ExampleReq) Field255DeepEqual(src *base.Base) bool { - if !p.Base.DeepEqual(src) { - return false - } - return true +type ExamplePartial2 struct { + Msg string `thrift:"Msg,1" json:"msg"` + Cookie *float64 `thrift:"Cookie,2,optional" json:"Cookie,omitempty"` + Status int32 `thrift:"Status,3,required" json:"Status"` + Header *bool `thrift:"Header,4,optional" json:"Header,omitempty"` + Code int64 `thrift:"Code,6" json:"code_code"` + Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` + InnerBase *InnerBasePartial `thrift:"InnerBase,7" json:"InnerBase"` + BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` } -type ExampleResp struct { - Msg string `thrift:"Msg,1" json:"Msg"` - Cookie *float64 `thrift:"Cookie,2" json:"Cookie,omitempty"` - Status int32 `thrift:"Status,3,required" json:"Status"` - Header *bool `thrift:"Header,4" json:"Header,omitempty"` - Code int64 `thrift:"Code,6" json:"code_code"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` - InnerBase *InnerBase `thrift:"InnerBase,7" json:"InnerBase"` - BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` +func NewExamplePartial2() *ExamplePartial2 { + return &ExamplePartial2{} } -func NewExampleResp() *ExampleResp { - return &ExampleResp{} +func (p *ExamplePartial2) InitDefault() { } -func (p *ExampleResp) GetMsg() (v string) { +func (p *ExamplePartial2) GetMsg() (v string) { return p.Msg } -var ExampleResp_Cookie_DEFAULT float64 +var ExamplePartial2_Cookie_DEFAULT float64 -func (p *ExampleResp) GetCookie() (v float64) { +func (p *ExamplePartial2) GetCookie() (v float64) { if !p.IsSetCookie() { - return ExampleResp_Cookie_DEFAULT + return ExamplePartial2_Cookie_DEFAULT } return *p.Cookie } -func (p *ExampleResp) GetStatus() (v int32) { +func (p *ExamplePartial2) GetStatus() (v int32) { return p.Status } -var ExampleResp_Header_DEFAULT bool +var ExamplePartial2_Header_DEFAULT bool -func (p *ExampleResp) GetHeader() (v bool) { +func (p *ExamplePartial2) GetHeader() (v bool) { if !p.IsSetHeader() { - return ExampleResp_Header_DEFAULT + return ExamplePartial2_Header_DEFAULT } return *p.Header } -func (p *ExampleResp) GetCode() (v int64) { +func (p *ExamplePartial2) GetCode() (v int64) { return p.Code } -func (p *ExampleResp) GetSubfix() (v float64) { +func (p *ExamplePartial2) GetSubfix() (v float64) { return p.Subfix } -var ExampleResp_InnerBase_DEFAULT *InnerBase +var ExamplePartial2_InnerBase_DEFAULT *InnerBasePartial -func (p *ExampleResp) GetInnerBase() (v *InnerBase) { +func (p *ExamplePartial2) GetInnerBase() (v *InnerBasePartial) { if !p.IsSetInnerBase() { - return ExampleResp_InnerBase_DEFAULT + return ExamplePartial2_InnerBase_DEFAULT } return p.InnerBase } -var ExampleResp_BaseResp_DEFAULT *base.BaseResp +var ExamplePartial2_BaseResp_DEFAULT *base.BaseResp -func (p *ExampleResp) GetBaseResp() (v *base.BaseResp) { +func (p *ExamplePartial2) GetBaseResp() (v *base.BaseResp) { if !p.IsSetBaseResp() { - return ExampleResp_BaseResp_DEFAULT + return ExamplePartial2_BaseResp_DEFAULT } return p.BaseResp } -func (p *ExampleResp) SetMsg(val string) { - p.Msg = val -} -func (p *ExampleResp) SetCookie(val *float64) { - p.Cookie = val -} -func (p *ExampleResp) SetStatus(val int32) { - p.Status = val -} -func (p *ExampleResp) SetHeader(val *bool) { - p.Header = val -} -func (p *ExampleResp) SetCode(val int64) { - p.Code = val + +func (p *ExamplePartial2) IsSetCookie() bool { + return p.Cookie != nil } -func (p *ExampleResp) SetSubfix(val float64) { - p.Subfix = val + +func (p *ExamplePartial2) IsSetHeader() bool { + return p.Header != nil } -func (p *ExampleResp) SetInnerBase(val *InnerBase) { - p.InnerBase = val + +func (p *ExamplePartial2) IsSetInnerBase() bool { + return p.InnerBase != nil } -func (p *ExampleResp) SetBaseResp(val *base.BaseResp) { - p.BaseResp = val + +func (p *ExamplePartial2) IsSetBaseResp() bool { + return p.BaseResp != nil } -var fieldIDToName_ExampleResp = map[int16]string{ - 1: "Msg", - 2: "Cookie", - 3: "Status", - 4: "Header", - 6: "Code", - 32767: "Subfix", - 7: "InnerBase", - 255: "BaseResp", -} - -func (p *ExampleResp) IsSetCookie() bool { - return p.Cookie != nil -} - -func (p *ExampleResp) IsSetHeader() bool { - return p.Header != nil -} - -func (p *ExampleResp) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExampleResp) IsSetBaseResp() bool { - return p.BaseResp != nil -} - -func (p *ExampleResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetStatus bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetStatus = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetStatus { - fieldId = 3 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil -} - -func (p *ExampleResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Cookie = &v - } - return nil -} - -func (p *ExampleResp) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Status = v - } - return nil -} - -func (p *ExampleResp) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Header = &v - } - return nil -} - -func (p *ExampleResp) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Code = v - } - return nil -} - -func (p *ExampleResp) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleResp) ReadField7(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBase() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleResp) ReadField255(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleResp) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleResp) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetCookie() { - if err = oprot.WriteFieldBegin("Cookie", thrift.DOUBLE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(*p.Cookie); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleResp) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Status", thrift.I32, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Status); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleResp) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetHeader() { - if err = oprot.WriteFieldBegin("Header", thrift.BOOL, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(*p.Header); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleResp) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Code", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExampleResp) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExampleResp) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 7); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *ExampleResp) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.BaseResp.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExampleResp) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleResp(%+v)", *p) -} - -func (p *ExampleResp) DeepEqual(ano *ExampleResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.Cookie) { - return false - } - if !p.Field3DeepEqual(ano.Status) { - return false - } - if !p.Field4DeepEqual(ano.Header) { - return false - } - if !p.Field6DeepEqual(ano.Code) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - if !p.Field7DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.BaseResp) { - return false - } - return true -} - -func (p *ExampleResp) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true -} -func (p *ExampleResp) Field2DeepEqual(src *float64) bool { - - if p.Cookie == src { - return true - } else if p.Cookie == nil || src == nil { - return false - } - if *p.Cookie != *src { - return false - } - return true -} -func (p *ExampleResp) Field3DeepEqual(src int32) bool { - - if p.Status != src { - return false - } - return true -} -func (p *ExampleResp) Field4DeepEqual(src *bool) bool { - - if p.Header == src { - return true - } else if p.Header == nil || src == nil { - return false - } - if *p.Header != *src { - return false - } - return true -} -func (p *ExampleResp) Field6DeepEqual(src int64) bool { - - if p.Code != src { - return false - } - return true -} -func (p *ExampleResp) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true -} -func (p *ExampleResp) Field7DeepEqual(src *InnerBase) bool { - - if !p.InnerBase.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleResp) Field255DeepEqual(src *base.BaseResp) bool { - - if !p.BaseResp.DeepEqual(src) { - return false - } - return true -} - -type ExampleError struct { - MapInnerBaseInnerBase map[*InnerBase]*InnerBase `thrift:"MapInnerBaseInnerBase,1" json:"MapInnerBaseInnerBase"` - Base64 []byte `thrift:"Base64,2" json:"Base64"` - Query string `thrift:"Query,3,required" json:"Query"` - Header string `thrift:"Header,4" json:"Header"` - Q2 int32 `thrift:"Q2,5" json:"Q2"` -} - -func NewExampleError() *ExampleError { - return &ExampleError{} -} - -func (p *ExampleError) GetMapInnerBaseInnerBase() (v map[*InnerBase]*InnerBase) { - return p.MapInnerBaseInnerBase -} - -func (p *ExampleError) GetBase64() (v []byte) { - return p.Base64 -} - -func (p *ExampleError) GetQuery() (v string) { - return p.Query -} - -func (p *ExampleError) GetHeader() (v string) { - return p.Header -} - -func (p *ExampleError) GetQ2() (v int32) { - return p.Q2 -} -func (p *ExampleError) SetMapInnerBaseInnerBase(val map[*InnerBase]*InnerBase) { - p.MapInnerBaseInnerBase = val -} -func (p *ExampleError) SetBase64(val []byte) { - p.Base64 = val -} -func (p *ExampleError) SetQuery(val string) { - p.Query = val -} -func (p *ExampleError) SetHeader(val string) { - p.Header = val -} -func (p *ExampleError) SetQ2(val int32) { - p.Q2 = val -} - -var fieldIDToName_ExampleError = map[int16]string{ - 1: "MapInnerBaseInnerBase", - 2: "Base64", - 3: "Query", - 4: "Header", - 5: "Q2", -} - -func (p *ExampleError) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetQuery = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.I32 { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetQuery { - fieldId = 3 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleError[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleError[fieldId])) -} - -func (p *ExampleError) ReadField1(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, size) - for i := 0; i < size; i++ { - _key := NewInnerBase() - if err := _key.Read(iprot); err != nil { - return err - } - _val := NewInnerBase() - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleError) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Base64 = []byte(v) - } - return nil -} - -func (p *ExampleError) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Query = v - } - return nil -} - -func (p *ExampleError) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Header = v - } - return nil -} - -func (p *ExampleError) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Q2 = v - } - return nil -} - -func (p *ExampleError) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleError"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleError) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MapInnerBaseInnerBase", thrift.MAP, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)); err != nil { - return err - } - for k, v := range p.MapInnerBaseInnerBase { - - if err := k.Write(oprot); err != nil { - return err - } - - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleError) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base64", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Base64)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleError) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Query", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Query); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleError) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Header", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Header); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleError) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Q2", thrift.I32, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Q2); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleError) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleError(%+v)", *p) -} - -func (p *ExampleError) DeepEqual(ano *ExampleError) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.MapInnerBaseInnerBase) { - return false - } - if !p.Field2DeepEqual(ano.Base64) { - return false - } - if !p.Field3DeepEqual(ano.Query) { - return false - } - if !p.Field4DeepEqual(ano.Header) { - return false - } - if !p.Field5DeepEqual(ano.Q2) { - return false - } - return true -} - -func (p *ExampleError) Field1DeepEqual(src map[*InnerBase]*InnerBase) bool { - - if len(p.MapInnerBaseInnerBase) != len(src) { - return false - } - for k, v := range p.MapInnerBaseInnerBase { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *ExampleError) Field2DeepEqual(src []byte) bool { - - if bytes.Compare(p.Base64, src) != 0 { - return false - } - return true -} -func (p *ExampleError) Field3DeepEqual(src string) bool { - - if strings.Compare(p.Query, src) != 0 { - return false - } - return true -} -func (p *ExampleError) Field4DeepEqual(src string) bool { - - if strings.Compare(p.Header, src) != 0 { - return false - } - return true -} -func (p *ExampleError) Field5DeepEqual(src int32) bool { - - if p.Q2 != src { - return false - } - return true -} - -type ExampleErrorResp struct { - Int64 int64 `thrift:"Int64,2" json:"Int64"` - Xjson string `thrift:"Xjson,4" json:"Xjson"` -} - -func NewExampleErrorResp() *ExampleErrorResp { - return &ExampleErrorResp{} -} - -func (p *ExampleErrorResp) GetInt64() (v int64) { - return p.Int64 -} - -func (p *ExampleErrorResp) GetXjson() (v string) { - return p.Xjson -} -func (p *ExampleErrorResp) SetInt64(val int64) { - p.Int64 = val -} -func (p *ExampleErrorResp) SetXjson(val string) { - p.Xjson = val -} - -var fieldIDToName_ExampleErrorResp = map[int16]string{ - 2: "Int64", - 4: "Xjson", -} - -func (p *ExampleErrorResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 2: - if fieldTypeId == thrift.I64 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleErrorResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleErrorResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Int64 = v - } - return nil -} - -func (p *ExampleErrorResp) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Xjson = v - } - return nil -} - -func (p *ExampleErrorResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleErrorResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleErrorResp) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int64", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Int64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleErrorResp) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Xjson", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Xjson); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleErrorResp) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleErrorResp(%+v)", *p) -} - -func (p *ExampleErrorResp) DeepEqual(ano *ExampleErrorResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field2DeepEqual(ano.Int64) { - return false - } - if !p.Field4DeepEqual(ano.Xjson) { - return false - } - return true -} - -func (p *ExampleErrorResp) Field2DeepEqual(src int64) bool { - - if p.Int64 != src { - return false - } - return true -} -func (p *ExampleErrorResp) Field4DeepEqual(src string) bool { - - if strings.Compare(p.Xjson, src) != 0 { - return false - } - return true -} - -type ExampleInt2Float struct { - Int32 int32 `thrift:"Int32,1" json:"Int32"` - Float64 float64 `thrift:"Float64,2" json:"Float64"` - String_ string `thrift:"String,3" json:"中文"` - Int64 int64 `thrift:"Int64,4" json:"Int64"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` -} - -func NewExampleInt2Float() *ExampleInt2Float { - return &ExampleInt2Float{} -} - -func (p *ExampleInt2Float) GetInt32() (v int32) { - return p.Int32 -} - -func (p *ExampleInt2Float) GetFloat64() (v float64) { - return p.Float64 -} - -func (p *ExampleInt2Float) GetString() (v string) { - return p.String_ -} - -func (p *ExampleInt2Float) GetInt64() (v int64) { - return p.Int64 -} - -func (p *ExampleInt2Float) GetSubfix() (v float64) { - return p.Subfix -} -func (p *ExampleInt2Float) SetInt32(val int32) { - p.Int32 = val -} -func (p *ExampleInt2Float) SetFloat64(val float64) { - p.Float64 = val -} -func (p *ExampleInt2Float) SetString(val string) { - p.String_ = val -} -func (p *ExampleInt2Float) SetInt64(val int64) { - p.Int64 = val -} -func (p *ExampleInt2Float) SetSubfix(val float64) { - p.Subfix = val -} - -var fieldIDToName_ExampleInt2Float = map[int16]string{ - 1: "Int32", - 2: "Float64", - 3: "String", - 4: "Int64", - 32767: "Subfix", -} - -func (p *ExampleInt2Float) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I64 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleInt2Float[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleInt2Float) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Int32 = v - } - return nil -} - -func (p *ExampleInt2Float) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Float64 = v - } - return nil -} - -func (p *ExampleInt2Float) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} - -func (p *ExampleInt2Float) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Int64 = v - } - return nil -} - -func (p *ExampleInt2Float) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExampleInt2Float) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleInt2Float"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleInt2Float) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int32", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Int32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleInt2Float) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Float64", thrift.DOUBLE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Float64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleInt2Float) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleInt2Float) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Int64", thrift.I64, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Int64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleInt2Float) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExampleInt2Float) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleInt2Float(%+v)", *p) -} - -func (p *ExampleInt2Float) DeepEqual(ano *ExampleInt2Float) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Int32) { - return false - } - if !p.Field2DeepEqual(ano.Float64) { - return false - } - if !p.Field3DeepEqual(ano.String_) { - return false - } - if !p.Field4DeepEqual(ano.Int64) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - return true -} - -func (p *ExampleInt2Float) Field1DeepEqual(src int32) bool { - - if p.Int32 != src { - return false - } - return true -} -func (p *ExampleInt2Float) Field2DeepEqual(src float64) bool { - - if p.Float64 != src { - return false - } - return true -} -func (p *ExampleInt2Float) Field3DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *ExampleInt2Float) Field4DeepEqual(src int64) bool { - - if p.Int64 != src { - return false - } - return true -} -func (p *ExampleInt2Float) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true -} - -type JSONObject struct { - A string `thrift:"A,1" json:"a"` - B int8 `thrift:"B,2" json:"b"` -} - -func NewJSONObject() *JSONObject { - return &JSONObject{} -} - -func (p *JSONObject) GetA() (v string) { - return p.A -} - -func (p *JSONObject) GetB() (v int8) { - return p.B -} -func (p *JSONObject) SetA(val string) { - p.A = val -} -func (p *JSONObject) SetB(val int8) { - p.B = val -} - -var fieldIDToName_JSONObject = map[int16]string{ - 1: "A", - 2: "B", -} - -func (p *JSONObject) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.BYTE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_JSONObject[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *JSONObject) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.A = v - } - return nil -} - -func (p *JSONObject) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.B = v - } - return nil -} - -func (p *JSONObject) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("JSONObject"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *JSONObject) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("A", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *JSONObject) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("B", thrift.BYTE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *JSONObject) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JSONObject(%+v)", *p) -} - -func (p *JSONObject) DeepEqual(ano *JSONObject) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - return true -} - -func (p *JSONObject) Field1DeepEqual(src string) bool { - - if strings.Compare(p.A, src) != 0 { - return false - } - return true -} -func (p *JSONObject) Field2DeepEqual(src int8) bool { - - if p.B != src { - return false - } - return true -} - -type ExampleJSONString struct { - Query *JSONObject `thrift:"Query,1" json:"Query"` - Query2 []string `thrift:"Query2,2,required" json:"Query2"` - Header *JSONObject `thrift:"Header,3,required" json:"Header"` - Header2 map[int32]string `thrift:"Header2,4,required" json:"Header2"` - Cookie *JSONObject `thrift:"Cookie,5" json:"Cookie"` - Cookie2 []int32 `thrift:"Cookie2,6,required" json:"Cookie2"` -} - -func NewExampleJSONString() *ExampleJSONString { - return &ExampleJSONString{} -} - -var ExampleJSONString_Query_DEFAULT *JSONObject - -func (p *ExampleJSONString) GetQuery() (v *JSONObject) { - if !p.IsSetQuery() { - return ExampleJSONString_Query_DEFAULT - } - return p.Query -} - -func (p *ExampleJSONString) GetQuery2() (v []string) { - return p.Query2 -} - -var ExampleJSONString_Header_DEFAULT *JSONObject - -func (p *ExampleJSONString) GetHeader() (v *JSONObject) { - if !p.IsSetHeader() { - return ExampleJSONString_Header_DEFAULT - } - return p.Header -} - -func (p *ExampleJSONString) GetHeader2() (v map[int32]string) { - return p.Header2 -} - -var ExampleJSONString_Cookie_DEFAULT *JSONObject - -func (p *ExampleJSONString) GetCookie() (v *JSONObject) { - if !p.IsSetCookie() { - return ExampleJSONString_Cookie_DEFAULT - } - return p.Cookie -} - -func (p *ExampleJSONString) GetCookie2() (v []int32) { - return p.Cookie2 -} -func (p *ExampleJSONString) SetQuery(val *JSONObject) { - p.Query = val -} -func (p *ExampleJSONString) SetQuery2(val []string) { - p.Query2 = val -} -func (p *ExampleJSONString) SetHeader(val *JSONObject) { - p.Header = val -} -func (p *ExampleJSONString) SetHeader2(val map[int32]string) { - p.Header2 = val -} -func (p *ExampleJSONString) SetCookie(val *JSONObject) { - p.Cookie = val -} -func (p *ExampleJSONString) SetCookie2(val []int32) { - p.Cookie2 = val -} - -var fieldIDToName_ExampleJSONString = map[int16]string{ - 1: "Query", - 2: "Query2", - 3: "Header", - 4: "Header2", - 5: "Cookie", - 6: "Cookie2", -} - -func (p *ExampleJSONString) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ExampleJSONString) IsSetHeader() bool { - return p.Header != nil -} - -func (p *ExampleJSONString) IsSetCookie() bool { - return p.Cookie != nil -} - -func (p *ExampleJSONString) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery2 bool = false - var issetHeader bool = false - var issetHeader2 bool = false - var issetCookie2 bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.LIST { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - issetQuery2 = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetHeader = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.MAP { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - issetHeader2 = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.SET { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - issetCookie2 = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetQuery2 { - fieldId = 2 - goto RequiredFieldNotSetError - } - - if !issetHeader { - fieldId = 3 - goto RequiredFieldNotSetError - } - - if !issetHeader2 { - fieldId = 4 - goto RequiredFieldNotSetError - } - - if !issetCookie2 { - fieldId = 6 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleJSONString[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleJSONString[fieldId])) -} - -func (p *ExampleJSONString) ReadField1(iprot thrift.TProtocol) error { - p.Query = NewJSONObject() - if err := p.Query.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.Query2 = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.Query2 = append(p.Query2, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) ReadField3(iprot thrift.TProtocol) error { - p.Header = NewJSONObject() - if err := p.Header.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) ReadField4(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Header2 = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Header2[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) ReadField5(iprot thrift.TProtocol) error { - p.Cookie = NewJSONObject() - if err := p.Cookie.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) ReadField6(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.Cookie2 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.Cookie2 = append(p.Cookie2, _elem) - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil -} - -func (p *ExampleJSONString) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleJSONString"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleJSONString) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Query", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Query.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleJSONString) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Query2", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Query2)); err != nil { - return err - } - for _, v := range p.Query2 { - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleJSONString) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Header", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.Header.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleJSONString) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Header2", thrift.MAP, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.Header2)); err != nil { - return err - } - for k, v := range p.Header2 { - - if err := oprot.WriteI32(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleJSONString) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Cookie", thrift.STRUCT, 5); err != nil { - goto WriteFieldBeginError - } - if err := p.Cookie.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleJSONString) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Cookie2", thrift.SET, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.Cookie2)); err != nil { - return err - } - for i := 0; i < len(p.Cookie2); i++ { - for j := i + 1; j < len(p.Cookie2); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.Cookie2[i], p.Cookie2[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.Cookie2[i])) - } - } - } - for _, v := range p.Cookie2 { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExampleJSONString) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleJSONString(%+v)", *p) -} - -func (p *ExampleJSONString) DeepEqual(ano *ExampleJSONString) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Query) { - return false - } - if !p.Field2DeepEqual(ano.Query2) { - return false - } - if !p.Field3DeepEqual(ano.Header) { - return false - } - if !p.Field4DeepEqual(ano.Header2) { - return false - } - if !p.Field5DeepEqual(ano.Cookie) { - return false - } - if !p.Field6DeepEqual(ano.Cookie2) { - return false - } - return true -} - -func (p *ExampleJSONString) Field1DeepEqual(src *JSONObject) bool { - - if !p.Query.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleJSONString) Field2DeepEqual(src []string) bool { - - if len(p.Query2) != len(src) { - return false - } - for i, v := range p.Query2 { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleJSONString) Field3DeepEqual(src *JSONObject) bool { - - if !p.Header.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleJSONString) Field4DeepEqual(src map[int32]string) bool { - - if len(p.Header2) != len(src) { - return false - } - for k, v := range p.Header2 { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *ExampleJSONString) Field5DeepEqual(src *JSONObject) bool { - - if !p.Cookie.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleJSONString) Field6DeepEqual(src []int32) bool { - - if len(p.Cookie2) != len(src) { - return false - } - for i, v := range p.Cookie2 { - _src := src[i] - if v != _src { - return false - } - } - return true -} - -type ExamplePartial struct { - Msg string `thrift:"Msg,1" json:"msg"` -} - -func NewExamplePartial() *ExamplePartial { - return &ExamplePartial{} -} - -func (p *ExamplePartial) GetMsg() (v string) { - return p.Msg -} -func (p *ExamplePartial) SetMsg(val string) { - p.Msg = val -} - -var fieldIDToName_ExamplePartial = map[int16]string{ - 1: "Msg", -} - -func (p *ExamplePartial) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePartial[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExamplePartial) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil -} - -func (p *ExamplePartial) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExamplePartial"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExamplePartial) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExamplePartial) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExamplePartial(%+v)", *p) -} - -func (p *ExamplePartial) DeepEqual(ano *ExamplePartial) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - return true -} - -func (p *ExamplePartial) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true -} - -type ExamplePartial2 struct { - Msg string `thrift:"Msg,1" json:"msg"` - Cookie *float64 `thrift:"Cookie,2" json:"Cookie,omitempty"` - Status int32 `thrift:"Status,3,required" json:"Status"` - Header *bool `thrift:"Header,4" json:"Header,omitempty"` - Code int64 `thrift:"Code,6" json:"code_code"` - Subfix float64 `thrift:"Subfix,32767" json:"Subfix"` - InnerBase *InnerBasePartial `thrift:"InnerBase,7" json:"InnerBase"` - BaseResp *base.BaseResp `thrift:"BaseResp,255" json:"BaseResp"` -} - -func NewExamplePartial2() *ExamplePartial2 { - return &ExamplePartial2{} -} - -func (p *ExamplePartial2) GetMsg() (v string) { - return p.Msg -} - -var ExamplePartial2_Cookie_DEFAULT float64 - -func (p *ExamplePartial2) GetCookie() (v float64) { - if !p.IsSetCookie() { - return ExamplePartial2_Cookie_DEFAULT - } - return *p.Cookie -} - -func (p *ExamplePartial2) GetStatus() (v int32) { - return p.Status -} - -var ExamplePartial2_Header_DEFAULT bool - -func (p *ExamplePartial2) GetHeader() (v bool) { - if !p.IsSetHeader() { - return ExamplePartial2_Header_DEFAULT - } - return *p.Header -} - -func (p *ExamplePartial2) GetCode() (v int64) { - return p.Code -} - -func (p *ExamplePartial2) GetSubfix() (v float64) { - return p.Subfix -} - -var ExamplePartial2_InnerBase_DEFAULT *InnerBasePartial - -func (p *ExamplePartial2) GetInnerBase() (v *InnerBasePartial) { - if !p.IsSetInnerBase() { - return ExamplePartial2_InnerBase_DEFAULT - } - return p.InnerBase -} - -var ExamplePartial2_BaseResp_DEFAULT *base.BaseResp - -func (p *ExamplePartial2) GetBaseResp() (v *base.BaseResp) { - if !p.IsSetBaseResp() { - return ExamplePartial2_BaseResp_DEFAULT - } - return p.BaseResp -} -func (p *ExamplePartial2) SetMsg(val string) { - p.Msg = val -} -func (p *ExamplePartial2) SetCookie(val *float64) { - p.Cookie = val -} -func (p *ExamplePartial2) SetStatus(val int32) { - p.Status = val -} -func (p *ExamplePartial2) SetHeader(val *bool) { - p.Header = val -} -func (p *ExamplePartial2) SetCode(val int64) { - p.Code = val -} -func (p *ExamplePartial2) SetSubfix(val float64) { - p.Subfix = val -} -func (p *ExamplePartial2) SetInnerBase(val *InnerBasePartial) { - p.InnerBase = val -} -func (p *ExamplePartial2) SetBaseResp(val *base.BaseResp) { - p.BaseResp = val -} - -var fieldIDToName_ExamplePartial2 = map[int16]string{ - 1: "Msg", - 2: "Cookie", - 3: "Status", - 4: "Header", - 6: "Code", - 32767: "Subfix", - 7: "InnerBase", - 255: "BaseResp", -} - -func (p *ExamplePartial2) IsSetCookie() bool { - return p.Cookie != nil -} - -func (p *ExamplePartial2) IsSetHeader() bool { - return p.Header != nil -} - -func (p *ExamplePartial2) IsSetInnerBase() bool { - return p.InnerBase != nil -} - -func (p *ExamplePartial2) IsSetBaseResp() bool { - return p.BaseResp != nil -} - -func (p *ExamplePartial2) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetStatus bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetStatus = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField32767(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField7(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetStatus { - fieldId = 3 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePartial2[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExamplePartial2[fieldId])) -} - -func (p *ExamplePartial2) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil -} - -func (p *ExamplePartial2) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Cookie = &v - } - return nil -} - -func (p *ExamplePartial2) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Status = v - } - return nil -} - -func (p *ExamplePartial2) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Header = &v - } - return nil -} - -func (p *ExamplePartial2) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Code = v - } - return nil -} - -func (p *ExamplePartial2) ReadField32767(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Subfix = v - } - return nil -} - -func (p *ExamplePartial2) ReadField7(iprot thrift.TProtocol) error { - p.InnerBase = NewInnerBasePartial() - if err := p.InnerBase.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExamplePartial2) ReadField255(iprot thrift.TProtocol) error { - p.BaseResp = base.NewBaseResp() - if err := p.BaseResp.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExamplePartial2) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExamplePartial2"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - if err = p.writeField32767(oprot); err != nil { - fieldId = 32767 - goto WriteFieldError - } - if err = p.writeField7(oprot); err != nil { - fieldId = 7 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExamplePartial2) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetCookie() { - if err = oprot.WriteFieldBegin("Cookie", thrift.DOUBLE, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(*p.Cookie); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Status", thrift.I32, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Status); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetHeader() { - if err = oprot.WriteFieldBegin("Header", thrift.BOOL, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(*p.Header); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Code", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField32767(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Subfix", thrift.DOUBLE, 32767); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Subfix); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 32767 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerBase", thrift.STRUCT, 7); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerBase.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} - -func (p *ExamplePartial2) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.BaseResp.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *ExamplePartial2) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExamplePartial2(%+v)", *p) -} - -func (p *ExamplePartial2) DeepEqual(ano *ExamplePartial2) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Msg) { - return false - } - if !p.Field2DeepEqual(ano.Cookie) { - return false - } - if !p.Field3DeepEqual(ano.Status) { - return false - } - if !p.Field4DeepEqual(ano.Header) { - return false - } - if !p.Field6DeepEqual(ano.Code) { - return false - } - if !p.Field32767DeepEqual(ano.Subfix) { - return false - } - if !p.Field7DeepEqual(ano.InnerBase) { - return false - } - if !p.Field255DeepEqual(ano.BaseResp) { - return false - } - return true -} - -func (p *ExamplePartial2) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true -} -func (p *ExamplePartial2) Field2DeepEqual(src *float64) bool { - - if p.Cookie == src { - return true - } else if p.Cookie == nil || src == nil { - return false - } - if *p.Cookie != *src { - return false - } - return true -} -func (p *ExamplePartial2) Field3DeepEqual(src int32) bool { - - if p.Status != src { - return false - } - return true -} -func (p *ExamplePartial2) Field4DeepEqual(src *bool) bool { - - if p.Header == src { - return true - } else if p.Header == nil || src == nil { - return false - } - if *p.Header != *src { - return false - } - return true -} -func (p *ExamplePartial2) Field6DeepEqual(src int64) bool { - - if p.Code != src { - return false - } - return true -} -func (p *ExamplePartial2) Field32767DeepEqual(src float64) bool { - - if p.Subfix != src { - return false - } - return true -} -func (p *ExamplePartial2) Field7DeepEqual(src *InnerBasePartial) bool { - - if !p.InnerBase.DeepEqual(src) { - return false - } - return true -} -func (p *ExamplePartial2) Field255DeepEqual(src *base.BaseResp) bool { - - if !p.BaseResp.DeepEqual(src) { - return false - } - return true -} - -type InnerBasePartial struct { - Bool bool `thrift:"Bool,1" json:"Bool"` - Base *base.Base `thrift:"Base,255" json:"Base"` -} - -func NewInnerBasePartial() *InnerBasePartial { - return &InnerBasePartial{} -} - -func (p *InnerBasePartial) GetBool() (v bool) { - return p.Bool -} - -var InnerBasePartial_Base_DEFAULT *base.Base - -func (p *InnerBasePartial) GetBase() (v *base.Base) { - if !p.IsSetBase() { - return InnerBasePartial_Base_DEFAULT - } - return p.Base -} -func (p *InnerBasePartial) SetBool(val bool) { - p.Bool = val -} -func (p *InnerBasePartial) SetBase(val *base.Base) { - p.Base = val -} - -var fieldIDToName_InnerBasePartial = map[int16]string{ - 1: "Bool", - 255: "Base", -} - -func (p *InnerBasePartial) IsSetBase() bool { - return p.Base != nil -} - -func (p *InnerBasePartial) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBasePartial[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBasePartial) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Bool = v - } - return nil -} - -func (p *InnerBasePartial) ReadField255(iprot thrift.TProtocol) error { - p.Base = base.NewBase() - if err := p.Base.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *InnerBasePartial) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerBasePartial"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerBasePartial) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Bool", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Bool); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *InnerBasePartial) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { - goto WriteFieldBeginError - } - if err := p.Base.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) -} - -func (p *InnerBasePartial) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerBasePartial(%+v)", *p) -} - -func (p *InnerBasePartial) DeepEqual(ano *InnerBasePartial) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Bool) { - return false - } - if !p.Field255DeepEqual(ano.Base) { - return false - } - return true -} - -func (p *InnerBasePartial) Field1DeepEqual(src bool) bool { - - if p.Bool != src { - return false - } - return true -} -func (p *InnerBasePartial) Field255DeepEqual(src *base.Base) bool { - - if !p.Base.DeepEqual(src) { - return false - } - return true -} - -type ExampleFallback struct { - Msg string `thrift:"Msg,2" json:"Msg"` - Heeader string `thrift:"Heeader,3" json:"Heeader"` -} - -func NewExampleFallback() *ExampleFallback { - return &ExampleFallback{} -} - -func (p *ExampleFallback) GetMsg() (v string) { - return p.Msg -} - -func (p *ExampleFallback) GetHeeader() (v string) { - return p.Heeader -} -func (p *ExampleFallback) SetMsg(val string) { - p.Msg = val -} -func (p *ExampleFallback) SetHeeader(val string) { - p.Heeader = val -} - -var fieldIDToName_ExampleFallback = map[int16]string{ - 2: "Msg", - 3: "Heeader", -} - -func (p *ExampleFallback) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleFallback[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleFallback) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil -} - -func (p *ExampleFallback) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Heeader = v - } - return nil -} - -func (p *ExampleFallback) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleFallback"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleFallback) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleFallback) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Heeader", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Heeader); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleFallback) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleFallback(%+v)", *p) -} - -func (p *ExampleFallback) DeepEqual(ano *ExampleFallback) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field2DeepEqual(ano.Msg) { - return false - } - if !p.Field3DeepEqual(ano.Heeader) { - return false - } - return true -} - -func (p *ExampleFallback) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true -} -func (p *ExampleFallback) Field3DeepEqual(src string) bool { - - if strings.Compare(p.Heeader, src) != 0 { - return false - } - return true -} - -type InnerCode struct { - C1 int64 `thrift:"C1,1" json:"C1"` - C2 int16 `thrift:"C2,2" json:"code"` - C3 []*InnerCode `thrift:"C3,3" json:"C3"` -} - -func NewInnerCode() *InnerCode { - return &InnerCode{} -} - -func (p *InnerCode) GetC1() (v int64) { - return p.C1 -} - -func (p *InnerCode) GetC2() (v int16) { - return p.C2 -} - -func (p *InnerCode) GetC3() (v []*InnerCode) { - return p.C3 -} -func (p *InnerCode) SetC1(val int64) { - p.C1 = val -} -func (p *InnerCode) SetC2(val int16) { - p.C2 = val -} -func (p *InnerCode) SetC3(val []*InnerCode) { - p.C3 = val -} - -var fieldIDToName_InnerCode = map[int16]string{ - 1: "C1", - 2: "C2", - 3: "C3", -} - -func (p *InnerCode) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I16 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.LIST { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerCode[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerCode) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.C1 = v - } - return nil -} - -func (p *InnerCode) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - p.C2 = v - } - return nil -} - -func (p *InnerCode) ReadField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.C3 = make([]*InnerCode, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerCode() - if err := _elem.Read(iprot); err != nil { - return err - } - - p.C3 = append(p.C3, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *InnerCode) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerCode"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerCode) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("C1", thrift.I64, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.C1); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *InnerCode) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("C2", thrift.I16, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI16(p.C2); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *InnerCode) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("C3", thrift.LIST, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.C3)); err != nil { - return err - } - for _, v := range p.C3 { - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *InnerCode) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerCode(%+v)", *p) -} - -func (p *InnerCode) DeepEqual(ano *InnerCode) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.C1) { - return false - } - if !p.Field2DeepEqual(ano.C2) { - return false - } - if !p.Field3DeepEqual(ano.C3) { - return false - } - return true -} - -func (p *InnerCode) Field1DeepEqual(src int64) bool { - - if p.C1 != src { - return false - } - return true -} -func (p *InnerCode) Field2DeepEqual(src int16) bool { - - if p.C2 != src { - return false - } - return true -} -func (p *InnerCode) Field3DeepEqual(src []*InnerCode) bool { - - if len(p.C3) != len(src) { - return false - } - for i, v := range p.C3 { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} - -type ExampleApiBody struct { - Code int64 `thrift:"Code,1" json:"Code"` - Code2 int16 `thrift:"Code2,2" json:"code"` - InnerCode *InnerCode `thrift:"InnerCode,3" json:"InnerCode"` -} - -func NewExampleApiBody() *ExampleApiBody { - return &ExampleApiBody{} -} - -func (p *ExampleApiBody) GetCode() (v int64) { - return p.Code -} - -func (p *ExampleApiBody) GetCode2() (v int16) { - return p.Code2 -} - -var ExampleApiBody_InnerCode_DEFAULT *InnerCode - -func (p *ExampleApiBody) GetInnerCode() (v *InnerCode) { - if !p.IsSetInnerCode() { - return ExampleApiBody_InnerCode_DEFAULT - } - return p.InnerCode -} -func (p *ExampleApiBody) SetCode(val int64) { - p.Code = val -} -func (p *ExampleApiBody) SetCode2(val int16) { - p.Code2 = val -} -func (p *ExampleApiBody) SetInnerCode(val *InnerCode) { - p.InnerCode = val -} - -var fieldIDToName_ExampleApiBody = map[int16]string{ - 1: "Code", - 2: "Code2", - 3: "InnerCode", -} - -func (p *ExampleApiBody) IsSetInnerCode() bool { - return p.InnerCode != nil -} - -func (p *ExampleApiBody) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I16 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleApiBody[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleApiBody) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Code = v - } - return nil -} - -func (p *ExampleApiBody) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return err - } else { - p.Code2 = v - } - return nil -} - -func (p *ExampleApiBody) ReadField3(iprot thrift.TProtocol) error { - p.InnerCode = NewInnerCode() - if err := p.InnerCode.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleApiBody) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleApiBody"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleApiBody) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Code", thrift.I64, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleApiBody) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Code2", thrift.I16, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI16(p.Code2); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleApiBody) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerCode", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerCode.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleApiBody) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleApiBody(%+v)", *p) -} - -func (p *ExampleApiBody) DeepEqual(ano *ExampleApiBody) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Code) { - return false - } - if !p.Field2DeepEqual(ano.Code2) { - return false - } - if !p.Field3DeepEqual(ano.InnerCode) { - return false - } - return true -} - -func (p *ExampleApiBody) Field1DeepEqual(src int64) bool { - - if p.Code != src { - return false - } - return true -} -func (p *ExampleApiBody) Field2DeepEqual(src int16) bool { - - if p.Code2 != src { - return false - } - return true -} -func (p *ExampleApiBody) Field3DeepEqual(src *InnerCode) bool { - - if !p.InnerCode.DeepEqual(src) { - return false - } - return true -} - -type InnerJSON struct { - A string `thrift:"A,1" json:"a"` - B int64 `thrift:"B,2" json:"b"` - InnerForm float64 `thrift:"inner_form,3" json:"inner_form"` -} - -func NewInnerJSON() *InnerJSON { - return &InnerJSON{} -} - -func (p *InnerJSON) GetA() (v string) { - return p.A -} - -func (p *InnerJSON) GetB() (v int64) { - return p.B -} - -func (p *InnerJSON) GetInnerForm() (v float64) { - return p.InnerForm -} -func (p *InnerJSON) SetA(val string) { - p.A = val -} -func (p *InnerJSON) SetB(val int64) { - p.B = val -} -func (p *InnerJSON) SetInnerForm(val float64) { - p.InnerForm = val -} - -var fieldIDToName_InnerJSON = map[int16]string{ - 1: "A", - 2: "B", - 3: "inner_form", -} - -func (p *InnerJSON) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I64 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerJSON[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerJSON) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.A = v - } - return nil -} - -func (p *InnerJSON) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.B = v - } - return nil -} - -func (p *InnerJSON) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.InnerForm = v - } - return nil -} - -func (p *InnerJSON) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerJSON"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerJSON) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("A", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *InnerJSON) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("B", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *InnerJSON) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("inner_form", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.InnerForm); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *InnerJSON) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerJSON(%+v)", *p) -} - -func (p *InnerJSON) DeepEqual(ano *InnerJSON) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - if !p.Field3DeepEqual(ano.InnerForm) { - return false - } - return true -} - -func (p *InnerJSON) Field1DeepEqual(src string) bool { - - if strings.Compare(p.A, src) != 0 { - return false - } - return true -} -func (p *InnerJSON) Field2DeepEqual(src int64) bool { - - if p.B != src { - return false - } - return true -} -func (p *InnerJSON) Field3DeepEqual(src float64) bool { - - if p.InnerForm != src { - return false - } - return true -} - -type ExamplePostForm struct { - Query string `thrift:"Query,1" json:"Query"` - Form string `thrift:"Form,2" json:"Form"` - JSON *InnerJSON `thrift:"JSON,3" json:"JSON"` -} - -func NewExamplePostForm() *ExamplePostForm { - return &ExamplePostForm{} -} - -func (p *ExamplePostForm) GetQuery() (v string) { - return p.Query -} - -func (p *ExamplePostForm) GetForm() (v string) { - return p.Form -} - -var ExamplePostForm_JSON_DEFAULT *InnerJSON - -func (p *ExamplePostForm) GetJSON() (v *InnerJSON) { - if !p.IsSetJSON() { - return ExamplePostForm_JSON_DEFAULT - } - return p.JSON -} -func (p *ExamplePostForm) SetQuery(val string) { - p.Query = val -} -func (p *ExamplePostForm) SetForm(val string) { - p.Form = val -} -func (p *ExamplePostForm) SetJSON(val *InnerJSON) { - p.JSON = val -} - -var fieldIDToName_ExamplePostForm = map[int16]string{ - 1: "Query", - 2: "Form", - 3: "JSON", -} - -func (p *ExamplePostForm) IsSetJSON() bool { - return p.JSON != nil -} - -func (p *ExamplePostForm) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePostForm[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExamplePostForm) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Query = v - } - return nil -} - -func (p *ExamplePostForm) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Form = v - } - return nil -} - -func (p *ExamplePostForm) ReadField3(iprot thrift.TProtocol) error { - p.JSON = NewInnerJSON() - if err := p.JSON.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExamplePostForm) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExamplePostForm"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExamplePostForm) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Query", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Query); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExamplePostForm) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Form", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Form); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExamplePostForm) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("JSON", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.JSON.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExamplePostForm) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExamplePostForm(%+v)", *p) -} - -func (p *ExamplePostForm) DeepEqual(ano *ExamplePostForm) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Query) { - return false - } - if !p.Field2DeepEqual(ano.Form) { - return false - } - if !p.Field3DeepEqual(ano.JSON) { - return false - } - return true -} - -func (p *ExamplePostForm) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Query, src) != 0 { - return false - } - return true -} -func (p *ExamplePostForm) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Form, src) != 0 { - return false - } - return true -} -func (p *ExamplePostForm) Field3DeepEqual(src *InnerJSON) bool { - - if !p.JSON.DeepEqual(src) { - return false - } - return true -} - -type InnerStruct struct { - InnerJSON string `thrift:"InnerJSON,1" json:"inner_json"` - Must string `thrift:"Must,2,required" json:"Must"` -} - -func NewInnerStruct() *InnerStruct { - return &InnerStruct{} -} - -func (p *InnerStruct) GetInnerJSON() (v string) { - return p.InnerJSON -} - -func (p *InnerStruct) GetMust() (v string) { - return p.Must -} -func (p *InnerStruct) SetInnerJSON(val string) { - p.InnerJSON = val -} -func (p *InnerStruct) SetMust(val string) { - p.Must = val -} - -var fieldIDToName_InnerStruct = map[int16]string{ - 1: "InnerJSON", - 2: "Must", -} - -func (p *InnerStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMust bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - issetMust = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetMust { - fieldId = 2 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_InnerStruct[fieldId])) -} - -func (p *InnerStruct) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.InnerJSON = v - } - return nil -} - -func (p *InnerStruct) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Must = v - } - return nil -} - -func (p *InnerStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("InnerStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *InnerStruct) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerJSON", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.InnerJSON); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *InnerStruct) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Must", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Must); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *InnerStruct) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InnerStruct(%+v)", *p) -} - -func (p *InnerStruct) DeepEqual(ano *InnerStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.InnerJSON) { - return false - } - if !p.Field2DeepEqual(ano.Must) { - return false - } - return true -} - -func (p *InnerStruct) Field1DeepEqual(src string) bool { - - if strings.Compare(p.InnerJSON, src) != 0 { - return false - } - return true -} -func (p *InnerStruct) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Must, src) != 0 { - return false - } - return true -} - -type ExampleDynamicStruct struct { - Query string `thrift:"Query,1,required" json:"Query"` - JSON string `thrift:"JSON,2" json:"json"` - InnerStruct *InnerStruct `thrift:"InnerStruct,3" json:"inner_struct"` -} - -func NewExampleDynamicStruct() *ExampleDynamicStruct { - return &ExampleDynamicStruct{} -} - -func (p *ExampleDynamicStruct) GetQuery() (v string) { - return p.Query -} - -func (p *ExampleDynamicStruct) GetJSON() (v string) { - return p.JSON -} - -var ExampleDynamicStruct_InnerStruct_DEFAULT *InnerStruct - -func (p *ExampleDynamicStruct) GetInnerStruct() (v *InnerStruct) { - if !p.IsSetInnerStruct() { - return ExampleDynamicStruct_InnerStruct_DEFAULT - } - return p.InnerStruct -} -func (p *ExampleDynamicStruct) SetQuery(val string) { - p.Query = val -} -func (p *ExampleDynamicStruct) SetJSON(val string) { - p.JSON = val -} -func (p *ExampleDynamicStruct) SetInnerStruct(val *InnerStruct) { - p.InnerStruct = val -} - -var fieldIDToName_ExampleDynamicStruct = map[int16]string{ - 1: "Query", - 2: "JSON", - 3: "InnerStruct", -} - -func (p *ExampleDynamicStruct) IsSetInnerStruct() bool { - return p.InnerStruct != nil -} - -func (p *ExampleDynamicStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - issetQuery = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetQuery { - fieldId = 1 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDynamicStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleDynamicStruct[fieldId])) -} - -func (p *ExampleDynamicStruct) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Query = v - } - return nil -} - -func (p *ExampleDynamicStruct) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.JSON = v - } - return nil -} - -func (p *ExampleDynamicStruct) ReadField3(iprot thrift.TProtocol) error { - p.InnerStruct = NewInnerStruct() - if err := p.InnerStruct.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleDynamicStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDynamicStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleDynamicStruct) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Query", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Query); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleDynamicStruct) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("JSON", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.JSON); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleDynamicStruct) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("InnerStruct", thrift.STRUCT, 3); err != nil { - goto WriteFieldBeginError - } - if err := p.InnerStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleDynamicStruct) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleDynamicStruct(%+v)", *p) -} - -func (p *ExampleDynamicStruct) DeepEqual(ano *ExampleDynamicStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Query) { - return false - } - if !p.Field2DeepEqual(ano.JSON) { - return false - } - if !p.Field3DeepEqual(ano.InnerStruct) { - return false - } - return true -} - -func (p *ExampleDynamicStruct) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Query, src) != 0 { - return false - } - return true -} -func (p *ExampleDynamicStruct) Field2DeepEqual(src string) bool { - - if strings.Compare(p.JSON, src) != 0 { - return false - } - return true -} -func (p *ExampleDynamicStruct) Field3DeepEqual(src *InnerStruct) bool { - - if !p.InnerStruct.DeepEqual(src) { - return false - } - return true -} - -type ExampleBase64Binary struct { - Binary []byte `thrift:"Binary,1" json:"Binary"` - Binary2 []byte `thrift:"Binary2,2" json:"Binary2"` -} - -func NewExampleBase64Binary() *ExampleBase64Binary { - return &ExampleBase64Binary{} -} - -func (p *ExampleBase64Binary) GetBinary() (v []byte) { - return p.Binary -} - -func (p *ExampleBase64Binary) GetBinary2() (v []byte) { - return p.Binary2 -} -func (p *ExampleBase64Binary) SetBinary(val []byte) { - p.Binary = val -} -func (p *ExampleBase64Binary) SetBinary2(val []byte) { - p.Binary2 = val -} - -var fieldIDToName_ExampleBase64Binary = map[int16]string{ - 1: "Binary", - 2: "Binary2", -} - -func (p *ExampleBase64Binary) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleBase64Binary[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleBase64Binary) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil -} - -func (p *ExampleBase64Binary) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary2 = []byte(v) - } - return nil -} - -func (p *ExampleBase64Binary) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleBase64Binary"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleBase64Binary) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleBase64Binary) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary2", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary2)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleBase64Binary) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExampleBase64Binary(%+v)", *p) -} - -func (p *ExampleBase64Binary) DeepEqual(ano *ExampleBase64Binary) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Binary) { - return false - } - if !p.Field2DeepEqual(ano.Binary2) { - return false - } - return true -} - -func (p *ExampleBase64Binary) Field1DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true -} -func (p *ExampleBase64Binary) Field2DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary2, src) != 0 { - return false - } - return true -} - -type ExampleDefaultValue struct { - A string `thrift:"A,1" json:"A"` - B int32 `thrift:"B,2" json:"B"` - C float64 `thrift:"C,3" json:"C"` - D string `thrift:"D,4" json:"D"` -} - -func NewExampleDefaultValue() *ExampleDefaultValue { - return &ExampleDefaultValue{ - - A: "hello", - B: int32(ref.FOO_A), - C: 1.2, - D: ref.ConstString, - } -} - -func (p *ExampleDefaultValue) GetA() (v string) { - return p.A -} - -func (p *ExampleDefaultValue) GetB() (v int32) { - return p.B -} - -func (p *ExampleDefaultValue) GetC() (v float64) { - return p.C -} - -func (p *ExampleDefaultValue) GetD() (v string) { - return p.D -} -func (p *ExampleDefaultValue) SetA(val string) { - p.A = val -} -func (p *ExampleDefaultValue) SetB(val int32) { - p.B = val -} -func (p *ExampleDefaultValue) SetC(val float64) { - p.C = val -} -func (p *ExampleDefaultValue) SetD(val string) { - p.D = val -} - -var fieldIDToName_ExampleDefaultValue = map[int16]string{ - 1: "A", - 2: "B", - 3: "C", - 4: "D", -} - -func (p *ExampleDefaultValue) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDefaultValue[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.A = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.B = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.C = v - } - return nil -} - -func (p *ExampleDefaultValue) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.D = v - } - return nil -} - -func (p *ExampleDefaultValue) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleDefaultValue"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("A", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("B", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("C", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.C); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *ExampleDefaultValue) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("D", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.D); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleDefaultValue) String() string { +func (p *ExamplePartial2) String() string { if p == nil { return "" } - return fmt.Sprintf("ExampleDefaultValue(%+v)", *p) -} - -func (p *ExampleDefaultValue) DeepEqual(ano *ExampleDefaultValue) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - if !p.Field3DeepEqual(ano.C) { - return false - } - if !p.Field4DeepEqual(ano.D) { - return false - } - return true -} - -func (p *ExampleDefaultValue) Field1DeepEqual(src string) bool { - - if strings.Compare(p.A, src) != 0 { - return false - } - return true -} -func (p *ExampleDefaultValue) Field2DeepEqual(src int32) bool { - - if p.B != src { - return false - } - return true -} -func (p *ExampleDefaultValue) Field3DeepEqual(src float64) bool { - - if p.C != src { - return false - } - return true -} -func (p *ExampleDefaultValue) Field4DeepEqual(src string) bool { - - if strings.Compare(p.D, src) != 0 { - return false - } - return true -} - -type ExampleOptionalDefaultValue struct { - A string `thrift:"A,1" json:"A,omitempty"` - B int32 `thrift:"B,2,required" json:"B"` - C float64 `thrift:"C,3" json:"C,omitempty"` - D string `thrift:"D,4,required" json:"D"` - E *string `thrift:"E,5" json:"E,omitempty"` - F *string `thrift:"F,6" json:"F,omitempty"` -} - -func NewExampleOptionalDefaultValue() *ExampleOptionalDefaultValue { - return &ExampleOptionalDefaultValue{ - - A: "hello", - B: int32(ref.FOO_A), - C: 1.2, - D: ref.ConstString, - } -} - -var ExampleOptionalDefaultValue_A_DEFAULT string = "hello" - -func (p *ExampleOptionalDefaultValue) GetA() (v string) { - if !p.IsSetA() { - return ExampleOptionalDefaultValue_A_DEFAULT - } - return p.A -} - -func (p *ExampleOptionalDefaultValue) GetB() (v int32) { - return p.B -} - -var ExampleOptionalDefaultValue_C_DEFAULT float64 = 1.2 - -func (p *ExampleOptionalDefaultValue) GetC() (v float64) { - if !p.IsSetC() { - return ExampleOptionalDefaultValue_C_DEFAULT - } - return p.C -} - -func (p *ExampleOptionalDefaultValue) GetD() (v string) { - return p.D -} - -var ExampleOptionalDefaultValue_E_DEFAULT string - -func (p *ExampleOptionalDefaultValue) GetE() (v string) { - if !p.IsSetE() { - return ExampleOptionalDefaultValue_E_DEFAULT - } - return *p.E -} - -var ExampleOptionalDefaultValue_F_DEFAULT string - -func (p *ExampleOptionalDefaultValue) GetF() (v string) { - if !p.IsSetF() { - return ExampleOptionalDefaultValue_F_DEFAULT - } - return *p.F -} -func (p *ExampleOptionalDefaultValue) SetA(val string) { - p.A = val -} -func (p *ExampleOptionalDefaultValue) SetB(val int32) { - p.B = val -} -func (p *ExampleOptionalDefaultValue) SetC(val float64) { - p.C = val -} -func (p *ExampleOptionalDefaultValue) SetD(val string) { - p.D = val -} -func (p *ExampleOptionalDefaultValue) SetE(val *string) { - p.E = val -} -func (p *ExampleOptionalDefaultValue) SetF(val *string) { - p.F = val -} - -var fieldIDToName_ExampleOptionalDefaultValue = map[int16]string{ - 1: "A", - 2: "B", - 3: "C", - 4: "D", - 5: "E", - 6: "F", -} - -func (p *ExampleOptionalDefaultValue) IsSetA() bool { - return p.A != ExampleOptionalDefaultValue_A_DEFAULT -} - -func (p *ExampleOptionalDefaultValue) IsSetC() bool { - return p.C != ExampleOptionalDefaultValue_C_DEFAULT -} - -func (p *ExampleOptionalDefaultValue) IsSetE() bool { - return p.E != nil -} - -func (p *ExampleOptionalDefaultValue) IsSetF() bool { - return p.F != nil -} - -func (p *ExampleOptionalDefaultValue) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetB bool = false - var issetD bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - issetB = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - issetD = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRING { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetB { - fieldId = 2 - goto RequiredFieldNotSetError - } - - if !issetD { - fieldId = 4 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleOptionalDefaultValue[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleOptionalDefaultValue[fieldId])) -} - -func (p *ExampleOptionalDefaultValue) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.A = v - } - return nil -} - -func (p *ExampleOptionalDefaultValue) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.B = v - } - return nil -} - -func (p *ExampleOptionalDefaultValue) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.C = v - } - return nil + return fmt.Sprintf("ExamplePartial2(%+v)", *p) } -func (p *ExampleOptionalDefaultValue) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.D = v - } - return nil +var fieldIDToName_ExamplePartial2 = map[int16]string{ + 1: "Msg", + 2: "Cookie", + 3: "Status", + 4: "Header", + 6: "Code", + 32767: "Subfix", + 7: "InnerBase", + 255: "BaseResp", } -func (p *ExampleOptionalDefaultValue) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.E = &v - } - return nil +type InnerBasePartial struct { + Bool bool `thrift:"Bool,1" json:"Bool"` + Base *base.Base `thrift:"Base,255" json:"Base"` } -func (p *ExampleOptionalDefaultValue) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.F = &v - } - return nil +func NewInnerBasePartial() *InnerBasePartial { + return &InnerBasePartial{} } -func (p *ExampleOptionalDefaultValue) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleOptionalDefaultValue"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } +func (p *InnerBasePartial) InitDefault() { +} - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleOptionalDefaultValue) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetA() { - if err = oprot.WriteFieldBegin("A", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *InnerBasePartial) GetBool() (v bool) { + return p.Bool } -func (p *ExampleOptionalDefaultValue) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("B", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *ExampleOptionalDefaultValue) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetC() { - if err = oprot.WriteFieldBegin("C", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.C); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } +var InnerBasePartial_Base_DEFAULT *base.Base + +func (p *InnerBasePartial) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return InnerBasePartial_Base_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) + return p.Base } -func (p *ExampleOptionalDefaultValue) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("D", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.D); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *ExampleOptionalDefaultValue) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetE() { - if err = oprot.WriteFieldBegin("E", thrift.STRING, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.E); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *ExampleOptionalDefaultValue) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetF() { - if err = oprot.WriteFieldBegin("F", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.F); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +func (p *InnerBasePartial) IsSetBase() bool { + return p.Base != nil } -func (p *ExampleOptionalDefaultValue) String() string { +func (p *InnerBasePartial) String() string { if p == nil { return "" } - return fmt.Sprintf("ExampleOptionalDefaultValue(%+v)", *p) + return fmt.Sprintf("InnerBasePartial(%+v)", *p) } -func (p *ExampleOptionalDefaultValue) DeepEqual(ano *ExampleOptionalDefaultValue) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - if !p.Field3DeepEqual(ano.C) { - return false - } - if !p.Field4DeepEqual(ano.D) { - return false - } - if !p.Field5DeepEqual(ano.E) { - return false - } - if !p.Field6DeepEqual(ano.F) { - return false - } - return true +var fieldIDToName_InnerBasePartial = map[int16]string{ + 1: "Bool", + 255: "Base", } -func (p *ExampleOptionalDefaultValue) Field1DeepEqual(src string) bool { - - if strings.Compare(p.A, src) != 0 { - return false - } - return true +type ExampleFallback struct { + Msg string `thrift:"Msg,2" json:"Msg"` + Heeader string `thrift:"Heeader,3" json:"Heeader"` } -func (p *ExampleOptionalDefaultValue) Field2DeepEqual(src int32) bool { - if p.B != src { - return false - } - return true +func NewExampleFallback() *ExampleFallback { + return &ExampleFallback{} } -func (p *ExampleOptionalDefaultValue) Field3DeepEqual(src float64) bool { - if p.C != src { - return false - } - return true +func (p *ExampleFallback) InitDefault() { } -func (p *ExampleOptionalDefaultValue) Field4DeepEqual(src string) bool { - if strings.Compare(p.D, src) != 0 { - return false - } - return true +func (p *ExampleFallback) GetMsg() (v string) { + return p.Msg } -func (p *ExampleOptionalDefaultValue) Field5DeepEqual(src *string) bool { - if p.E == src { - return true - } else if p.E == nil || src == nil { - return false - } - if strings.Compare(*p.E, *src) != 0 { - return false - } - return true +func (p *ExampleFallback) GetHeeader() (v string) { + return p.Heeader } -func (p *ExampleOptionalDefaultValue) Field6DeepEqual(src *string) bool { - if p.F == src { - return true - } else if p.F == nil || src == nil { - return false - } - if strings.Compare(*p.F, *src) != 0 { - return false +func (p *ExampleFallback) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("ExampleFallback(%+v)", *p) } -type ExampleNoBodyStruct struct { - NoBodyStruct *NoBodyStruct `thrift:"NoBodyStruct,1" json:"NoBodyStruct"` +var fieldIDToName_ExampleFallback = map[int16]string{ + 2: "Msg", + 3: "Heeader", } -func NewExampleNoBodyStruct() *ExampleNoBodyStruct { - return &ExampleNoBodyStruct{} +type InnerCode struct { + C1 int64 `thrift:"C1,1" json:"C1"` + C2 int16 `thrift:"C2,2" json:"code"` + C3 []*InnerCode `thrift:"C3,3" json:"C3"` } -var ExampleNoBodyStruct_NoBodyStruct_DEFAULT *NoBodyStruct - -func (p *ExampleNoBodyStruct) GetNoBodyStruct() (v *NoBodyStruct) { - if !p.IsSetNoBodyStruct() { - return ExampleNoBodyStruct_NoBodyStruct_DEFAULT - } - return p.NoBodyStruct -} -func (p *ExampleNoBodyStruct) SetNoBodyStruct(val *NoBodyStruct) { - p.NoBodyStruct = val +func NewInnerCode() *InnerCode { + return &InnerCode{} } -var fieldIDToName_ExampleNoBodyStruct = map[int16]string{ - 1: "NoBodyStruct", +func (p *InnerCode) InitDefault() { } -func (p *ExampleNoBodyStruct) IsSetNoBodyStruct() bool { - return p.NoBodyStruct != nil +func (p *InnerCode) GetC1() (v int64) { + return p.C1 } -func (p *ExampleNoBodyStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleNoBodyStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleNoBodyStruct) ReadField1(iprot thrift.TProtocol) error { - p.NoBodyStruct = NewNoBodyStruct() - if err := p.NoBodyStruct.Read(iprot); err != nil { - return err - } - return nil +func (p *InnerCode) GetC2() (v int16) { + return p.C2 } -func (p *ExampleNoBodyStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleNoBodyStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleNoBodyStruct) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("NoBodyStruct", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.NoBodyStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *InnerCode) GetC3() (v []*InnerCode) { + return p.C3 } -func (p *ExampleNoBodyStruct) String() string { +func (p *InnerCode) String() string { if p == nil { return "" } - return fmt.Sprintf("ExampleNoBodyStruct(%+v)", *p) + return fmt.Sprintf("InnerCode(%+v)", *p) } -func (p *ExampleNoBodyStruct) DeepEqual(ano *ExampleNoBodyStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.NoBodyStruct) { - return false - } - return true +var fieldIDToName_InnerCode = map[int16]string{ + 1: "C1", + 2: "C2", + 3: "C3", } -func (p *ExampleNoBodyStruct) Field1DeepEqual(src *NoBodyStruct) bool { - - if !p.NoBodyStruct.DeepEqual(src) { - return false - } - return true +type ExampleApiBody struct { + Code int64 `thrift:"Code,1" json:"Code"` + Code2 int16 `thrift:"Code2,2" json:"code"` + InnerCode *InnerCode `thrift:"InnerCode,3" json:"InnerCode"` } -type NoBodyStruct struct { - A *int32 `thrift:"A,1" json:"A,omitempty"` - B *int32 `thrift:"B,2" json:"B,omitempty"` - C int32 `thrift:"C,3" json:"C,omitempty"` +func NewExampleApiBody() *ExampleApiBody { + return &ExampleApiBody{} } -func NewNoBodyStruct() *NoBodyStruct { - return &NoBodyStruct{ - - C: 1, - } +func (p *ExampleApiBody) InitDefault() { } -var NoBodyStruct_A_DEFAULT int32 +func (p *ExampleApiBody) GetCode() (v int64) { + return p.Code +} -func (p *NoBodyStruct) GetA() (v int32) { - if !p.IsSetA() { - return NoBodyStruct_A_DEFAULT - } - return *p.A +func (p *ExampleApiBody) GetCode2() (v int16) { + return p.Code2 } -var NoBodyStruct_B_DEFAULT int32 +var ExampleApiBody_InnerCode_DEFAULT *InnerCode -func (p *NoBodyStruct) GetB() (v int32) { - if !p.IsSetB() { - return NoBodyStruct_B_DEFAULT +func (p *ExampleApiBody) GetInnerCode() (v *InnerCode) { + if !p.IsSetInnerCode() { + return ExampleApiBody_InnerCode_DEFAULT } - return *p.B + return p.InnerCode } -var NoBodyStruct_C_DEFAULT int32 = 1 +func (p *ExampleApiBody) IsSetInnerCode() bool { + return p.InnerCode != nil +} -func (p *NoBodyStruct) GetC() (v int32) { - if !p.IsSetC() { - return NoBodyStruct_C_DEFAULT +func (p *ExampleApiBody) String() string { + if p == nil { + return "" } - return p.C -} -func (p *NoBodyStruct) SetA(val *int32) { - p.A = val -} -func (p *NoBodyStruct) SetB(val *int32) { - p.B = val -} -func (p *NoBodyStruct) SetC(val int32) { - p.C = val + return fmt.Sprintf("ExampleApiBody(%+v)", *p) } -var fieldIDToName_NoBodyStruct = map[int16]string{ - 1: "A", - 2: "B", - 3: "C", +var fieldIDToName_ExampleApiBody = map[int16]string{ + 1: "Code", + 2: "Code2", + 3: "InnerCode", } -func (p *NoBodyStruct) IsSetA() bool { - return p.A != nil +type InnerJSON struct { + A string `thrift:"A,1" json:"a"` + B int64 `thrift:"B,2" json:"b"` + InnerForm float64 `thrift:"inner_form,3" json:"inner_form"` } -func (p *NoBodyStruct) IsSetB() bool { - return p.B != nil +func NewInnerJSON() *InnerJSON { + return &InnerJSON{} } -func (p *NoBodyStruct) IsSetC() bool { - return p.C != NoBodyStruct_C_DEFAULT +func (p *InnerJSON) InitDefault() { } -func (p *NoBodyStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 +func (p *InnerJSON) GetA() (v string) { + return p.A +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *InnerJSON) GetB() (v int64) { + return p.B +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +func (p *InnerJSON) GetInnerForm() (v float64) { + return p.InnerForm +} - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NoBodyStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *NoBodyStruct) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.A = &v +func (p *InnerJSON) String() string { + if p == nil { + return "" } - return nil + return fmt.Sprintf("InnerJSON(%+v)", *p) } -func (p *NoBodyStruct) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.B = &v - } - return nil +var fieldIDToName_InnerJSON = map[int16]string{ + 1: "A", + 2: "B", + 3: "inner_form", } -func (p *NoBodyStruct) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.C = v - } - return nil +type ExamplePostForm struct { + Query string `thrift:"Query,1" json:"Query"` + Form string `thrift:"Form,2" json:"Form"` + JSON *InnerJSON `thrift:"JSON,3" json:"JSON"` } -func (p *NoBodyStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NoBodyStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } +func NewExamplePostForm() *ExamplePostForm { + return &ExamplePostForm{} +} - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *NoBodyStruct) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetA() { - if err = oprot.WriteFieldBegin("A", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(*p.A); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *NoBodyStruct) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetB() { - if err = oprot.WriteFieldBegin("B", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(*p.B); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *NoBodyStruct) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetC() { - if err = oprot.WriteFieldBegin("C", thrift.I32, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.C); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +func (p *ExamplePostForm) InitDefault() { } -func (p *NoBodyStruct) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("NoBodyStruct(%+v)", *p) +func (p *ExamplePostForm) GetQuery() (v string) { + return p.Query } -func (p *NoBodyStruct) DeepEqual(ano *NoBodyStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.A) { - return false - } - if !p.Field2DeepEqual(ano.B) { - return false - } - if !p.Field3DeepEqual(ano.C) { - return false - } - return true +func (p *ExamplePostForm) GetForm() (v string) { + return p.Form } -func (p *NoBodyStruct) Field1DeepEqual(src *int32) bool { +var ExamplePostForm_JSON_DEFAULT *InnerJSON - if p.A == src { - return true - } else if p.A == nil || src == nil { - return false - } - if *p.A != *src { - return false +func (p *ExamplePostForm) GetJSON() (v *InnerJSON) { + if !p.IsSetJSON() { + return ExamplePostForm_JSON_DEFAULT } - return true + return p.JSON } -func (p *NoBodyStruct) Field2DeepEqual(src *int32) bool { - if p.B == src { - return true - } else if p.B == nil || src == nil { - return false - } - if *p.B != *src { - return false +func (p *ExamplePostForm) IsSetJSON() bool { + return p.JSON != nil +} + +func (p *ExamplePostForm) String() string { + if p == nil { + return "" } - return true + return fmt.Sprintf("ExamplePostForm(%+v)", *p) } -func (p *NoBodyStruct) Field3DeepEqual(src int32) bool { - if p.C != src { - return false - } - return true +var fieldIDToName_ExamplePostForm = map[int16]string{ + 1: "Query", + 2: "Form", + 3: "JSON", } -type Exception struct { - Code int32 `thrift:"code,1" json:"code"` - Msg string `thrift:"msg,255" json:"msg"` +type InnerStruct struct { + InnerJSON string `thrift:"InnerJSON,1" json:"inner_json"` + Must string `thrift:"Must,2,required" json:"Must"` } -func NewException() *Exception { - return &Exception{} +func NewInnerStruct() *InnerStruct { + return &InnerStruct{} } -func (p *Exception) GetCode() (v int32) { - return p.Code +func (p *InnerStruct) InitDefault() { } -func (p *Exception) GetMsg() (v string) { - return p.Msg -} -func (p *Exception) SetCode(val int32) { - p.Code = val +func (p *InnerStruct) GetInnerJSON() (v string) { + return p.InnerJSON } -func (p *Exception) SetMsg(val string) { - p.Msg = val + +func (p *InnerStruct) GetMust() (v string) { + return p.Must } -var fieldIDToName_Exception = map[int16]string{ - 1: "code", - 255: "msg", +func (p *InnerStruct) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("InnerStruct(%+v)", *p) } -func (p *Exception) Read(iprot thrift.TProtocol) (err error) { +var fieldIDToName_InnerStruct = map[int16]string{ + 1: "InnerJSON", + 2: "Must", +} - var fieldTypeId thrift.TType - var fieldId int16 +type ExampleDynamicStruct struct { + Query string `thrift:"Query,1,required" json:"Query"` + JSON string `thrift:"JSON,2" json:"json"` + InnerStruct *InnerStruct `thrift:"InnerStruct,3" json:"inner_struct"` +} - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func NewExampleDynamicStruct() *ExampleDynamicStruct { + return &ExampleDynamicStruct{} +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRING { - if err = p.ReadField255(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +func (p *ExampleDynamicStruct) InitDefault() { +} - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Exception) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.Code = v - } - return nil +func (p *ExampleDynamicStruct) GetQuery() (v string) { + return p.Query } -func (p *Exception) ReadField255(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Msg = v - } - return nil +func (p *ExampleDynamicStruct) GetJSON() (v string) { + return p.JSON } -func (p *Exception) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Exception"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField255(oprot); err != nil { - fieldId = 255 - goto WriteFieldError - } +var ExampleDynamicStruct_InnerStruct_DEFAULT *InnerStruct +func (p *ExampleDynamicStruct) GetInnerStruct() (v *InnerStruct) { + if !p.IsSetInnerStruct() { + return ExampleDynamicStruct_InnerStruct_DEFAULT } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Exception) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Code); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) + return p.InnerStruct } -func (p *Exception) writeField255(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 255); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +func (p *ExampleDynamicStruct) IsSetInnerStruct() bool { + return p.InnerStruct != nil } -func (p *Exception) String() string { +func (p *ExampleDynamicStruct) String() string { if p == nil { return "" } - return fmt.Sprintf("Exception(%+v)", *p) -} -func (p *Exception) Error() string { - return p.String() + return fmt.Sprintf("ExampleDynamicStruct(%+v)", *p) } -func (p *Exception) DeepEqual(ano *Exception) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Code) { - return false - } - if !p.Field255DeepEqual(ano.Msg) { - return false - } - return true +var fieldIDToName_ExampleDynamicStruct = map[int16]string{ + 1: "Query", + 2: "JSON", + 3: "InnerStruct", } -func (p *Exception) Field1DeepEqual(src int32) bool { - - if p.Code != src { - return false - } - return true +type ExampleBase64Binary struct { + Binary []byte `thrift:"Binary,1" json:"Binary"` + Binary2 []byte `thrift:"Binary2,2" json:"Binary2"` } -func (p *Exception) Field255DeepEqual(src string) bool { - if strings.Compare(p.Msg, src) != 0 { - return false - } - return true +func NewExampleBase64Binary() *ExampleBase64Binary { + return &ExampleBase64Binary{} } -type ExampleService interface { - ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) - - ErrorMethod(ctx context.Context, req *ExampleError) (r *ExampleErrorResp, err error) - - Int2FloatMethod(ctx context.Context, req *ExampleInt2Float) (r *ExampleInt2Float, err error) - - JSONStringMethod(ctx context.Context, req *ExampleJSONString) (r *ExampleJSONString, err error) - - PartialMethod(ctx context.Context, req *ExamplePartial2) (r *ExamplePartial, err error) - - FallbackMethod(ctx context.Context, req *ExampleFallback) (r *ExampleFallback, err error) - - ApiBodyMethod(ctx context.Context, req *ExampleApiBody) (r *ExampleApiBody, err error) - - PostFormMethod(ctx context.Context, req *ExamplePostForm) (r *ExamplePostForm, err error) - - DynamicStructMethod(ctx context.Context, req *ExampleDynamicStruct) (r *ExampleDynamicStruct, err error) - - Base64BinaryMethod(ctx context.Context, req *ExampleBase64Binary) (r *ExampleBase64Binary, err error) - - DefaultValueMethod(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) - - OptionalDefaultValueMethod(ctx context.Context, req *ExampleOptionalDefaultValue) (r *ExampleOptionalDefaultValue, err error) - - NoBodyStructMethod(ctx context.Context, req *ExampleNoBodyStruct) (r *ExampleNoBodyStruct, err error) - - String(ctx context.Context, req string) (r string, err error) - - I64(ctx context.Context, req int64) (r int64, err error) +func (p *ExampleBase64Binary) InitDefault() { } -type ExampleServiceClient struct { - c thrift.TClient +func (p *ExampleBase64Binary) GetBinary() (v []byte) { + return p.Binary } -func NewExampleServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } +func (p *ExampleBase64Binary) GetBinary2() (v []byte) { + return p.Binary2 } -func NewExampleServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ExampleServiceClient { - return &ExampleServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), +func (p *ExampleBase64Binary) String() string { + if p == nil { + return "" } + return fmt.Sprintf("ExampleBase64Binary(%+v)", *p) } -func NewExampleServiceClient(c thrift.TClient) *ExampleServiceClient { - return &ExampleServiceClient{ - c: c, - } +var fieldIDToName_ExampleBase64Binary = map[int16]string{ + 1: "Binary", + 2: "Binary2", } -func (p *ExampleServiceClient) Client_() thrift.TClient { - return p.c +type ExampleDefaultValue struct { + A string `thrift:"A,1" json:"A"` + B int32 `thrift:"B,2" json:"B"` + C float64 `thrift:"C,3" json:"C"` + D string `thrift:"D,4" json:"D"` } -func (p *ExampleServiceClient) ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) { - var _args ExampleServiceExampleMethodArgs - _args.Req = req - var _result ExampleServiceExampleMethodResult - if err = p.Client_().Call(ctx, "ExampleMethod", &_args, &_result); err != nil { - return - } - switch { - case _result.Err != nil: - return r, _result.Err +func NewExampleDefaultValue() *ExampleDefaultValue { + return &ExampleDefaultValue{ + + A: "hello", + B: int32(ref.FOO_A), + C: 1.2, + D: ref.ConstString, } - return _result.GetSuccess(), nil } -func (p *ExampleServiceClient) ErrorMethod(ctx context.Context, req *ExampleError) (r *ExampleErrorResp, err error) { - var _args ExampleServiceErrorMethodArgs - _args.Req = req - var _result ExampleServiceErrorMethodResult - if err = p.Client_().Call(ctx, "ErrorMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleDefaultValue) InitDefault() { + p.A = "hello" + p.B = int32(ref.FOO_A) + p.C = 1.2 + p.D = ref.ConstString } -func (p *ExampleServiceClient) Int2FloatMethod(ctx context.Context, req *ExampleInt2Float) (r *ExampleInt2Float, err error) { - var _args ExampleServiceInt2FloatMethodArgs - _args.Req = req - var _result ExampleServiceInt2FloatMethodResult - if err = p.Client_().Call(ctx, "Int2FloatMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleDefaultValue) GetA() (v string) { + return p.A } -func (p *ExampleServiceClient) JSONStringMethod(ctx context.Context, req *ExampleJSONString) (r *ExampleJSONString, err error) { - var _args ExampleServiceJSONStringMethodArgs - _args.Req = req - var _result ExampleServiceJSONStringMethodResult - if err = p.Client_().Call(ctx, "JSONStringMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleDefaultValue) GetB() (v int32) { + return p.B } -func (p *ExampleServiceClient) PartialMethod(ctx context.Context, req *ExamplePartial2) (r *ExamplePartial, err error) { - var _args ExampleServicePartialMethodArgs - _args.Req = req - var _result ExampleServicePartialMethodResult - if err = p.Client_().Call(ctx, "PartialMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleDefaultValue) GetC() (v float64) { + return p.C } -func (p *ExampleServiceClient) FallbackMethod(ctx context.Context, req *ExampleFallback) (r *ExampleFallback, err error) { - var _args ExampleServiceFallbackMethodArgs - _args.Req = req - var _result ExampleServiceFallbackMethodResult - if err = p.Client_().Call(ctx, "FallbackMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleDefaultValue) GetD() (v string) { + return p.D } -func (p *ExampleServiceClient) ApiBodyMethod(ctx context.Context, req *ExampleApiBody) (r *ExampleApiBody, err error) { - var _args ExampleServiceApiBodyMethodArgs - _args.Req = req - var _result ExampleServiceApiBodyMethodResult - if err = p.Client_().Call(ctx, "ApiBodyMethod", &_args, &_result); err != nil { - return +func (p *ExampleDefaultValue) String() string { + if p == nil { + return "" } - return _result.GetSuccess(), nil + return fmt.Sprintf("ExampleDefaultValue(%+v)", *p) } -func (p *ExampleServiceClient) PostFormMethod(ctx context.Context, req *ExamplePostForm) (r *ExamplePostForm, err error) { - var _args ExampleServicePostFormMethodArgs - _args.Req = req - var _result ExampleServicePostFormMethodResult - if err = p.Client_().Call(ctx, "PostFormMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +var fieldIDToName_ExampleDefaultValue = map[int16]string{ + 1: "A", + 2: "B", + 3: "C", + 4: "D", } -func (p *ExampleServiceClient) DynamicStructMethod(ctx context.Context, req *ExampleDynamicStruct) (r *ExampleDynamicStruct, err error) { - var _args ExampleServiceDynamicStructMethodArgs - _args.Req = req - var _result ExampleServiceDynamicStructMethodResult - if err = p.Client_().Call(ctx, "DynamicStructMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +type ExampleOptionalDefaultValue struct { + A string `thrift:"A,1,optional" json:"A,omitempty"` + B int32 `thrift:"B,2,required" json:"B"` + C float64 `thrift:"C,3,optional" json:"C,omitempty"` + D string `thrift:"D,4,required" json:"D"` + E *string `thrift:"E,5,optional" json:"E,omitempty"` + F *string `thrift:"F,6,optional" json:"F,omitempty"` } -func (p *ExampleServiceClient) Base64BinaryMethod(ctx context.Context, req *ExampleBase64Binary) (r *ExampleBase64Binary, err error) { - var _args ExampleServiceBase64BinaryMethodArgs - _args.Req = req - var _result ExampleServiceBase64BinaryMethodResult - if err = p.Client_().Call(ctx, "Base64BinaryMethod", &_args, &_result); err != nil { - return +func NewExampleOptionalDefaultValue() *ExampleOptionalDefaultValue { + return &ExampleOptionalDefaultValue{ + + A: "hello", + B: int32(ref.FOO_A), + C: 1.2, + D: ref.ConstString, } - return _result.GetSuccess(), nil } -func (p *ExampleServiceClient) DefaultValueMethod(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) { - var _args ExampleServiceDefaultValueMethodArgs - _args.Req = req - var _result ExampleServiceDefaultValueMethodResult - if err = p.Client_().Call(ctx, "DefaultValueMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleOptionalDefaultValue) InitDefault() { + p.A = "hello" + p.B = int32(ref.FOO_A) + p.C = 1.2 + p.D = ref.ConstString } -func (p *ExampleServiceClient) OptionalDefaultValueMethod(ctx context.Context, req *ExampleOptionalDefaultValue) (r *ExampleOptionalDefaultValue, err error) { - var _args ExampleServiceOptionalDefaultValueMethodArgs - _args.Req = req - var _result ExampleServiceOptionalDefaultValueMethodResult - if err = p.Client_().Call(ctx, "OptionalDefaultValueMethod", &_args, &_result); err != nil { - return +var ExampleOptionalDefaultValue_A_DEFAULT string = "hello" + +func (p *ExampleOptionalDefaultValue) GetA() (v string) { + if !p.IsSetA() { + return ExampleOptionalDefaultValue_A_DEFAULT } - return _result.GetSuccess(), nil + return p.A } -func (p *ExampleServiceClient) NoBodyStructMethod(ctx context.Context, req *ExampleNoBodyStruct) (r *ExampleNoBodyStruct, err error) { - var _args ExampleServiceNoBodyStructMethodArgs - _args.Req = req - var _result ExampleServiceNoBodyStructMethodResult - if err = p.Client_().Call(ctx, "NoBodyStructMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil +func (p *ExampleOptionalDefaultValue) GetB() (v int32) { + return p.B } -func (p *ExampleServiceClient) String(ctx context.Context, req string) (r string, err error) { - var _args ExampleServiceStringArgs - _args.Req = req - var _result ExampleServiceStringResult - if err = p.Client_().Call(ctx, "String", &_args, &_result); err != nil { - return +var ExampleOptionalDefaultValue_C_DEFAULT float64 = 1.2 + +func (p *ExampleOptionalDefaultValue) GetC() (v float64) { + if !p.IsSetC() { + return ExampleOptionalDefaultValue_C_DEFAULT } - return _result.GetSuccess(), nil + return p.C +} + +func (p *ExampleOptionalDefaultValue) GetD() (v string) { + return p.D } -func (p *ExampleServiceClient) I64(ctx context.Context, req int64) (r int64, err error) { - var _args ExampleServiceI64Args - _args.Req = req - var _result ExampleServiceI64Result - if err = p.Client_().Call(ctx, "I64", &_args, &_result); err != nil { - return +var ExampleOptionalDefaultValue_E_DEFAULT string + +func (p *ExampleOptionalDefaultValue) GetE() (v string) { + if !p.IsSetE() { + return ExampleOptionalDefaultValue_E_DEFAULT } - return _result.GetSuccess(), nil + return *p.E } -type ExampleServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ExampleService +var ExampleOptionalDefaultValue_F_DEFAULT string + +func (p *ExampleOptionalDefaultValue) GetF() (v string) { + if !p.IsSetF() { + return ExampleOptionalDefaultValue_F_DEFAULT + } + return *p.F } -func (p *ExampleServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor +func (p *ExampleOptionalDefaultValue) IsSetA() bool { + return p.A != ExampleOptionalDefaultValue_A_DEFAULT } -func (p *ExampleServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok +func (p *ExampleOptionalDefaultValue) IsSetC() bool { + return p.C != ExampleOptionalDefaultValue_C_DEFAULT } -func (p *ExampleServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap +func (p *ExampleOptionalDefaultValue) IsSetE() bool { + return p.E != nil } -func NewExampleServiceProcessor(handler ExampleService) *ExampleServiceProcessor { - self := &ExampleServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("ExampleMethod", &exampleServiceProcessorExampleMethod{handler: handler}) - self.AddToProcessorMap("ErrorMethod", &exampleServiceProcessorErrorMethod{handler: handler}) - self.AddToProcessorMap("Int2FloatMethod", &exampleServiceProcessorInt2FloatMethod{handler: handler}) - self.AddToProcessorMap("JSONStringMethod", &exampleServiceProcessorJSONStringMethod{handler: handler}) - self.AddToProcessorMap("PartialMethod", &exampleServiceProcessorPartialMethod{handler: handler}) - self.AddToProcessorMap("FallbackMethod", &exampleServiceProcessorFallbackMethod{handler: handler}) - self.AddToProcessorMap("ApiBodyMethod", &exampleServiceProcessorApiBodyMethod{handler: handler}) - self.AddToProcessorMap("PostFormMethod", &exampleServiceProcessorPostFormMethod{handler: handler}) - self.AddToProcessorMap("DynamicStructMethod", &exampleServiceProcessorDynamicStructMethod{handler: handler}) - self.AddToProcessorMap("Base64BinaryMethod", &exampleServiceProcessorBase64BinaryMethod{handler: handler}) - self.AddToProcessorMap("DefaultValueMethod", &exampleServiceProcessorDefaultValueMethod{handler: handler}) - self.AddToProcessorMap("OptionalDefaultValueMethod", &exampleServiceProcessorOptionalDefaultValueMethod{handler: handler}) - self.AddToProcessorMap("NoBodyStructMethod", &exampleServiceProcessorNoBodyStructMethod{handler: handler}) - self.AddToProcessorMap("String", &exampleServiceProcessorString{handler: handler}) - self.AddToProcessorMap("I64", &exampleServiceProcessorI64{handler: handler}) - return self +func (p *ExampleOptionalDefaultValue) IsSetF() bool { + return p.F != nil } -func (p *ExampleServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type exampleServiceProcessorExampleMethod struct { - handler ExampleService -} - -func (p *exampleServiceProcessorExampleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceExampleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceExampleMethodResult{} - var retval *ExampleResp - if retval, err2 = p.handler.ExampleMethod(ctx, args.Req); err2 != nil { - switch v := err2.(type) { - case *Exception: - result.Err = v - default: - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExampleMethod: "+err2.Error()) - oprot.WriteMessageBegin("ExampleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ExampleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *ExampleOptionalDefaultValue) String() string { + if p == nil { + return "" } - return true, err + return fmt.Sprintf("ExampleOptionalDefaultValue(%+v)", *p) } -type exampleServiceProcessorErrorMethod struct { - handler ExampleService +var fieldIDToName_ExampleOptionalDefaultValue = map[int16]string{ + 1: "A", + 2: "B", + 3: "C", + 4: "D", + 5: "E", + 6: "F", } -func (p *exampleServiceProcessorErrorMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceErrorMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ErrorMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +type ExampleNoBodyStruct struct { + NoBodyStruct *NoBodyStruct `thrift:"NoBodyStruct,1" json:"NoBodyStruct"` +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceErrorMethodResult{} - var retval *ExampleErrorResp - if retval, err2 = p.handler.ErrorMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ErrorMethod: "+err2.Error()) - oprot.WriteMessageBegin("ErrorMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ErrorMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +func NewExampleNoBodyStruct() *ExampleNoBodyStruct { + return &ExampleNoBodyStruct{} } -type exampleServiceProcessorInt2FloatMethod struct { - handler ExampleService +func (p *ExampleNoBodyStruct) InitDefault() { } -func (p *exampleServiceProcessorInt2FloatMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceInt2FloatMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Int2FloatMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +var ExampleNoBodyStruct_NoBodyStruct_DEFAULT *NoBodyStruct - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceInt2FloatMethodResult{} - var retval *ExampleInt2Float - if retval, err2 = p.handler.Int2FloatMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Int2FloatMethod: "+err2.Error()) - oprot.WriteMessageBegin("Int2FloatMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Int2FloatMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *ExampleNoBodyStruct) GetNoBodyStruct() (v *NoBodyStruct) { + if !p.IsSetNoBodyStruct() { + return ExampleNoBodyStruct_NoBodyStruct_DEFAULT } - return true, err + return p.NoBodyStruct } -type exampleServiceProcessorJSONStringMethod struct { - handler ExampleService +func (p *ExampleNoBodyStruct) IsSetNoBodyStruct() bool { + return p.NoBodyStruct != nil } -func (p *exampleServiceProcessorJSONStringMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceJSONStringMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("JSONStringMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err +func (p *ExampleNoBodyStruct) String() string { + if p == nil { + return "" } + return fmt.Sprintf("ExampleNoBodyStruct(%+v)", *p) +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceJSONStringMethodResult{} - var retval *ExampleJSONString - if retval, err2 = p.handler.JSONStringMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing JSONStringMethod: "+err2.Error()) - oprot.WriteMessageBegin("JSONStringMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("JSONStringMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +var fieldIDToName_ExampleNoBodyStruct = map[int16]string{ + 1: "NoBodyStruct", } -type exampleServiceProcessorPartialMethod struct { - handler ExampleService +type NoBodyStruct struct { + A *int32 `thrift:"A,1,optional" json:"A,omitempty"` + B *int32 `thrift:"B,2,optional" json:"B,omitempty"` + C int32 `thrift:"C,3,optional" json:"C,omitempty"` } -func (p *exampleServiceProcessorPartialMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServicePartialMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PartialMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +func NewNoBodyStruct() *NoBodyStruct { + return &NoBodyStruct{ - iprot.ReadMessageEnd() - var err2 error - result := ExampleServicePartialMethodResult{} - var retval *ExamplePartial - if retval, err2 = p.handler.PartialMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialMethod: "+err2.Error()) - oprot.WriteMessageBegin("PartialMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PartialMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return + C: 1, } - return true, err } -type exampleServiceProcessorFallbackMethod struct { - handler ExampleService +func (p *NoBodyStruct) InitDefault() { + p.C = 1 } -func (p *exampleServiceProcessorFallbackMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceFallbackMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("FallbackMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +var NoBodyStruct_A_DEFAULT int32 - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceFallbackMethodResult{} - var retval *ExampleFallback - if retval, err2 = p.handler.FallbackMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing FallbackMethod: "+err2.Error()) - oprot.WriteMessageBegin("FallbackMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("FallbackMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *NoBodyStruct) GetA() (v int32) { + if !p.IsSetA() { + return NoBodyStruct_A_DEFAULT } - return true, err + return *p.A } -type exampleServiceProcessorApiBodyMethod struct { - handler ExampleService -} +var NoBodyStruct_B_DEFAULT int32 -func (p *exampleServiceProcessorApiBodyMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceApiBodyMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("ApiBodyMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err +func (p *NoBodyStruct) GetB() (v int32) { + if !p.IsSetB() { + return NoBodyStruct_B_DEFAULT } + return *p.B +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceApiBodyMethodResult{} - var retval *ExampleApiBody - if retval, err2 = p.handler.ApiBodyMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ApiBodyMethod: "+err2.Error()) - oprot.WriteMessageBegin("ApiBodyMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("ApiBodyMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +var NoBodyStruct_C_DEFAULT int32 = 1 + +func (p *NoBodyStruct) GetC() (v int32) { + if !p.IsSetC() { + return NoBodyStruct_C_DEFAULT } - return true, err + return p.C } -type exampleServiceProcessorPostFormMethod struct { - handler ExampleService +func (p *NoBodyStruct) IsSetA() bool { + return p.A != nil } -func (p *exampleServiceProcessorPostFormMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServicePostFormMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PostFormMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := ExampleServicePostFormMethodResult{} - var retval *ExamplePostForm - if retval, err2 = p.handler.PostFormMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PostFormMethod: "+err2.Error()) - oprot.WriteMessageBegin("PostFormMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PostFormMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +func (p *NoBodyStruct) IsSetB() bool { + return p.B != nil } -type exampleServiceProcessorDynamicStructMethod struct { - handler ExampleService +func (p *NoBodyStruct) IsSetC() bool { + return p.C != NoBodyStruct_C_DEFAULT } -func (p *exampleServiceProcessorDynamicStructMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceDynamicStructMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DynamicStructMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err +func (p *NoBodyStruct) String() string { + if p == nil { + return "" } + return fmt.Sprintf("NoBodyStruct(%+v)", *p) +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceDynamicStructMethodResult{} - var retval *ExampleDynamicStruct - if retval, err2 = p.handler.DynamicStructMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DynamicStructMethod: "+err2.Error()) - oprot.WriteMessageBegin("DynamicStructMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DynamicStructMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +var fieldIDToName_NoBodyStruct = map[int16]string{ + 1: "A", + 2: "B", + 3: "C", } -type exampleServiceProcessorBase64BinaryMethod struct { - handler ExampleService +type Exception struct { + Code int32 `thrift:"code,1" json:"code"` + Msg string `thrift:"msg,255" json:"msg"` } -func (p *exampleServiceProcessorBase64BinaryMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceBase64BinaryMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Base64BinaryMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +func NewException() *Exception { + return &Exception{} +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceBase64BinaryMethodResult{} - var retval *ExampleBase64Binary - if retval, err2 = p.handler.Base64BinaryMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Base64BinaryMethod: "+err2.Error()) - oprot.WriteMessageBegin("Base64BinaryMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Base64BinaryMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err +func (p *Exception) InitDefault() { } -type exampleServiceProcessorDefaultValueMethod struct { - handler ExampleService +func (p *Exception) GetCode() (v int32) { + return p.Code } -func (p *exampleServiceProcessorDefaultValueMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceDefaultValueMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("DefaultValueMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +func (p *Exception) GetMsg() (v string) { + return p.Msg +} - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceDefaultValueMethodResult{} - var retval *ExampleDefaultValue - if retval, err2 = p.handler.DefaultValueMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DefaultValueMethod: "+err2.Error()) - oprot.WriteMessageBegin("DefaultValueMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("DefaultValueMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return +func (p *Exception) String() string { + if p == nil { + return "" } - return true, err + return fmt.Sprintf("Exception(%+v)", *p) +} +func (p *Exception) Error() string { + return p.String() } -type exampleServiceProcessorOptionalDefaultValueMethod struct { - handler ExampleService +var fieldIDToName_Exception = map[int16]string{ + 1: "code", + 255: "msg", } -func (p *exampleServiceProcessorOptionalDefaultValueMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceOptionalDefaultValueMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("OptionalDefaultValueMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } +type ExampleService interface { + ExampleMethod(ctx context.Context, req *ExampleReq) (r *ExampleResp, err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceOptionalDefaultValueMethodResult{} - var retval *ExampleOptionalDefaultValue - if retval, err2 = p.handler.OptionalDefaultValueMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing OptionalDefaultValueMethod: "+err2.Error()) - oprot.WriteMessageBegin("OptionalDefaultValueMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("OptionalDefaultValueMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} + ErrorMethod(ctx context.Context, req *ExampleError) (r *ExampleErrorResp, err error) -type exampleServiceProcessorNoBodyStructMethod struct { - handler ExampleService -} + Int2FloatMethod(ctx context.Context, req *ExampleInt2Float) (r *ExampleInt2Float, err error) -func (p *exampleServiceProcessorNoBodyStructMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceNoBodyStructMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("NoBodyStructMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } + JSONStringMethod(ctx context.Context, req *ExampleJSONString) (r *ExampleJSONString, err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceNoBodyStructMethodResult{} - var retval *ExampleNoBodyStruct - if retval, err2 = p.handler.NoBodyStructMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NoBodyStructMethod: "+err2.Error()) - oprot.WriteMessageBegin("NoBodyStructMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("NoBodyStructMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} + PartialMethod(ctx context.Context, req *ExamplePartial2) (r *ExamplePartial, err error) -type exampleServiceProcessorString struct { - handler ExampleService -} + FallbackMethod(ctx context.Context, req *ExampleFallback) (r *ExampleFallback, err error) -func (p *exampleServiceProcessorString) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceStringArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("String", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } + ApiBodyMethod(ctx context.Context, req *ExampleApiBody) (r *ExampleApiBody, err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceStringResult{} - var retval string - if retval, err2 = p.handler.String(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing String: "+err2.Error()) - oprot.WriteMessageBegin("String", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = &retval - } - if err2 = oprot.WriteMessageBegin("String", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} + PostFormMethod(ctx context.Context, req *ExamplePostForm) (r *ExamplePostForm, err error) -type exampleServiceProcessorI64 struct { - handler ExampleService -} + DynamicStructMethod(ctx context.Context, req *ExampleDynamicStruct) (r *ExampleDynamicStruct, err error) -func (p *exampleServiceProcessorI64) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ExampleServiceI64Args{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("I64", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } + Base64BinaryMethod(ctx context.Context, req *ExampleBase64Binary) (r *ExampleBase64Binary, err error) - iprot.ReadMessageEnd() - var err2 error - result := ExampleServiceI64Result{} - var retval int64 - if retval, err2 = p.handler.I64(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing I64: "+err2.Error()) - oprot.WriteMessageBegin("I64", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = &retval - } - if err2 = oprot.WriteMessageBegin("I64", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err + DefaultValueMethod(ctx context.Context, req *ExampleDefaultValue) (r *ExampleDefaultValue, err error) + + OptionalDefaultValueMethod(ctx context.Context, req *ExampleOptionalDefaultValue) (r *ExampleOptionalDefaultValue, err error) + + NoBodyStructMethod(ctx context.Context, req *ExampleNoBodyStruct) (r *ExampleNoBodyStruct, err error) + + String(ctx context.Context, req string) (r string, err error) + + I64(ctx context.Context, req int64) (r int64, err error) } type ExampleServiceExampleMethodArgs struct { @@ -10693,6 +1501,9 @@ func NewExampleServiceExampleMethodArgs() *ExampleServiceExampleMethodArgs { return &ExampleServiceExampleMethodArgs{} } +func (p *ExampleServiceExampleMethodArgs) InitDefault() { +} + var ExampleServiceExampleMethodArgs_Req_DEFAULT *ExampleReq func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { @@ -10701,131 +1512,11 @@ func (p *ExampleServiceExampleMethodArgs) GetReq() (v *ExampleReq) { } return p.Req } -func (p *ExampleServiceExampleMethodArgs) SetReq(val *ExampleReq) { - p.Req = val -} - -var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceExampleMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceExampleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleReq() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceExampleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceExampleMethodArgs) String() string { if p == nil { return "" @@ -10833,226 +1524,46 @@ func (p *ExampleServiceExampleMethodArgs) String() string { return fmt.Sprintf("ExampleServiceExampleMethodArgs(%+v)", *p) } -func (p *ExampleServiceExampleMethodArgs) DeepEqual(ano *ExampleServiceExampleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodArgs) Field1DeepEqual(src *ExampleReq) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceExampleMethodResult struct { - Success *ExampleResp `thrift:"success,0" json:"success,omitempty"` - Err *Exception `thrift:"err,1" json:"err,omitempty"` + Success *ExampleResp `thrift:"success,0,optional" json:"success,omitempty"` + Err *Exception `thrift:"err,1,optional" json:"err,omitempty"` } func NewExampleServiceExampleMethodResult() *ExampleServiceExampleMethodResult { return &ExampleServiceExampleMethodResult{} } -var ExampleServiceExampleMethodResult_Success_DEFAULT *ExampleResp - -func (p *ExampleServiceExampleMethodResult) GetSuccess() (v *ExampleResp) { - if !p.IsSetSuccess() { - return ExampleServiceExampleMethodResult_Success_DEFAULT - } - return p.Success -} - -var ExampleServiceExampleMethodResult_Err_DEFAULT *Exception - -func (p *ExampleServiceExampleMethodResult) GetErr() (v *Exception) { - if !p.IsSetErr() { - return ExampleServiceExampleMethodResult_Err_DEFAULT - } - return p.Err -} -func (p *ExampleServiceExampleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleResp) -} -func (p *ExampleServiceExampleMethodResult) SetErr(val *Exception) { - p.Err = val -} - -var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ - 0: "success", - 1: "err", -} - -func (p *ExampleServiceExampleMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ExampleServiceExampleMethodResult) IsSetErr() bool { - return p.Err != nil +func (p *ExampleServiceExampleMethodResult) InitDefault() { } -func (p *ExampleServiceExampleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var ExampleServiceExampleMethodResult_Success_DEFAULT *ExampleResp - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleResp() - if err := p.Success.Read(iprot); err != nil { - return err +func (p *ExampleServiceExampleMethodResult) GetSuccess() (v *ExampleResp) { + if !p.IsSetSuccess() { + return ExampleServiceExampleMethodResult_Success_DEFAULT } - return nil + return p.Success } -func (p *ExampleServiceExampleMethodResult) ReadField1(iprot thrift.TProtocol) error { - p.Err = NewException() - if err := p.Err.Read(iprot); err != nil { - return err +var ExampleServiceExampleMethodResult_Err_DEFAULT *Exception + +func (p *ExampleServiceExampleMethodResult) GetErr() (v *Exception) { + if !p.IsSetErr() { + return ExampleServiceExampleMethodResult_Err_DEFAULT } - return nil + return p.Err } -func (p *ExampleServiceExampleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ExampleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } +func (p *ExampleServiceExampleMethodResult) IsSetSuccess() bool { + return p.Success != nil +} - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *ExampleServiceExampleMethodResult) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetErr() { - if err = oprot.WriteFieldBegin("err", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Err.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceExampleMethodResult) IsSetErr() bool { + return p.Err != nil } func (p *ExampleServiceExampleMethodResult) String() string { @@ -11062,34 +1573,9 @@ func (p *ExampleServiceExampleMethodResult) String() string { return fmt.Sprintf("ExampleServiceExampleMethodResult(%+v)", *p) } -func (p *ExampleServiceExampleMethodResult) DeepEqual(ano *ExampleServiceExampleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - if !p.Field1DeepEqual(ano.Err) { - return false - } - return true -} - -func (p *ExampleServiceExampleMethodResult) Field0DeepEqual(src *ExampleResp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} -func (p *ExampleServiceExampleMethodResult) Field1DeepEqual(src *Exception) bool { - - if !p.Err.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceExampleMethodResult = map[int16]string{ + 0: "success", + 1: "err", } type ExampleServiceErrorMethodArgs struct { @@ -11100,6 +1586,9 @@ func NewExampleServiceErrorMethodArgs() *ExampleServiceErrorMethodArgs { return &ExampleServiceErrorMethodArgs{} } +func (p *ExampleServiceErrorMethodArgs) InitDefault() { +} + var ExampleServiceErrorMethodArgs_Req_DEFAULT *ExampleError func (p *ExampleServiceErrorMethodArgs) GetReq() (v *ExampleError) { @@ -11108,131 +1597,11 @@ func (p *ExampleServiceErrorMethodArgs) GetReq() (v *ExampleError) { } return p.Req } -func (p *ExampleServiceErrorMethodArgs) SetReq(val *ExampleError) { - p.Req = val -} - -var fieldIDToName_ExampleServiceErrorMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceErrorMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceErrorMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceErrorMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceErrorMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleError() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceErrorMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ErrorMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceErrorMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceErrorMethodArgs) String() string { if p == nil { return "" @@ -11240,34 +1609,21 @@ func (p *ExampleServiceErrorMethodArgs) String() string { return fmt.Sprintf("ExampleServiceErrorMethodArgs(%+v)", *p) } -func (p *ExampleServiceErrorMethodArgs) DeepEqual(ano *ExampleServiceErrorMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceErrorMethodArgs) Field1DeepEqual(src *ExampleError) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceErrorMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceErrorMethodResult struct { - Success *ExampleErrorResp `thrift:"success,0" json:"success,omitempty"` + Success *ExampleErrorResp `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceErrorMethodResult() *ExampleServiceErrorMethodResult { return &ExampleServiceErrorMethodResult{} } +func (p *ExampleServiceErrorMethodResult) InitDefault() { +} + var ExampleServiceErrorMethodResult_Success_DEFAULT *ExampleErrorResp func (p *ExampleServiceErrorMethodResult) GetSuccess() (v *ExampleErrorResp) { @@ -11276,133 +1632,11 @@ func (p *ExampleServiceErrorMethodResult) GetSuccess() (v *ExampleErrorResp) { } return p.Success } -func (p *ExampleServiceErrorMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleErrorResp) -} - -var fieldIDToName_ExampleServiceErrorMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceErrorMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceErrorMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceErrorMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceErrorMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleErrorResp() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceErrorMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ErrorMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceErrorMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceErrorMethodResult) String() string { if p == nil { return "" @@ -11410,24 +1644,8 @@ func (p *ExampleServiceErrorMethodResult) String() string { return fmt.Sprintf("ExampleServiceErrorMethodResult(%+v)", *p) } -func (p *ExampleServiceErrorMethodResult) DeepEqual(ano *ExampleServiceErrorMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceErrorMethodResult) Field0DeepEqual(src *ExampleErrorResp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceErrorMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceInt2FloatMethodArgs struct { @@ -11438,6 +1656,9 @@ func NewExampleServiceInt2FloatMethodArgs() *ExampleServiceInt2FloatMethodArgs { return &ExampleServiceInt2FloatMethodArgs{} } +func (p *ExampleServiceInt2FloatMethodArgs) InitDefault() { +} + var ExampleServiceInt2FloatMethodArgs_Req_DEFAULT *ExampleInt2Float func (p *ExampleServiceInt2FloatMethodArgs) GetReq() (v *ExampleInt2Float) { @@ -11446,131 +1667,11 @@ func (p *ExampleServiceInt2FloatMethodArgs) GetReq() (v *ExampleInt2Float) { } return p.Req } -func (p *ExampleServiceInt2FloatMethodArgs) SetReq(val *ExampleInt2Float) { - p.Req = val -} - -var fieldIDToName_ExampleServiceInt2FloatMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceInt2FloatMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceInt2FloatMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceInt2FloatMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceInt2FloatMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleInt2Float() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceInt2FloatMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Int2FloatMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceInt2FloatMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceInt2FloatMethodArgs) String() string { if p == nil { return "" @@ -11578,34 +1679,21 @@ func (p *ExampleServiceInt2FloatMethodArgs) String() string { return fmt.Sprintf("ExampleServiceInt2FloatMethodArgs(%+v)", *p) } -func (p *ExampleServiceInt2FloatMethodArgs) DeepEqual(ano *ExampleServiceInt2FloatMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceInt2FloatMethodArgs) Field1DeepEqual(src *ExampleInt2Float) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceInt2FloatMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceInt2FloatMethodResult struct { - Success *ExampleInt2Float `thrift:"success,0" json:"success,omitempty"` + Success *ExampleInt2Float `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceInt2FloatMethodResult() *ExampleServiceInt2FloatMethodResult { return &ExampleServiceInt2FloatMethodResult{} } +func (p *ExampleServiceInt2FloatMethodResult) InitDefault() { +} + var ExampleServiceInt2FloatMethodResult_Success_DEFAULT *ExampleInt2Float func (p *ExampleServiceInt2FloatMethodResult) GetSuccess() (v *ExampleInt2Float) { @@ -11614,133 +1702,11 @@ func (p *ExampleServiceInt2FloatMethodResult) GetSuccess() (v *ExampleInt2Float) } return p.Success } -func (p *ExampleServiceInt2FloatMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleInt2Float) -} - -var fieldIDToName_ExampleServiceInt2FloatMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceInt2FloatMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceInt2FloatMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceInt2FloatMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceInt2FloatMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleInt2Float() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceInt2FloatMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Int2FloatMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceInt2FloatMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceInt2FloatMethodResult) String() string { if p == nil { return "" @@ -11748,24 +1714,8 @@ func (p *ExampleServiceInt2FloatMethodResult) String() string { return fmt.Sprintf("ExampleServiceInt2FloatMethodResult(%+v)", *p) } -func (p *ExampleServiceInt2FloatMethodResult) DeepEqual(ano *ExampleServiceInt2FloatMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceInt2FloatMethodResult) Field0DeepEqual(src *ExampleInt2Float) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceInt2FloatMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceJSONStringMethodArgs struct { @@ -11776,6 +1726,9 @@ func NewExampleServiceJSONStringMethodArgs() *ExampleServiceJSONStringMethodArgs return &ExampleServiceJSONStringMethodArgs{} } +func (p *ExampleServiceJSONStringMethodArgs) InitDefault() { +} + var ExampleServiceJSONStringMethodArgs_Req_DEFAULT *ExampleJSONString func (p *ExampleServiceJSONStringMethodArgs) GetReq() (v *ExampleJSONString) { @@ -11784,131 +1737,11 @@ func (p *ExampleServiceJSONStringMethodArgs) GetReq() (v *ExampleJSONString) { } return p.Req } -func (p *ExampleServiceJSONStringMethodArgs) SetReq(val *ExampleJSONString) { - p.Req = val -} - -var fieldIDToName_ExampleServiceJSONStringMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceJSONStringMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceJSONStringMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceJSONStringMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceJSONStringMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleJSONString() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceJSONStringMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("JSONStringMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceJSONStringMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceJSONStringMethodArgs) String() string { if p == nil { return "" @@ -11916,34 +1749,21 @@ func (p *ExampleServiceJSONStringMethodArgs) String() string { return fmt.Sprintf("ExampleServiceJSONStringMethodArgs(%+v)", *p) } -func (p *ExampleServiceJSONStringMethodArgs) DeepEqual(ano *ExampleServiceJSONStringMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceJSONStringMethodArgs) Field1DeepEqual(src *ExampleJSONString) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceJSONStringMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceJSONStringMethodResult struct { - Success *ExampleJSONString `thrift:"success,0" json:"success,omitempty"` + Success *ExampleJSONString `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceJSONStringMethodResult() *ExampleServiceJSONStringMethodResult { return &ExampleServiceJSONStringMethodResult{} } +func (p *ExampleServiceJSONStringMethodResult) InitDefault() { +} + var ExampleServiceJSONStringMethodResult_Success_DEFAULT *ExampleJSONString func (p *ExampleServiceJSONStringMethodResult) GetSuccess() (v *ExampleJSONString) { @@ -11952,133 +1772,11 @@ func (p *ExampleServiceJSONStringMethodResult) GetSuccess() (v *ExampleJSONStrin } return p.Success } -func (p *ExampleServiceJSONStringMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleJSONString) -} - -var fieldIDToName_ExampleServiceJSONStringMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceJSONStringMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceJSONStringMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceJSONStringMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceJSONStringMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleJSONString() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceJSONStringMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("JSONStringMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceJSONStringMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceJSONStringMethodResult) String() string { if p == nil { return "" @@ -12086,24 +1784,8 @@ func (p *ExampleServiceJSONStringMethodResult) String() string { return fmt.Sprintf("ExampleServiceJSONStringMethodResult(%+v)", *p) } -func (p *ExampleServiceJSONStringMethodResult) DeepEqual(ano *ExampleServiceJSONStringMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceJSONStringMethodResult) Field0DeepEqual(src *ExampleJSONString) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceJSONStringMethodResult = map[int16]string{ + 0: "success", } type ExampleServicePartialMethodArgs struct { @@ -12114,137 +1796,20 @@ func NewExampleServicePartialMethodArgs() *ExampleServicePartialMethodArgs { return &ExampleServicePartialMethodArgs{} } -var ExampleServicePartialMethodArgs_Req_DEFAULT *ExamplePartial2 - -func (p *ExampleServicePartialMethodArgs) GetReq() (v *ExamplePartial2) { - if !p.IsSetReq() { - return ExampleServicePartialMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *ExampleServicePartialMethodArgs) SetReq(val *ExamplePartial2) { - p.Req = val -} - -var fieldIDToName_ExampleServicePartialMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *ExampleServicePartialMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *ExampleServicePartialMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } +func (p *ExampleServicePartialMethodArgs) InitDefault() { +} - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } +var ExampleServicePartialMethodArgs_Req_DEFAULT *ExamplePartial2 - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePartialMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePartialMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExamplePartial2() - if err := p.Req.Read(iprot); err != nil { - return err +func (p *ExampleServicePartialMethodArgs) GetReq() (v *ExamplePartial2) { + if !p.IsSetReq() { + return ExampleServicePartialMethodArgs_Req_DEFAULT } - return nil + return p.Req } -func (p *ExampleServicePartialMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePartialMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServicePartialMethodArgs) IsSetReq() bool { + return p.Req != nil } func (p *ExampleServicePartialMethodArgs) String() string { @@ -12254,34 +1819,21 @@ func (p *ExampleServicePartialMethodArgs) String() string { return fmt.Sprintf("ExampleServicePartialMethodArgs(%+v)", *p) } -func (p *ExampleServicePartialMethodArgs) DeepEqual(ano *ExampleServicePartialMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServicePartialMethodArgs) Field1DeepEqual(src *ExamplePartial2) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServicePartialMethodArgs = map[int16]string{ + 1: "req", } type ExampleServicePartialMethodResult struct { - Success *ExamplePartial `thrift:"success,0" json:"success,omitempty"` + Success *ExamplePartial `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServicePartialMethodResult() *ExampleServicePartialMethodResult { return &ExampleServicePartialMethodResult{} } +func (p *ExampleServicePartialMethodResult) InitDefault() { +} + var ExampleServicePartialMethodResult_Success_DEFAULT *ExamplePartial func (p *ExampleServicePartialMethodResult) GetSuccess() (v *ExamplePartial) { @@ -12290,133 +1842,11 @@ func (p *ExampleServicePartialMethodResult) GetSuccess() (v *ExamplePartial) { } return p.Success } -func (p *ExampleServicePartialMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExamplePartial) -} - -var fieldIDToName_ExampleServicePartialMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServicePartialMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServicePartialMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePartialMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePartialMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExamplePartial() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServicePartialMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePartialMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServicePartialMethodResult) String() string { if p == nil { return "" @@ -12424,24 +1854,8 @@ func (p *ExampleServicePartialMethodResult) String() string { return fmt.Sprintf("ExampleServicePartialMethodResult(%+v)", *p) } -func (p *ExampleServicePartialMethodResult) DeepEqual(ano *ExampleServicePartialMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServicePartialMethodResult) Field0DeepEqual(src *ExamplePartial) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServicePartialMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceFallbackMethodArgs struct { @@ -12452,6 +1866,9 @@ func NewExampleServiceFallbackMethodArgs() *ExampleServiceFallbackMethodArgs { return &ExampleServiceFallbackMethodArgs{} } +func (p *ExampleServiceFallbackMethodArgs) InitDefault() { +} + var ExampleServiceFallbackMethodArgs_Req_DEFAULT *ExampleFallback func (p *ExampleServiceFallbackMethodArgs) GetReq() (v *ExampleFallback) { @@ -12460,131 +1877,11 @@ func (p *ExampleServiceFallbackMethodArgs) GetReq() (v *ExampleFallback) { } return p.Req } -func (p *ExampleServiceFallbackMethodArgs) SetReq(val *ExampleFallback) { - p.Req = val -} - -var fieldIDToName_ExampleServiceFallbackMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceFallbackMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceFallbackMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFallbackMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFallbackMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleFallback() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFallbackMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("FallbackMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFallbackMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceFallbackMethodArgs) String() string { if p == nil { return "" @@ -12592,34 +1889,21 @@ func (p *ExampleServiceFallbackMethodArgs) String() string { return fmt.Sprintf("ExampleServiceFallbackMethodArgs(%+v)", *p) } -func (p *ExampleServiceFallbackMethodArgs) DeepEqual(ano *ExampleServiceFallbackMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceFallbackMethodArgs) Field1DeepEqual(src *ExampleFallback) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFallbackMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceFallbackMethodResult struct { - Success *ExampleFallback `thrift:"success,0" json:"success,omitempty"` + Success *ExampleFallback `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceFallbackMethodResult() *ExampleServiceFallbackMethodResult { return &ExampleServiceFallbackMethodResult{} } +func (p *ExampleServiceFallbackMethodResult) InitDefault() { +} + var ExampleServiceFallbackMethodResult_Success_DEFAULT *ExampleFallback func (p *ExampleServiceFallbackMethodResult) GetSuccess() (v *ExampleFallback) { @@ -12628,133 +1912,11 @@ func (p *ExampleServiceFallbackMethodResult) GetSuccess() (v *ExampleFallback) { } return p.Success } -func (p *ExampleServiceFallbackMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleFallback) -} - -var fieldIDToName_ExampleServiceFallbackMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceFallbackMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceFallbackMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFallbackMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceFallbackMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleFallback() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceFallbackMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("FallbackMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceFallbackMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceFallbackMethodResult) String() string { if p == nil { return "" @@ -12762,24 +1924,8 @@ func (p *ExampleServiceFallbackMethodResult) String() string { return fmt.Sprintf("ExampleServiceFallbackMethodResult(%+v)", *p) } -func (p *ExampleServiceFallbackMethodResult) DeepEqual(ano *ExampleServiceFallbackMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceFallbackMethodResult) Field0DeepEqual(src *ExampleFallback) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceFallbackMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceApiBodyMethodArgs struct { @@ -12790,6 +1936,9 @@ func NewExampleServiceApiBodyMethodArgs() *ExampleServiceApiBodyMethodArgs { return &ExampleServiceApiBodyMethodArgs{} } +func (p *ExampleServiceApiBodyMethodArgs) InitDefault() { +} + var ExampleServiceApiBodyMethodArgs_Req_DEFAULT *ExampleApiBody func (p *ExampleServiceApiBodyMethodArgs) GetReq() (v *ExampleApiBody) { @@ -12798,131 +1947,11 @@ func (p *ExampleServiceApiBodyMethodArgs) GetReq() (v *ExampleApiBody) { } return p.Req } -func (p *ExampleServiceApiBodyMethodArgs) SetReq(val *ExampleApiBody) { - p.Req = val -} - -var fieldIDToName_ExampleServiceApiBodyMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceApiBodyMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceApiBodyMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceApiBodyMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceApiBodyMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleApiBody() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceApiBodyMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ApiBodyMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceApiBodyMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceApiBodyMethodArgs) String() string { if p == nil { return "" @@ -12930,34 +1959,21 @@ func (p *ExampleServiceApiBodyMethodArgs) String() string { return fmt.Sprintf("ExampleServiceApiBodyMethodArgs(%+v)", *p) } -func (p *ExampleServiceApiBodyMethodArgs) DeepEqual(ano *ExampleServiceApiBodyMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceApiBodyMethodArgs) Field1DeepEqual(src *ExampleApiBody) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceApiBodyMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceApiBodyMethodResult struct { - Success *ExampleApiBody `thrift:"success,0" json:"success,omitempty"` + Success *ExampleApiBody `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceApiBodyMethodResult() *ExampleServiceApiBodyMethodResult { return &ExampleServiceApiBodyMethodResult{} } +func (p *ExampleServiceApiBodyMethodResult) InitDefault() { +} + var ExampleServiceApiBodyMethodResult_Success_DEFAULT *ExampleApiBody func (p *ExampleServiceApiBodyMethodResult) GetSuccess() (v *ExampleApiBody) { @@ -12966,133 +1982,11 @@ func (p *ExampleServiceApiBodyMethodResult) GetSuccess() (v *ExampleApiBody) { } return p.Success } -func (p *ExampleServiceApiBodyMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleApiBody) -} - -var fieldIDToName_ExampleServiceApiBodyMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceApiBodyMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceApiBodyMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceApiBodyMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceApiBodyMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleApiBody() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceApiBodyMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("ApiBodyMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceApiBodyMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceApiBodyMethodResult) String() string { if p == nil { return "" @@ -13100,24 +1994,8 @@ func (p *ExampleServiceApiBodyMethodResult) String() string { return fmt.Sprintf("ExampleServiceApiBodyMethodResult(%+v)", *p) } -func (p *ExampleServiceApiBodyMethodResult) DeepEqual(ano *ExampleServiceApiBodyMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceApiBodyMethodResult) Field0DeepEqual(src *ExampleApiBody) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceApiBodyMethodResult = map[int16]string{ + 0: "success", } type ExampleServicePostFormMethodArgs struct { @@ -13128,6 +2006,9 @@ func NewExampleServicePostFormMethodArgs() *ExampleServicePostFormMethodArgs { return &ExampleServicePostFormMethodArgs{} } +func (p *ExampleServicePostFormMethodArgs) InitDefault() { +} + var ExampleServicePostFormMethodArgs_Req_DEFAULT *ExamplePostForm func (p *ExampleServicePostFormMethodArgs) GetReq() (v *ExamplePostForm) { @@ -13136,131 +2017,11 @@ func (p *ExampleServicePostFormMethodArgs) GetReq() (v *ExamplePostForm) { } return p.Req } -func (p *ExampleServicePostFormMethodArgs) SetReq(val *ExamplePostForm) { - p.Req = val -} - -var fieldIDToName_ExampleServicePostFormMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServicePostFormMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServicePostFormMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePostFormMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePostFormMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExamplePostForm() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServicePostFormMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PostFormMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePostFormMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServicePostFormMethodArgs) String() string { if p == nil { return "" @@ -13268,167 +2029,32 @@ func (p *ExampleServicePostFormMethodArgs) String() string { return fmt.Sprintf("ExampleServicePostFormMethodArgs(%+v)", *p) } -func (p *ExampleServicePostFormMethodArgs) DeepEqual(ano *ExampleServicePostFormMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServicePostFormMethodArgs) Field1DeepEqual(src *ExamplePostForm) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServicePostFormMethodArgs = map[int16]string{ + 1: "req", } type ExampleServicePostFormMethodResult struct { - Success *ExamplePostForm `thrift:"success,0" json:"success,omitempty"` + Success *ExamplePostForm `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServicePostFormMethodResult() *ExampleServicePostFormMethodResult { return &ExampleServicePostFormMethodResult{} } +func (p *ExampleServicePostFormMethodResult) InitDefault() { +} + var ExampleServicePostFormMethodResult_Success_DEFAULT *ExamplePostForm func (p *ExampleServicePostFormMethodResult) GetSuccess() (v *ExamplePostForm) { if !p.IsSetSuccess() { - return ExampleServicePostFormMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *ExampleServicePostFormMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExamplePostForm) -} - -var fieldIDToName_ExampleServicePostFormMethodResult = map[int16]string{ - 0: "success", -} - -func (p *ExampleServicePostFormMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ExampleServicePostFormMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePostFormMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServicePostFormMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExamplePostForm() - if err := p.Success.Read(iprot); err != nil { - return err + return ExampleServicePostFormMethodResult_Success_DEFAULT } - return nil + return p.Success } -func (p *ExampleServicePostFormMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PostFormMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServicePostFormMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +func (p *ExampleServicePostFormMethodResult) IsSetSuccess() bool { + return p.Success != nil } func (p *ExampleServicePostFormMethodResult) String() string { @@ -13438,24 +2064,8 @@ func (p *ExampleServicePostFormMethodResult) String() string { return fmt.Sprintf("ExampleServicePostFormMethodResult(%+v)", *p) } -func (p *ExampleServicePostFormMethodResult) DeepEqual(ano *ExampleServicePostFormMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServicePostFormMethodResult) Field0DeepEqual(src *ExamplePostForm) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServicePostFormMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceDynamicStructMethodArgs struct { @@ -13466,6 +2076,9 @@ func NewExampleServiceDynamicStructMethodArgs() *ExampleServiceDynamicStructMeth return &ExampleServiceDynamicStructMethodArgs{} } +func (p *ExampleServiceDynamicStructMethodArgs) InitDefault() { +} + var ExampleServiceDynamicStructMethodArgs_Req_DEFAULT *ExampleDynamicStruct func (p *ExampleServiceDynamicStructMethodArgs) GetReq() (v *ExampleDynamicStruct) { @@ -13474,131 +2087,11 @@ func (p *ExampleServiceDynamicStructMethodArgs) GetReq() (v *ExampleDynamicStruc } return p.Req } -func (p *ExampleServiceDynamicStructMethodArgs) SetReq(val *ExampleDynamicStruct) { - p.Req = val -} - -var fieldIDToName_ExampleServiceDynamicStructMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceDynamicStructMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceDynamicStructMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDynamicStructMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceDynamicStructMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleDynamicStruct() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceDynamicStructMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("DynamicStructMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceDynamicStructMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceDynamicStructMethodArgs) String() string { if p == nil { return "" @@ -13606,34 +2099,21 @@ func (p *ExampleServiceDynamicStructMethodArgs) String() string { return fmt.Sprintf("ExampleServiceDynamicStructMethodArgs(%+v)", *p) } -func (p *ExampleServiceDynamicStructMethodArgs) DeepEqual(ano *ExampleServiceDynamicStructMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceDynamicStructMethodArgs) Field1DeepEqual(src *ExampleDynamicStruct) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceDynamicStructMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceDynamicStructMethodResult struct { - Success *ExampleDynamicStruct `thrift:"success,0" json:"success,omitempty"` + Success *ExampleDynamicStruct `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceDynamicStructMethodResult() *ExampleServiceDynamicStructMethodResult { return &ExampleServiceDynamicStructMethodResult{} } +func (p *ExampleServiceDynamicStructMethodResult) InitDefault() { +} + var ExampleServiceDynamicStructMethodResult_Success_DEFAULT *ExampleDynamicStruct func (p *ExampleServiceDynamicStructMethodResult) GetSuccess() (v *ExampleDynamicStruct) { @@ -13642,133 +2122,11 @@ func (p *ExampleServiceDynamicStructMethodResult) GetSuccess() (v *ExampleDynami } return p.Success } -func (p *ExampleServiceDynamicStructMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleDynamicStruct) -} - -var fieldIDToName_ExampleServiceDynamicStructMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceDynamicStructMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceDynamicStructMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDynamicStructMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceDynamicStructMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleDynamicStruct() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceDynamicStructMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("DynamicStructMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceDynamicStructMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceDynamicStructMethodResult) String() string { if p == nil { return "" @@ -13776,24 +2134,8 @@ func (p *ExampleServiceDynamicStructMethodResult) String() string { return fmt.Sprintf("ExampleServiceDynamicStructMethodResult(%+v)", *p) } -func (p *ExampleServiceDynamicStructMethodResult) DeepEqual(ano *ExampleServiceDynamicStructMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceDynamicStructMethodResult) Field0DeepEqual(src *ExampleDynamicStruct) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceDynamicStructMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceBase64BinaryMethodArgs struct { @@ -13804,6 +2146,9 @@ func NewExampleServiceBase64BinaryMethodArgs() *ExampleServiceBase64BinaryMethod return &ExampleServiceBase64BinaryMethodArgs{} } +func (p *ExampleServiceBase64BinaryMethodArgs) InitDefault() { +} + var ExampleServiceBase64BinaryMethodArgs_Req_DEFAULT *ExampleBase64Binary func (p *ExampleServiceBase64BinaryMethodArgs) GetReq() (v *ExampleBase64Binary) { @@ -13812,131 +2157,11 @@ func (p *ExampleServiceBase64BinaryMethodArgs) GetReq() (v *ExampleBase64Binary) } return p.Req } -func (p *ExampleServiceBase64BinaryMethodArgs) SetReq(val *ExampleBase64Binary) { - p.Req = val -} - -var fieldIDToName_ExampleServiceBase64BinaryMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceBase64BinaryMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceBase64BinaryMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceBase64BinaryMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceBase64BinaryMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleBase64Binary() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceBase64BinaryMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Base64BinaryMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceBase64BinaryMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceBase64BinaryMethodArgs) String() string { if p == nil { return "" @@ -13944,34 +2169,21 @@ func (p *ExampleServiceBase64BinaryMethodArgs) String() string { return fmt.Sprintf("ExampleServiceBase64BinaryMethodArgs(%+v)", *p) } -func (p *ExampleServiceBase64BinaryMethodArgs) DeepEqual(ano *ExampleServiceBase64BinaryMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceBase64BinaryMethodArgs) Field1DeepEqual(src *ExampleBase64Binary) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceBase64BinaryMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceBase64BinaryMethodResult struct { - Success *ExampleBase64Binary `thrift:"success,0" json:"success,omitempty"` + Success *ExampleBase64Binary `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceBase64BinaryMethodResult() *ExampleServiceBase64BinaryMethodResult { return &ExampleServiceBase64BinaryMethodResult{} } +func (p *ExampleServiceBase64BinaryMethodResult) InitDefault() { +} + var ExampleServiceBase64BinaryMethodResult_Success_DEFAULT *ExampleBase64Binary func (p *ExampleServiceBase64BinaryMethodResult) GetSuccess() (v *ExampleBase64Binary) { @@ -13980,133 +2192,11 @@ func (p *ExampleServiceBase64BinaryMethodResult) GetSuccess() (v *ExampleBase64B } return p.Success } -func (p *ExampleServiceBase64BinaryMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleBase64Binary) -} - -var fieldIDToName_ExampleServiceBase64BinaryMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceBase64BinaryMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceBase64BinaryMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceBase64BinaryMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceBase64BinaryMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleBase64Binary() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceBase64BinaryMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Base64BinaryMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceBase64BinaryMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceBase64BinaryMethodResult) String() string { if p == nil { return "" @@ -14114,24 +2204,8 @@ func (p *ExampleServiceBase64BinaryMethodResult) String() string { return fmt.Sprintf("ExampleServiceBase64BinaryMethodResult(%+v)", *p) } -func (p *ExampleServiceBase64BinaryMethodResult) DeepEqual(ano *ExampleServiceBase64BinaryMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceBase64BinaryMethodResult) Field0DeepEqual(src *ExampleBase64Binary) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceBase64BinaryMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceDefaultValueMethodArgs struct { @@ -14142,6 +2216,9 @@ func NewExampleServiceDefaultValueMethodArgs() *ExampleServiceDefaultValueMethod return &ExampleServiceDefaultValueMethodArgs{} } +func (p *ExampleServiceDefaultValueMethodArgs) InitDefault() { +} + var ExampleServiceDefaultValueMethodArgs_Req_DEFAULT *ExampleDefaultValue func (p *ExampleServiceDefaultValueMethodArgs) GetReq() (v *ExampleDefaultValue) { @@ -14150,131 +2227,11 @@ func (p *ExampleServiceDefaultValueMethodArgs) GetReq() (v *ExampleDefaultValue) } return p.Req } -func (p *ExampleServiceDefaultValueMethodArgs) SetReq(val *ExampleDefaultValue) { - p.Req = val -} - -var fieldIDToName_ExampleServiceDefaultValueMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceDefaultValueMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceDefaultValueMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDefaultValueMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceDefaultValueMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleDefaultValue() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceDefaultValueMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("DefaultValueMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceDefaultValueMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceDefaultValueMethodArgs) String() string { if p == nil { return "" @@ -14282,34 +2239,21 @@ func (p *ExampleServiceDefaultValueMethodArgs) String() string { return fmt.Sprintf("ExampleServiceDefaultValueMethodArgs(%+v)", *p) } -func (p *ExampleServiceDefaultValueMethodArgs) DeepEqual(ano *ExampleServiceDefaultValueMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceDefaultValueMethodArgs) Field1DeepEqual(src *ExampleDefaultValue) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceDefaultValueMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceDefaultValueMethodResult struct { - Success *ExampleDefaultValue `thrift:"success,0" json:"success,omitempty"` + Success *ExampleDefaultValue `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceDefaultValueMethodResult() *ExampleServiceDefaultValueMethodResult { return &ExampleServiceDefaultValueMethodResult{} } +func (p *ExampleServiceDefaultValueMethodResult) InitDefault() { +} + var ExampleServiceDefaultValueMethodResult_Success_DEFAULT *ExampleDefaultValue func (p *ExampleServiceDefaultValueMethodResult) GetSuccess() (v *ExampleDefaultValue) { @@ -14318,133 +2262,11 @@ func (p *ExampleServiceDefaultValueMethodResult) GetSuccess() (v *ExampleDefault } return p.Success } -func (p *ExampleServiceDefaultValueMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleDefaultValue) -} - -var fieldIDToName_ExampleServiceDefaultValueMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceDefaultValueMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceDefaultValueMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDefaultValueMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceDefaultValueMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleDefaultValue() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceDefaultValueMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("DefaultValueMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceDefaultValueMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceDefaultValueMethodResult) String() string { if p == nil { return "" @@ -14452,24 +2274,8 @@ func (p *ExampleServiceDefaultValueMethodResult) String() string { return fmt.Sprintf("ExampleServiceDefaultValueMethodResult(%+v)", *p) } -func (p *ExampleServiceDefaultValueMethodResult) DeepEqual(ano *ExampleServiceDefaultValueMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceDefaultValueMethodResult) Field0DeepEqual(src *ExampleDefaultValue) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceDefaultValueMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceOptionalDefaultValueMethodArgs struct { @@ -14480,137 +2286,20 @@ func NewExampleServiceOptionalDefaultValueMethodArgs() *ExampleServiceOptionalDe return &ExampleServiceOptionalDefaultValueMethodArgs{} } -var ExampleServiceOptionalDefaultValueMethodArgs_Req_DEFAULT *ExampleOptionalDefaultValue - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) GetReq() (v *ExampleOptionalDefaultValue) { - if !p.IsSetReq() { - return ExampleServiceOptionalDefaultValueMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *ExampleServiceOptionalDefaultValueMethodArgs) SetReq(val *ExampleOptionalDefaultValue) { - p.Req = val -} - -var fieldIDToName_ExampleServiceOptionalDefaultValueMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOptionalDefaultValueMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleOptionalDefaultValue() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil +func (p *ExampleServiceOptionalDefaultValueMethodArgs) InitDefault() { } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("OptionalDefaultValueMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError +var ExampleServiceOptionalDefaultValueMethodArgs_Req_DEFAULT *ExampleOptionalDefaultValue + +func (p *ExampleServiceOptionalDefaultValueMethodArgs) GetReq() (v *ExampleOptionalDefaultValue) { + if !p.IsSetReq() { + return ExampleServiceOptionalDefaultValueMethodArgs_Req_DEFAULT } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) + return p.Req +} + +func (p *ExampleServiceOptionalDefaultValueMethodArgs) IsSetReq() bool { + return p.Req != nil } func (p *ExampleServiceOptionalDefaultValueMethodArgs) String() string { @@ -14620,34 +2309,21 @@ func (p *ExampleServiceOptionalDefaultValueMethodArgs) String() string { return fmt.Sprintf("ExampleServiceOptionalDefaultValueMethodArgs(%+v)", *p) } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) DeepEqual(ano *ExampleServiceOptionalDefaultValueMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) Field1DeepEqual(src *ExampleOptionalDefaultValue) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceOptionalDefaultValueMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceOptionalDefaultValueMethodResult struct { - Success *ExampleOptionalDefaultValue `thrift:"success,0" json:"success,omitempty"` + Success *ExampleOptionalDefaultValue `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceOptionalDefaultValueMethodResult() *ExampleServiceOptionalDefaultValueMethodResult { return &ExampleServiceOptionalDefaultValueMethodResult{} } +func (p *ExampleServiceOptionalDefaultValueMethodResult) InitDefault() { +} + var ExampleServiceOptionalDefaultValueMethodResult_Success_DEFAULT *ExampleOptionalDefaultValue func (p *ExampleServiceOptionalDefaultValueMethodResult) GetSuccess() (v *ExampleOptionalDefaultValue) { @@ -14656,133 +2332,11 @@ func (p *ExampleServiceOptionalDefaultValueMethodResult) GetSuccess() (v *Exampl } return p.Success } -func (p *ExampleServiceOptionalDefaultValueMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleOptionalDefaultValue) -} - -var fieldIDToName_ExampleServiceOptionalDefaultValueMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceOptionalDefaultValueMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceOptionalDefaultValueMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOptionalDefaultValueMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceOptionalDefaultValueMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleOptionalDefaultValue() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceOptionalDefaultValueMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("OptionalDefaultValueMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceOptionalDefaultValueMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceOptionalDefaultValueMethodResult) String() string { if p == nil { return "" @@ -14790,24 +2344,8 @@ func (p *ExampleServiceOptionalDefaultValueMethodResult) String() string { return fmt.Sprintf("ExampleServiceOptionalDefaultValueMethodResult(%+v)", *p) } -func (p *ExampleServiceOptionalDefaultValueMethodResult) DeepEqual(ano *ExampleServiceOptionalDefaultValueMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceOptionalDefaultValueMethodResult) Field0DeepEqual(src *ExampleOptionalDefaultValue) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceOptionalDefaultValueMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceNoBodyStructMethodArgs struct { @@ -14818,6 +2356,9 @@ func NewExampleServiceNoBodyStructMethodArgs() *ExampleServiceNoBodyStructMethod return &ExampleServiceNoBodyStructMethodArgs{} } +func (p *ExampleServiceNoBodyStructMethodArgs) InitDefault() { +} + var ExampleServiceNoBodyStructMethodArgs_Req_DEFAULT *ExampleNoBodyStruct func (p *ExampleServiceNoBodyStructMethodArgs) GetReq() (v *ExampleNoBodyStruct) { @@ -14826,131 +2367,11 @@ func (p *ExampleServiceNoBodyStructMethodArgs) GetReq() (v *ExampleNoBodyStruct) } return p.Req } -func (p *ExampleServiceNoBodyStructMethodArgs) SetReq(val *ExampleNoBodyStruct) { - p.Req = val -} - -var fieldIDToName_ExampleServiceNoBodyStructMethodArgs = map[int16]string{ - 1: "req", -} func (p *ExampleServiceNoBodyStructMethodArgs) IsSetReq() bool { return p.Req != nil } -func (p *ExampleServiceNoBodyStructMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceNoBodyStructMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceNoBodyStructMethodArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewExampleNoBodyStruct() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceNoBodyStructMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NoBodyStructMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceNoBodyStructMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *ExampleServiceNoBodyStructMethodArgs) String() string { if p == nil { return "" @@ -14958,34 +2379,21 @@ func (p *ExampleServiceNoBodyStructMethodArgs) String() string { return fmt.Sprintf("ExampleServiceNoBodyStructMethodArgs(%+v)", *p) } -func (p *ExampleServiceNoBodyStructMethodArgs) DeepEqual(ano *ExampleServiceNoBodyStructMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceNoBodyStructMethodArgs) Field1DeepEqual(src *ExampleNoBodyStruct) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceNoBodyStructMethodArgs = map[int16]string{ + 1: "req", } type ExampleServiceNoBodyStructMethodResult struct { - Success *ExampleNoBodyStruct `thrift:"success,0" json:"success,omitempty"` + Success *ExampleNoBodyStruct `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceNoBodyStructMethodResult() *ExampleServiceNoBodyStructMethodResult { return &ExampleServiceNoBodyStructMethodResult{} } +func (p *ExampleServiceNoBodyStructMethodResult) InitDefault() { +} + var ExampleServiceNoBodyStructMethodResult_Success_DEFAULT *ExampleNoBodyStruct func (p *ExampleServiceNoBodyStructMethodResult) GetSuccess() (v *ExampleNoBodyStruct) { @@ -14994,133 +2402,11 @@ func (p *ExampleServiceNoBodyStructMethodResult) GetSuccess() (v *ExampleNoBodyS } return p.Success } -func (p *ExampleServiceNoBodyStructMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*ExampleNoBodyStruct) -} - -var fieldIDToName_ExampleServiceNoBodyStructMethodResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceNoBodyStructMethodResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceNoBodyStructMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceNoBodyStructMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceNoBodyStructMethodResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewExampleNoBodyStruct() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *ExampleServiceNoBodyStructMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NoBodyStructMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceNoBodyStructMethodResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceNoBodyStructMethodResult) String() string { if p == nil { return "" @@ -15128,24 +2414,8 @@ func (p *ExampleServiceNoBodyStructMethodResult) String() string { return fmt.Sprintf("ExampleServiceNoBodyStructMethodResult(%+v)", *p) } -func (p *ExampleServiceNoBodyStructMethodResult) DeepEqual(ano *ExampleServiceNoBodyStructMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceNoBodyStructMethodResult) Field0DeepEqual(src *ExampleNoBodyStruct) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_ExampleServiceNoBodyStructMethodResult = map[int16]string{ + 0: "success", } type ExampleServiceStringArgs struct { @@ -15156,129 +2426,11 @@ func NewExampleServiceStringArgs() *ExampleServiceStringArgs { return &ExampleServiceStringArgs{} } -func (p *ExampleServiceStringArgs) GetReq() (v string) { - return p.Req -} -func (p *ExampleServiceStringArgs) SetReq(val string) { - p.Req = val -} - -var fieldIDToName_ExampleServiceStringArgs = map[int16]string{ - 1: "req", -} - -func (p *ExampleServiceStringArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceStringArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceStringArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Req = v - } - return nil +func (p *ExampleServiceStringArgs) InitDefault() { } -func (p *ExampleServiceStringArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("String_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceStringArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Req); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceStringArgs) GetReq() (v string) { + return p.Req } func (p *ExampleServiceStringArgs) String() string { @@ -15288,34 +2440,21 @@ func (p *ExampleServiceStringArgs) String() string { return fmt.Sprintf("ExampleServiceStringArgs(%+v)", *p) } -func (p *ExampleServiceStringArgs) DeepEqual(ano *ExampleServiceStringArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceStringArgs) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Req, src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceStringArgs = map[int16]string{ + 1: "req", } type ExampleServiceStringResult struct { - Success *string `thrift:"success,0" json:"success,omitempty"` + Success *string `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceStringResult() *ExampleServiceStringResult { return &ExampleServiceStringResult{} } +func (p *ExampleServiceStringResult) InitDefault() { +} + var ExampleServiceStringResult_Success_DEFAULT string func (p *ExampleServiceStringResult) GetSuccess() (v string) { @@ -15324,134 +2463,11 @@ func (p *ExampleServiceStringResult) GetSuccess() (v string) { } return *p.Success } -func (p *ExampleServiceStringResult) SetSuccess(x interface{}) { - p.Success = x.(*string) -} - -var fieldIDToName_ExampleServiceStringResult = map[int16]string{ - 0: "success", -} func (p *ExampleServiceStringResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceStringResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceStringResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceStringResult) ReadField0(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Success = &v - } - return nil -} - -func (p *ExampleServiceStringResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("String_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceStringResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(*p.Success); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceStringResult) String() string { if p == nil { return "" @@ -15459,29 +2475,8 @@ func (p *ExampleServiceStringResult) String() string { return fmt.Sprintf("ExampleServiceStringResult(%+v)", *p) } -func (p *ExampleServiceStringResult) DeepEqual(ano *ExampleServiceStringResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *ExampleServiceStringResult) Field0DeepEqual(src *string) bool { - - if p.Success == src { - return true - } else if p.Success == nil || src == nil { - return false - } - if strings.Compare(*p.Success, *src) != 0 { - return false - } - return true +var fieldIDToName_ExampleServiceStringResult = map[int16]string{ + 0: "success", } type ExampleServiceI64Args struct { @@ -15492,129 +2487,11 @@ func NewExampleServiceI64Args() *ExampleServiceI64Args { return &ExampleServiceI64Args{} } -func (p *ExampleServiceI64Args) GetReq() (v int64) { - return p.Req -} -func (p *ExampleServiceI64Args) SetReq(val int64) { - p.Req = val -} - -var fieldIDToName_ExampleServiceI64Args = map[int16]string{ - 1: "req", -} - -func (p *ExampleServiceI64Args) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceI64Args[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceI64Args) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Req = v - } - return nil +func (p *ExampleServiceI64Args) InitDefault() { } -func (p *ExampleServiceI64Args) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("I64_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceI64Args) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.I64, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Req); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *ExampleServiceI64Args) GetReq() (v int64) { + return p.Req } func (p *ExampleServiceI64Args) String() string { @@ -15624,34 +2501,21 @@ func (p *ExampleServiceI64Args) String() string { return fmt.Sprintf("ExampleServiceI64Args(%+v)", *p) } -func (p *ExampleServiceI64Args) DeepEqual(ano *ExampleServiceI64Args) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *ExampleServiceI64Args) Field1DeepEqual(src int64) bool { - - if p.Req != src { - return false - } - return true +var fieldIDToName_ExampleServiceI64Args = map[int16]string{ + 1: "req", } type ExampleServiceI64Result struct { - Success *int64 `thrift:"success,0" json:"success,omitempty"` + Success *int64 `thrift:"success,0,optional" json:"success,omitempty"` } func NewExampleServiceI64Result() *ExampleServiceI64Result { return &ExampleServiceI64Result{} } +func (p *ExampleServiceI64Result) InitDefault() { +} + var ExampleServiceI64Result_Success_DEFAULT int64 func (p *ExampleServiceI64Result) GetSuccess() (v int64) { @@ -15660,134 +2524,11 @@ func (p *ExampleServiceI64Result) GetSuccess() (v int64) { } return *p.Success } -func (p *ExampleServiceI64Result) SetSuccess(x interface{}) { - p.Success = x.(*int64) -} - -var fieldIDToName_ExampleServiceI64Result = map[int16]string{ - 0: "success", -} func (p *ExampleServiceI64Result) IsSetSuccess() bool { return p.Success != nil } -func (p *ExampleServiceI64Result) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.I64 { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceI64Result[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceI64Result) ReadField0(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Success = &v - } - return nil -} - -func (p *ExampleServiceI64Result) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("I64_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *ExampleServiceI64Result) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.I64, 0); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(*p.Success); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *ExampleServiceI64Result) String() string { if p == nil { return "" @@ -15795,27 +2536,11 @@ func (p *ExampleServiceI64Result) String() string { return fmt.Sprintf("ExampleServiceI64Result(%+v)", *p) } -func (p *ExampleServiceI64Result) DeepEqual(ano *ExampleServiceI64Result) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true +var fieldIDToName_ExampleServiceI64Result = map[int16]string{ + 0: "success", } -func (p *ExampleServiceI64Result) Field0DeepEqual(src *int64) bool { - - if p.Success == src { - return true - } else if p.Success == nil || src == nil { - return false - } - if *p.Success != *src { - return false - } - return true -} +// exceptions of methods in ExampleService. +var ( + _ error = (*Exception)(nil) +) diff --git a/testdata/kitex_gen/example3/k-example3.go b/testdata/kitex_gen/example3/k-example3.go index 80c0b8b1..20dc39d5 100644 --- a/testdata/kitex_gen/example3/k-example3.go +++ b/testdata/kitex_gen/example3/k-example3.go @@ -1,11686 +1,5787 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package example3 import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" + "unsafe" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/ref" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) _ = base.KitexUnusedProtection _ = ref.KitexUnusedProtection ) -func (p *InnerBase) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError +func (p *InnerBase) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + off += 3 + off += 1 + + // p.Byte ID:2 thrift.I08 + off += 3 + off += 1 + + // p.Int16 ID:3 thrift.I16 + off += 3 + off += 2 + + // p.Int32 ID:4 thrift.I32 + off += 3 + off += 4 + + // p.Int64 ID:5 thrift.I64 + off += 3 + off += 8 + + // p.Double ID:6 thrift.DOUBLE + off += 3 + off += 8 + + // p.String_ ID:7 thrift.STRING + off += 3 + off += 4 + len(p.String_) + + // p.ListInt32 ID:8 thrift.LIST + off += 3 + off += 5 + off += len(p.ListInt32) * 4 + + // p.MapStringString ID:9 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringString { + off += 4 + len(k) + off += 4 + len(v) + } + + // p.SetInt32 ID:10 thrift.SET + off += 3 + off += 5 + off += len(p.SetInt32) * 4 + + // p.Foo ID:11 thrift.I32 + off += 3 + off += 4 + + // p.MapInt32String ID:12 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt32String) * 4 + for _, v := range p.MapInt32String { + off += 4 + len(v) + } + + // p.Binary ID:13 thrift.STRING + off += 3 + off += 4 + len(p.Binary) + + // p.MapInt8String ID:14 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt8String) * 1 + for _, v := range p.MapInt8String { + off += 4 + len(v) + } + + // p.MapInt16String ID:15 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt16String) * 2 + for _, v := range p.MapInt16String { + off += 4 + len(v) + } + + // p.MapInt64String ID:16 thrift.MAP + off += 3 + off += 6 + off += len(p.MapInt64String) * 8 + for _, v := range p.MapInt64String { + off += 4 + len(v) + } + + // p.ListInnerBase ID:18 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListInnerBase { + off += v.BLength() + } + + // p.MapStringInnerBase ID:19 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapStringInnerBase { + off += 4 + len(k) + off += v.BLength() + } + + // p.InnerQuery ID:20 thrift.STRING + off += 3 + off += 4 + len(p.InnerQuery) + + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() + return off + 1 +} + +func (p *InnerBase) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *InnerBase) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Bool ID:1 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Bool))) + off++ + + // p.Byte ID:2 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = byte(p.Byte) + off++ + + // p.Int16 ID:3 thrift.I16 + b[off] = 6 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint16(b[off:], uint16(p.Int16)) + off += 2 + + // p.Int32 ID:4 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Int32)) + off += 4 + + // p.Int64 ID:5 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Int64)) + off += 8 + + // p.Double ID:6 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Double))) + off += 8 + + // p.String_ ID:7 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) + + // p.ListInt32 ID:8 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInt32))) + off += 5 + for _, v := range p.ListInt32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.MapStringString ID:9 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 9) + off += 3 + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringString))) + off += 6 + for k, v := range p.MapStringString { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.SetInt32 ID:10 thrift.SET + b[off] = 14 + binary.BigEndian.PutUint16(b[off+1:], 10) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.SetInt32))) + off += 5 + for _, v := range p.SetInt32 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } + + // p.Foo ID:11 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 11) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Foo)) + off += 4 + + // p.MapInt32String ID:12 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 12) + off += 3 + b[off] = 8 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt32String))) + off += 6 + for k, v := range p.MapInt32String { + binary.BigEndian.PutUint32(b[off:], uint32(k)) + off += 4 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.Binary ID:13 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 13) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary) + + // p.MapInt8String ID:14 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 14) + off += 3 + b[off] = 3 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt8String))) + off += 6 + for k, v := range p.MapInt8String { + b[off] = byte(k) + off++ + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapInt16String ID:15 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 15) + off += 3 + b[off] = 6 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt16String))) + off += 6 + for k, v := range p.MapInt16String { + binary.BigEndian.PutUint16(b[off:], uint16(k)) + off += 2 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.MapInt64String ID:16 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 16) + off += 3 + b[off] = 10 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInt64String))) + off += 6 + for k, v := range p.MapInt64String { + binary.BigEndian.PutUint64(b[off:], uint64(k)) + off += 8 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.ListInnerBase ID:18 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 18) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListInnerBase))) + off += 5 + for _, v := range p.ListInnerBase { + off += v.FastWriteNocopy(b[off:], w) + } + + // p.MapStringInnerBase ID:19 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 19) + off += 3 + b[off] = 11 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapStringInnerBase))) + off += 6 + for k, v := range p.MapStringInnerBase { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + off += v.FastWriteNocopy(b[off:], w) } + // p.InnerQuery ID:20 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 20) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.InnerQuery) + + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) + + b[off] = 0 + return off + 1 +} + +func (p *InnerBase) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var enum int32 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x102: // p.Bool ID:1 thrift.BOOL + p.Bool, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x203: // p.Byte ID:2 thrift.I08 + p.Byte, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.I16 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x306: // p.Int16 ID:3 thrift.I16 + p.Int16, l, err = x.ReadI16(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x408: // p.Int32 ID:4 thrift.I32 + p.Int32, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x50a: // p.Int64 ID:5 thrift.I64 + p.Int64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x604: // p.Double ID:6 thrift.DOUBLE + p.Double, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 7: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x70b: // p.String_ ID:7 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 8: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x80f: // p.ListInt32 ID:8 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 9: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField9(buf[offset:]) - offset += l + p.ListInt32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.ListInt32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 10: - if fieldTypeId == thrift.SET { - l, err = p.FastReadField10(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x90d: // p.MapStringString ID:9 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 11: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField11(buf[offset:]) - offset += l + p.MapStringString = make(map[string]string, sz) + for i := 0; i < sz; i++ { + var k string + var v string + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 12: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField12(buf[offset:]) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + p.MapStringString[k] = v } - case 13: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField13(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xa0e: // p.SetInt32 ID:10 thrift.SET + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 14: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField14(buf[offset:]) - offset += l + p.SetInt32 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.SetInt32[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 15: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField15(buf[offset:]) - offset += l + case 0xb08: // p.Foo ID:11 thrift.I32 + enum, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Foo = FOO(enum) + case 0xc0d: // p.MapInt32String ID:12 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapInt32String = make(map[int32]string, sz) + for i := 0; i < sz; i++ { + var k int32 + var v string + k, l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt32String[k] = v + } + case 0xd0b: // p.Binary ID:13 thrift.STRING + p.Binary, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xe0d: // p.MapInt8String ID:14 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 16: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField16(buf[offset:]) - offset += l + p.MapInt8String = make(map[int8]string, sz) + for i := 0; i < sz; i++ { + var k int8 + var v string + k, l, err = x.ReadByte(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt8String[k] = v + } + case 0xf0d: // p.MapInt16String ID:15 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 18: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField18(buf[offset:]) - offset += l + p.MapInt16String = make(map[int16]string, sz) + for i := 0; i < sz; i++ { + var k int16 + var v string + k, l, err = x.ReadI16(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt16String[k] = v + } + case 0x100d: // p.MapInt64String ID:16 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 19: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField19(buf[offset:]) - offset += l + p.MapInt64String = make(map[int64]string, sz) + for i := 0; i < sz; i++ { + var k int64 + var v string + k, l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapInt64String[k] = v } - case 20: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField20(buf[offset:]) - offset += l + case 0x120f: // p.ListInnerBase ID:18 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListInnerBase = make([]*InnerBase, sz) + for i := 0; i < sz; i++ { + p.ListInnerBase[i] = NewInnerBase() + l, err = p.ListInnerBase[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l + case 0x130d: // p.MapStringInnerBase ID:19 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.MapStringInnerBase = make(map[string]*InnerBase, sz) + for i := 0; i < sz; i++ { + var k string + var v *InnerBase + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v = NewInnerBase() + l, err = v.FastRead(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.MapStringInnerBase[k] = v + } + case 0x140b: // p.InnerQuery ID:20 thrift.STRING + p.InnerQuery, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBase[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerBase[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *InnerBase) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Bool = v - +func (p *ExampleReq) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *InnerBase) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v + off := 0 + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + off += 3 + off += 4 + len(*p.Msg) } - return offset, nil -} - -func (p *InnerBase) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int16 = v + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + off += 3 + off += 8 } - return offset, nil -} - -func (p *InnerBase) FastReadField4(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int32 = v + // p.Path ID:3 thrift.STRING + off += 3 + off += 4 + len(p.Path) + // p.Query ID:4 thrift.LIST + if p.Query != nil { + off += 3 + off += 5 + for _, v := range p.Query { + off += 4 + len(v) + } } - return offset, nil -} - -func (p *InnerBase) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int64 = v + // p.Header ID:5 thrift.BOOL + if p.Header != nil { + off += 3 + off += 1 } - return offset, nil -} - -func (p *InnerBase) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Double = v + // p.Code ID:6 thrift.I64 + off += 3 + off += 8 - } - return offset, nil -} + // p.InnerBase ID:7 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() -func (p *InnerBase) FastReadField7(buf []byte) (int, error) { - offset := 0 + // p.RawUri ID:8 thrift.STRING + off += 3 + off += 4 + len(p.RawUri) - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() - p.String_ = v - - } - return offset, nil + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 } -func (p *InnerBase) FastReadField8(buf []byte) (int, error) { - offset := 0 +func (p *ExampleReq) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err +func (p *ExampleReq) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - p.ListInt32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - _elem = v - - } - - p.ListInt32 = append(p.ListInt32, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Msg ID:1 thrift.STRING + if p.Msg != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Msg) } - return offset, nil -} - -func (p *InnerBase) FastReadField9(buf []byte) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(p.Cookie))) + off += 8 } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - _key = v + // p.Path ID:3 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Path) + // p.Query ID:4 thrift.LIST + if p.Query != nil { + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.Query))) + off += 5 + for _, v := range p.Query { + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + } + + // p.Header ID:5 thrift.BOOL + if p.Header != nil { + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(p.Header))) + off++ + } + + // p.Code ID:6 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Code)) + off += 8 + + // p.InnerBase ID:7 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) + + // p.RawUri ID:8 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 8) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.RawUri) + + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) + + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleReq) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - + if ftyp == thrift.STOP { + break } - - p.MapStringString[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField10(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.SetInt32_ = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + if p.Msg == nil { + p.Msg = new(string) + } + *p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x204: // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie == nil { + p.Cookie = new(float64) + } + *p.Cookie, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30b: // p.Path ID:3 thrift.STRING + p.Path, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x40f: // p.Query ID:4 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Query = make([]string, sz) + for i := 0; i < sz; i++ { + p.Query[i], l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + } + case 0x502: // p.Header ID:5 thrift.BOOL + if p.Header == nil { + p.Header = new(bool) + } + *p.Header, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x60a: // p.Code ID:6 thrift.I64 + p.Code, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x70c: // p.InnerBase ID:7 thrift.STRUCT + p.InnerBase = NewInnerBase() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x80b: // p.RawUri ID:8 thrift.STRING + p.RawUri, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } } - - p.SetInt32_ = append(p.SetInt32_, _elem) } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + if isset&0x1 == 0 { + fid = 3 // Path + goto RequiredFieldNotSetError } - return offset, nil + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleReq[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleReq[fid])) } -func (p *InnerBase) FastReadField11(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Foo = FOO(v) - +func (p *ExampleResp) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *InnerBase) FastReadField12(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err + off := 0 + + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + off += 3 + off += 8 } - p.MapInt32String = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - _key = v + // p.Status ID:3 thrift.I32 + off += 3 + off += 4 + + // p.Header ID:4 thrift.BOOL + if p.Header != nil { + off += 3 + off += 1 + } + + // p.Code ID:6 thrift.I64 + off += 3 + off += 8 + + // p.InnerBase ID:7 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() + + // p.BaseResp ID:255 thrift.STRUCT + off += 3 + off += p.BaseResp.BLength() + + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 +} + +func (p *ExampleResp) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExampleResp) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) + + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(p.Cookie))) + off += 8 + } + + // p.Status ID:3 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Status)) + off += 4 + + // p.Header ID:4 thrift.BOOL + if p.Header != nil { + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(p.Header))) + off++ + } + + // p.Code ID:6 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Code)) + off += 8 + + // p.InnerBase ID:7 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) + + // p.BaseResp ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.BaseResp.FastWriteNocopy(b[off:], w) + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleResp) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - + if ftyp == thrift.STOP { + break } - - p.MapInt32String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField13(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *InnerBase) FastReadField14(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt8String = make(map[int8]string, size) - for i := 0; i < size; i++ { - var _key int8 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt8String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField15(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt16String = make(map[int16]string, size) - for i := 0; i < size; i++ { - var _key int16 - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt16String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField16(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInt64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapInt64String[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField18(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListInnerBase = make([]*InnerBase, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerBase() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListInnerBase = append(p.ListInnerBase, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField19(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringInnerBase = make(map[string]*InnerBase, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - _val := NewInnerBase() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapStringInnerBase[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *InnerBase) FastReadField20(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.InnerQuery = v - - } - return offset, nil -} - -func (p *InnerBase) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *InnerBase) FastWrite(buf []byte) int { - return 0 -} - -func (p *InnerBase) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerBase") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField9(buf[offset:], binaryWriter) - offset += p.fastWriteField10(buf[offset:], binaryWriter) - offset += p.fastWriteField11(buf[offset:], binaryWriter) - offset += p.fastWriteField12(buf[offset:], binaryWriter) - offset += p.fastWriteField13(buf[offset:], binaryWriter) - offset += p.fastWriteField14(buf[offset:], binaryWriter) - offset += p.fastWriteField15(buf[offset:], binaryWriter) - offset += p.fastWriteField16(buf[offset:], binaryWriter) - offset += p.fastWriteField18(buf[offset:], binaryWriter) - offset += p.fastWriteField19(buf[offset:], binaryWriter) - offset += p.fastWriteField20(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerBase") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field9Length() - l += p.field10Length() - l += p.field11Length() - l += p.field12Length() - l += p.field13Length() - l += p.field14Length() - l += p.field15Length() - l += p.field16Length() - l += p.field18Length() - l += p.field19Length() - l += p.field20Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerBase) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 2) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int16", thrift.I16, 3) - offset += bthrift.Binary.WriteI16(buf[offset:], p.Int16) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int32", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Int32) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int64", thrift.I64, 5) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Int64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 6) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 7) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInt32", thrift.LIST, 8) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I32, len(p.ListInt32)) - for _, v := range p.ListInt32 { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 9) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SetInt32", thrift.SET, 10) - offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.I32, len(p.SetInt32_)) - - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - for _, v := range p.SetInt32_ { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Foo", thrift.I32, 11) - offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Foo)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt32String", thrift.MAP, 12) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I32, thrift.STRING, len(p.MapInt32String)) - for k, v := range p.MapInt32String { - - offset += bthrift.Binary.WriteI32(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 13) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt8String", thrift.MAP, 14) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.BYTE, thrift.STRING, len(p.MapInt8String)) - for k, v := range p.MapInt8String { - - offset += bthrift.Binary.WriteByte(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt16String", thrift.MAP, 15) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I16, thrift.STRING, len(p.MapInt16String)) - for k, v := range p.MapInt16String { - - offset += bthrift.Binary.WriteI16(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField16(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInt64String", thrift.MAP, 16) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I64, thrift.STRING, len(p.MapInt64String)) - for k, v := range p.MapInt64String { - - offset += bthrift.Binary.WriteI64(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField18(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListInnerBase", thrift.LIST, 18) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField19(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringInnerBase", thrift.MAP, 19) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRUCT, len(p.MapStringInnerBase)) - for k, v := range p.MapStringInnerBase { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField20(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerQuery", thrift.STRING, 20) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.InnerQuery) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBase) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Bool) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 2) - l += bthrift.Binary.ByteLength(p.Byte) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int16", thrift.I16, 3) - l += bthrift.Binary.I16Length(p.Int16) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int32", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.Int32) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int64", thrift.I64, 5) - l += bthrift.Binary.I64Length(p.Int64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 6) - l += bthrift.Binary.DoubleLength(p.Double) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 7) - l += bthrift.Binary.StringLengthNocopy(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInt32", thrift.LIST, 8) - l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListInt32)) - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.ListInt32) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 9) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - - l += bthrift.Binary.StringLengthNocopy(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field10Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SetInt32", thrift.SET, 10) - l += bthrift.Binary.SetBeginLength(thrift.I32, len(p.SetInt32_)) - - for i := 0; i < len(p.SetInt32_); i++ { - for j := i + 1; j < len(p.SetInt32_); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.SetInt32_[i], p.SetInt32_[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetInt32_[i])) - } - } - } - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.SetInt32_) - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Foo", thrift.I32, 11) - l += bthrift.Binary.I32Length(int32(p.Foo)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field12Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt32String", thrift.MAP, 12) - l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.STRING, len(p.MapInt32String)) - for k, v := range p.MapInt32String { - - l += bthrift.Binary.I32Length(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field13Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 13) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field14Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt8String", thrift.MAP, 14) - l += bthrift.Binary.MapBeginLength(thrift.BYTE, thrift.STRING, len(p.MapInt8String)) - for k, v := range p.MapInt8String { - - l += bthrift.Binary.ByteLength(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field15Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt16String", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.I16, thrift.STRING, len(p.MapInt16String)) - for k, v := range p.MapInt16String { - - l += bthrift.Binary.I16Length(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field16Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInt64String", thrift.MAP, 16) - l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, len(p.MapInt64String)) - for k, v := range p.MapInt64String { - - l += bthrift.Binary.I64Length(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field18Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListInnerBase", thrift.LIST, 18) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListInnerBase)) - for _, v := range p.ListInnerBase { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field19Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringInnerBase", thrift.MAP, 19) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringInnerBase)) - for k, v := range p.MapStringInnerBase { - - l += bthrift.Binary.StringLengthNocopy(k) - - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field20Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerQuery", thrift.STRING, 20) - l += bthrift.Binary.StringLengthNocopy(p.InnerQuery) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBase) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetPath bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetPath = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 8: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetPath { - fieldId = 3 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleReq[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleReq[fieldId])) -} - -func (p *ExampleReq) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Msg = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Cookie = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Path = v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField4(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Query = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.Query = append(p.Query, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleReq) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Header = &v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField7(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBase() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleReq) FastReadField8(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.RawUri = v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -func (p *ExampleReq) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleReq) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleReq") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField8(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleReq") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - l += p.field7Length() - l += p.field8Length() - l += p.field32767Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetMsg() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetCookie() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Cookie", thrift.DOUBLE, 2) - offset += bthrift.Binary.WriteDouble(buf[offset:], *p.Cookie) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Path", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Path) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetQuery() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query", thrift.LIST, 4) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.Query)) - for _, v := range p.Query { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetHeader() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header", thrift.BOOL, 5) - offset += bthrift.Binary.WriteBool(buf[offset:], *p.Header) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleReq) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Code", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 7) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "RawUri", thrift.STRING, 8) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RawUri) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleReq) field1Length() int { - l := 0 - if p.IsSetMsg() { - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(*p.Msg) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field2Length() int { - l := 0 - if p.IsSetCookie() { - l += bthrift.Binary.FieldBeginLength("Cookie", thrift.DOUBLE, 2) - l += bthrift.Binary.DoubleLength(*p.Cookie) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Path", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Path) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field4Length() int { - l := 0 - if p.IsSetQuery() { - l += bthrift.Binary.FieldBeginLength("Query", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Query)) - for _, v := range p.Query { - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field5Length() int { - l := 0 - if p.IsSetHeader() { - l += bthrift.Binary.FieldBeginLength("Header", thrift.BOOL, 5) - l += bthrift.Binary.BoolLength(*p.Header) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleReq) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Code", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.Code) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 7) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("RawUri", thrift.STRING, 8) - l += bthrift.Binary.StringLengthNocopy(p.RawUri) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleReq) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetStatus bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetStatus = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetStatus { - fieldId = 3 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleResp[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleResp[fieldId])) -} - -func (p *ExampleResp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Cookie = &v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Status = v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Header = &v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -func (p *ExampleResp) FastReadField7(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBase() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleResp) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.BaseResp = base.NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleResp) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleResp") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleResp") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field6Length() - l += p.field32767Length() - l += p.field7Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetCookie() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Cookie", thrift.DOUBLE, 2) - offset += bthrift.Binary.WriteDouble(buf[offset:], *p.Cookie) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Status", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Status) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetHeader() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], *p.Header) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExampleResp) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Code", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 7) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BaseResp", thrift.STRUCT, 255) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleResp) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field2Length() int { - l := 0 - if p.IsSetCookie() { - l += bthrift.Binary.FieldBeginLength("Cookie", thrift.DOUBLE, 2) - l += bthrift.Binary.DoubleLength(*p.Cookie) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleResp) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Status", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.Status) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field4Length() int { - l := 0 - if p.IsSetHeader() { - l += bthrift.Binary.FieldBeginLength("Header", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(*p.Header) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExampleResp) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Code", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.Code) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 7) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleResp) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 255) - l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleError) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetQuery = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetQuery { - fieldId = 3 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleError[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleError[fieldId])) -} - -func (p *ExampleError) FastReadField1(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, size) - for i := 0; i < size; i++ { - _key := NewInnerBase() - if l, err := _key.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - _val := NewInnerBase() - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapInnerBaseInnerBase[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleError) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Base64 = []byte(v) - - } - return offset, nil -} - -func (p *ExampleError) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Query = v - - } - return offset, nil -} - -func (p *ExampleError) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Header = v - - } - return offset, nil -} - -func (p *ExampleError) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Q2 = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleError) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleError) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleError") - if p != nil { - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleError") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleError) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapInnerBaseInnerBase", thrift.MAP, 1) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - offset += k.FastWriteNocopy(buf[offset:], binaryWriter) - - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base64", thrift.STRING, 2) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Base64)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Query) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Header) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Q2", thrift.I32, 5) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Q2) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleError) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapInnerBaseInnerBase", thrift.MAP, 1) - l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapInnerBaseInnerBase)) - for k, v := range p.MapInnerBaseInnerBase { - - l += k.BLength() - - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleError) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base64", thrift.STRING, 2) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Base64)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleError) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Query", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Query) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleError) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Header", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Header) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleError) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Q2", thrift.I32, 5) - l += bthrift.Binary.I32Length(p.Q2) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleErrorResp) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleErrorResp[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleErrorResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int64 = v - - } - return offset, nil -} - -func (p *ExampleErrorResp) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Xjson = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleErrorResp) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleErrorResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleErrorResp") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleErrorResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleErrorResp") - if p != nil { - l += p.field2Length() - l += p.field4Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleErrorResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int64", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Int64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleErrorResp) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Xjson", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Xjson) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleErrorResp) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int64", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.Int64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleErrorResp) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Xjson", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.Xjson) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleInt2Float) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleInt2Float[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleInt2Float) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int32 = v - - } - return offset, nil -} - -func (p *ExampleInt2Float) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Float64 = v - - } - return offset, nil -} - -func (p *ExampleInt2Float) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - - } - return offset, nil -} - -func (p *ExampleInt2Float) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Int64 = v - - } - return offset, nil -} - -func (p *ExampleInt2Float) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleInt2Float) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleInt2Float) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleInt2Float") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleInt2Float") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field32767Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleInt2Float) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int32", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Int32) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Float64", thrift.DOUBLE, 2) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Float64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Int64", thrift.I64, 4) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Int64) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleInt2Float) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int32", thrift.I32, 1) - l += bthrift.Binary.I32Length(p.Int32) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleInt2Float) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Float64", thrift.DOUBLE, 2) - l += bthrift.Binary.DoubleLength(p.Float64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleInt2Float) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.String_) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleInt2Float) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Int64", thrift.I64, 4) - l += bthrift.Binary.I64Length(p.Int64) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleInt2Float) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *JSONObject) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.BYTE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_JSONObject[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *JSONObject) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.A = v - - } - return offset, nil -} - -func (p *JSONObject) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.B = v - - } - return offset, nil -} - -// for compatibility -func (p *JSONObject) FastWrite(buf []byte) int { - return 0 -} - -func (p *JSONObject) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "JSONObject") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *JSONObject) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("JSONObject") - if p != nil { - l += p.field1Length() - l += p.field2Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *JSONObject) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.A) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *JSONObject) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "B", thrift.BYTE, 2) - offset += bthrift.Binary.WriteByte(buf[offset:], p.B) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *JSONObject) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("A", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.A) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *JSONObject) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("B", thrift.BYTE, 2) - l += bthrift.Binary.ByteLength(p.B) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery2 bool = false - var issetHeader bool = false - var issetHeader2 bool = false - var issetCookie2 bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetQuery2 = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetHeader = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetHeader2 = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.SET { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetCookie2 = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetQuery2 { - fieldId = 2 - goto RequiredFieldNotSetError - } - - if !issetHeader { - fieldId = 3 - goto RequiredFieldNotSetError - } - - if !issetHeader2 { - fieldId = 4 - goto RequiredFieldNotSetError - } - - if !issetCookie2 { - fieldId = 6 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleJSONString[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleJSONString[fieldId])) -} - -func (p *ExampleJSONString) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Query = NewJSONObject() - if l, err := p.Query.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleJSONString) FastReadField2(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Query2 = make([]string, 0, size) - for i := 0; i < size; i++ { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.Query2 = append(p.Query2, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleJSONString) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.Header = NewJSONObject() - if l, err := p.Header.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleJSONString) FastReadField4(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Header2 = make(map[int32]string, size) - for i := 0; i < size; i++ { - var _key int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Header2[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleJSONString) FastReadField5(buf []byte) (int, error) { - offset := 0 - p.Cookie = NewJSONObject() - if l, err := p.Cookie.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExampleJSONString) FastReadField6(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Cookie2 = make([]int32, 0, size) - for i := 0; i < size; i++ { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.Cookie2 = append(p.Cookie2, _elem) - } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExampleJSONString) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleJSONString) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleJSONString") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleJSONString") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleJSONString) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query", thrift.STRUCT, 1) - offset += p.Query.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query2", thrift.LIST, 2) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRING, len(p.Query2)) - for _, v := range p.Query2 { - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header", thrift.STRUCT, 3) - offset += p.Header.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header2", thrift.MAP, 4) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I32, thrift.STRING, len(p.Header2)) - for k, v := range p.Header2 { - - offset += bthrift.Binary.WriteI32(buf[offset:], k) - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Cookie", thrift.STRUCT, 5) - offset += p.Cookie.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Cookie2", thrift.SET, 6) - offset += bthrift.Binary.WriteSetBegin(buf[offset:], thrift.I32, len(p.Cookie2)) - - for i := 0; i < len(p.Cookie2); i++ { - for j := i + 1; j < len(p.Cookie2); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.Cookie2[i], p.Cookie2[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Cookie2[i])) - } - } - } - for _, v := range p.Cookie2 { - offset += bthrift.Binary.WriteI32(buf[offset:], v) - - } - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleJSONString) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Query", thrift.STRUCT, 1) - l += p.Query.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Query2", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.Query2)) - for _, v := range p.Query2 { - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Header", thrift.STRUCT, 3) - l += p.Header.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Header2", thrift.MAP, 4) - l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.STRING, len(p.Header2)) - for k, v := range p.Header2 { - - l += bthrift.Binary.I32Length(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Cookie", thrift.STRUCT, 5) - l += p.Cookie.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleJSONString) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Cookie2", thrift.SET, 6) - l += bthrift.Binary.SetBeginLength(thrift.I32, len(p.Cookie2)) - - for i := 0; i < len(p.Cookie2); i++ { - for j := i + 1; j < len(p.Cookie2); j++ { - if func(tgt, src int32) bool { - if tgt != src { - return false - } - return true - }(p.Cookie2[i], p.Cookie2[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.Cookie2[i])) - } - } - } - var tmpV int32 - l += bthrift.Binary.I32Length(int32(tmpV)) * len(p.Cookie2) - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePartial[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExamplePartial) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -// for compatibility -func (p *ExamplePartial) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExamplePartial) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplePartial") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExamplePartial") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExamplePartial) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetStatus bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetStatus = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 32767: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField32767(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 7: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField7(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetStatus { - fieldId = 3 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePartial2[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExamplePartial2[fieldId])) -} - -func (p *ExamplePartial2) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Cookie = &v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Status = v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Header = &v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField6(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField32767(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Subfix = v - - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField7(buf []byte) (int, error) { - offset := 0 - p.InnerBase = NewInnerBasePartial() - if l, err := p.InnerBase.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *ExamplePartial2) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.BaseResp = base.NewBaseResp() - if l, err := p.BaseResp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *ExamplePartial2) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExamplePartial2) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplePartial2") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - offset += p.fastWriteField32767(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField7(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExamplePartial2") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field6Length() - l += p.field32767Length() - l += p.field7Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExamplePartial2) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetCookie() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Cookie", thrift.DOUBLE, 2) - offset += bthrift.Binary.WriteDouble(buf[offset:], *p.Cookie) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExamplePartial2) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Status", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Status) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetHeader() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Header", thrift.BOOL, 4) - offset += bthrift.Binary.WriteBool(buf[offset:], *p.Header) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *ExamplePartial2) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Code", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) fastWriteField32767(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Subfix", thrift.DOUBLE, 32767) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Subfix) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerBase", thrift.STRUCT, 7) - offset += p.InnerBase.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BaseResp", thrift.STRUCT, 255) - offset += p.BaseResp.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePartial2) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) field2Length() int { - l := 0 - if p.IsSetCookie() { - l += bthrift.Binary.FieldBeginLength("Cookie", thrift.DOUBLE, 2) - l += bthrift.Binary.DoubleLength(*p.Cookie) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExamplePartial2) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Status", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.Status) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) field4Length() int { - l := 0 - if p.IsSetHeader() { - l += bthrift.Binary.FieldBeginLength("Header", thrift.BOOL, 4) - l += bthrift.Binary.BoolLength(*p.Header) - - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *ExamplePartial2) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Code", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.Code) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) field32767Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Subfix", thrift.DOUBLE, 32767) - l += bthrift.Binary.DoubleLength(p.Subfix) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) field7Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerBase", thrift.STRUCT, 7) - l += p.InnerBase.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePartial2) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BaseResp", thrift.STRUCT, 255) - l += p.BaseResp.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 255: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x204: // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie == nil { + p.Cookie = new(float64) } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + *p.Cookie, l, err = x.ReadDouble(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerBasePartial[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerBasePartial) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Bool = v - - } - return offset, nil -} - -func (p *InnerBasePartial) FastReadField255(buf []byte) (int, error) { - offset := 0 - p.Base = base.NewBase() - if l, err := p.Base.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *InnerBasePartial) FastWrite(buf []byte) int { - return 0 -} - -func (p *InnerBasePartial) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerBasePartial") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerBasePartial") - if p != nil { - l += p.field1Length() - l += p.field255Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerBasePartial) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Bool", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Bool) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Base", thrift.STRUCT, 255) - offset += p.Base.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerBasePartial) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Bool", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Bool) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerBasePartial) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Base", thrift.STRUCT, 255) - l += p.Base.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleFallback) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x308: // p.Status ID:3 thrift.I32 + p.Status, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + isset |= 0x1 + case 0x402: // p.Header ID:4 thrift.BOOL + if p.Header == nil { + p.Header = new(bool) } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + *p.Header, l, err = x.ReadBool(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleFallback[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleFallback) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Msg = v - - } - return offset, nil -} - -func (p *ExampleFallback) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Heeader = v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleFallback) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleFallback) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleFallback") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *ExampleFallback) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleFallback") - if p != nil { - l += p.field2Length() - l += p.field3Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleFallback) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Msg", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleFallback) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Heeader", thrift.STRING, 3) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Heeader) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleFallback) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Msg", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Msg) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleFallback) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Heeader", thrift.STRING, 3) - l += bthrift.Binary.StringLengthNocopy(p.Heeader) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *InnerCode) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x60a: // p.Code ID:6 thrift.I64 + p.Code, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I16 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x70c: // p.InnerBase ID:7 thrift.STRUCT + p.InnerBase = NewInnerBase() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xff0c: // p.BaseResp ID:255 thrift.STRUCT + p.BaseResp = base.NewBaseResp() + l, err = p.BaseResp.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 3 // Status + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerCode[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleResp[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *InnerCode) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.C1 = v - - } - return offset, nil -} - -func (p *InnerCode) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.C2 = v - - } - return offset, nil -} - -func (p *InnerCode) FastReadField3(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.C3 = make([]*InnerCode, 0, size) - for i := 0; i < size; i++ { - _elem := NewInnerCode() - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.C3 = append(p.C3, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *InnerCode) FastWrite(buf []byte) int { - return 0 -} - -func (p *InnerCode) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerCode") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *InnerCode) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerCode") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerCode) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C1", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.C1) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleResp[fid])) } -func (p *InnerCode) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C2", thrift.I16, 2) - offset += bthrift.Binary.WriteI16(buf[offset:], p.C2) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *ExampleError) BLength() int { + if p == nil { + return 1 + } + off := 0 -func (p *InnerCode) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C3", thrift.LIST, 3) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.STRUCT, len(p.C3)) - for _, v := range p.C3 { - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + // p.MapInnerBaseInnerBase ID:1 thrift.MAP + off += 3 + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.BLength() + off += v.BLength() } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} -func (p *InnerCode) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("C1", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.C1) + // p.Base64 ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Base64) - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Query ID:3 thrift.STRING + off += 3 + off += 4 + len(p.Query) -func (p *InnerCode) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("C2", thrift.I16, 2) - l += bthrift.Binary.I16Length(p.C2) + // p.Header ID:4 thrift.STRING + off += 3 + off += 4 + len(p.Header) - l += bthrift.Binary.FieldEndLength() - return l + // p.Q2 ID:5 thrift.I32 + off += 3 + off += 4 + return off + 1 } -func (p *InnerCode) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("C3", thrift.LIST, 3) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.C3)) - for _, v := range p.C3 { - l += v.BLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} +func (p *ExampleError) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleApiBody) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError +func (p *ExampleError) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } + off := 0 + // p.MapInnerBaseInnerBase ID:1 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = 12 + b[off+1] = 12 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.MapInnerBaseInnerBase))) + off += 6 + for k, v := range p.MapInnerBaseInnerBase { + off += k.FastWriteNocopy(b[off:], w) + off += v.FastWriteNocopy(b[off:], w) + } + + // p.Base64 ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Base64) + + // p.Query ID:3 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Query) + + // p.Header ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Header) + + // p.Q2 ID:5 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Q2)) + off += 4 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleError) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10d: // p.MapInnerBaseInnerBase ID:1 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I16 { - l, err = p.FastReadField2(buf[offset:]) - offset += l + p.MapInnerBaseInnerBase = make(map[*InnerBase]*InnerBase, sz) + for i := 0; i < sz; i++ { + var k *InnerBase + var v *InnerBase + k = NewInnerBase() + l, err = k.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l + v = NewInnerBase() + l, err = v.FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + p.MapInnerBaseInnerBase[k] = v + } + case 0x20b: // p.Base64 ID:2 thrift.STRING + p.Base64, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30b: // p.Query ID:3 thrift.STRING + p.Query, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x40b: // p.Header ID:4 thrift.STRING + p.Header, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x508: // p.Q2 ID:5 thrift.I32 + p.Q2, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 3 // Query + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleApiBody[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleError[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleApiBody) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code = v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleError[fid])) } -func (p *ExampleApiBody) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI16(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Code2 = v - +func (p *ExampleErrorResp) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleApiBody) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.InnerCode = NewInnerCode() - if l, err := p.InnerCode.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} + // p.Int64 ID:2 thrift.I64 + off += 3 + off += 8 -// for compatibility -func (p *ExampleApiBody) FastWrite(buf []byte) int { - return 0 + // p.Xjson ID:4 thrift.STRING + off += 3 + off += 4 + len(p.Xjson) + return off + 1 } -func (p *ExampleApiBody) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleApiBody") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleErrorResp) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleApiBody) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleApiBody") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() +func (p *ExampleErrorResp) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleApiBody) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Code", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Code) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleApiBody) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Code2", thrift.I16, 2) - offset += bthrift.Binary.WriteI16(buf[offset:], p.Code2) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleApiBody) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerCode", thrift.STRUCT, 3) - offset += p.InnerCode.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleApiBody) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Code", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Code) - - l += bthrift.Binary.FieldEndLength() - return l -} + off := 0 -func (p *ExampleApiBody) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Code2", thrift.I16, 2) - l += bthrift.Binary.I16Length(p.Code2) + // p.Int64 ID:2 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Int64)) + off += 8 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Xjson ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Xjson) -func (p *ExampleApiBody) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerCode", thrift.STRUCT, 3) - l += p.InnerCode.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *InnerJSON) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleErrorResp) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x20a: // p.Int64 ID:2 thrift.I64 + p.Int64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x40b: // p.Xjson ID:4 thrift.STRING + p.Xjson, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } + } + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleErrorResp[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +} - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l +func (p *ExampleInt2Float) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Int32 ID:1 thrift.I32 + off += 3 + off += 4 + + // p.Float64 ID:2 thrift.DOUBLE + off += 3 + off += 8 + + // p.String_ ID:3 thrift.STRING + off += 3 + off += 4 + len(p.String_) + + // p.Int64 ID:4 thrift.I64 + off += 3 + off += 8 + + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 +} + +func (p *ExampleInt2Float) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExampleInt2Float) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Int32 ID:1 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Int32)) + off += 4 + + // p.Float64 ID:2 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Float64))) + off += 8 + + // p.String_ ID:3 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.String_) + + // p.Int64 ID:4 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Int64)) + off += 8 + + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 + + b[off] = 0 + return off + 1 +} + +func (p *ExampleInt2Float) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { - goto ReadFieldEndError + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x108: // p.Int32 ID:1 thrift.I32 + p.Int32, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x204: // p.Float64 ID:2 thrift.DOUBLE + p.Float64, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30b: // p.String_ ID:3 thrift.STRING + p.String_, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x40a: // p.Int64 ID:4 thrift.I64 + p.Int64, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerJSON[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleInt2Float[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *InnerJSON) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.A = v - +func (p *JSONObject) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *InnerJSON) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - p.B = v + // p.A ID:1 thrift.STRING + off += 3 + off += 4 + len(p.A) - } - return offset, nil + // p.B ID:2 thrift.I08 + off += 3 + off += 1 + return off + 1 } -func (p *InnerJSON) FastReadField3(buf []byte) (int, error) { - offset := 0 +func (p *JSONObject) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *JSONObject) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - p.InnerForm = v + // p.A ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.A) - } - return offset, nil -} + // p.B ID:2 thrift.I08 + b[off] = 3 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = byte(p.B) + off++ -// for compatibility -func (p *InnerJSON) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *InnerJSON) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerJSON") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) +func (p *JSONObject) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.A ID:1 thrift.STRING + p.A, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x203: // p.B ID:2 thrift.I08 + p.B, l, err = x.ReadByte(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_JSONObject[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *InnerJSON) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerJSON") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() +func (p *ExampleJSONString) BLength() int { + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *InnerJSON) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.A) + // p.Query ID:1 thrift.STRUCT + off += 3 + off += p.Query.BLength() - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Query2 ID:2 thrift.LIST + off += 3 + off += 5 + for _, v := range p.Query2 { + off += 4 + len(v) + } -func (p *InnerJSON) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "B", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.B) + // p.Header ID:3 thrift.STRUCT + off += 3 + off += p.Header.BLength() - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Header2 ID:4 thrift.MAP + off += 3 + off += 6 + off += len(p.Header2) * 4 + for _, v := range p.Header2 { + off += 4 + len(v) + } -func (p *InnerJSON) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "inner_form", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.InnerForm) + // p.Cookie ID:5 thrift.STRUCT + off += 3 + off += p.Cookie.BLength() - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Cookie2 ID:6 thrift.SET + off += 3 + off += 5 + off += len(p.Cookie2) * 4 + return off + 1 } -func (p *InnerJSON) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("A", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.A) - - l += bthrift.Binary.FieldEndLength() - return l -} +func (p *ExampleJSONString) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *InnerJSON) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("B", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.B) +func (p *ExampleJSONString) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Query ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Query.FastWriteNocopy(b[off:], w) -func (p *InnerJSON) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("inner_form", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.InnerForm) + // p.Query2 ID:2 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + b[off] = 11 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.Query2))) + off += 5 + for _, v := range p.Query2 { + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.Header ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.Header.FastWriteNocopy(b[off:], w) + + // p.Header2 ID:4 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = 8 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Header2))) + off += 6 + for k, v := range p.Header2 { + binary.BigEndian.PutUint32(b[off:], uint32(k)) + off += 4 + off += thrift.Binary.WriteStringNocopy(b[off:], w, v) + } + + // p.Cookie ID:5 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += p.Cookie.FastWriteNocopy(b[off:], w) + + // p.Cookie2 ID:6 thrift.SET + b[off] = 14 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + b[off] = 8 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.Cookie2))) + off += 5 + for _, v := range p.Cookie2 { + binary.BigEndian.PutUint32(b[off:], uint32(v)) + off += 4 + } - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExamplePostForm) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleJSONString) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Query ID:1 thrift.STRUCT + p.Query = NewJSONObject() + l, err = p.Query.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20f: // p.Query2 ID:2 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Query2 = make([]string, sz) + for i := 0; i < sz; i++ { + p.Query2[i], l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l + isset |= 0x1 + case 0x30c: // p.Header ID:3 thrift.STRUCT + p.Header = NewJSONObject() + l, err = p.Header.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x2 + case 0x40d: // p.Header2 ID:4 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Header2 = make(map[int32]string, sz) + for i := 0; i < sz; i++ { + var k int32 + var v string + k, l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadString(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.Header2[k] = v } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l + isset |= 0x4 + case 0x50c: // p.Cookie ID:5 thrift.STRUCT + p.Cookie = NewJSONObject() + l, err = p.Cookie.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x60e: // p.Cookie2 ID:6 thrift.SET + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Cookie2 = make([]int32, sz) + for i := 0; i < sz; i++ { + p.Cookie2[i], l, err = x.ReadI32(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } + isset |= 0x8 default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError + if isset&0x1 == 0 { + fid = 2 // Query2 + goto RequiredFieldNotSetError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + if isset&0x2 == 0 { + fid = 3 // Header + goto RequiredFieldNotSetError + } + if isset&0x4 == 0 { + fid = 4 // Header2 + goto RequiredFieldNotSetError + } + if isset&0x8 == 0 { + fid = 6 // Cookie2 + goto RequiredFieldNotSetError + } + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExamplePostForm[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleJSONString[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleJSONString[fid])) } -func (p *ExamplePostForm) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Query = v - +func (p *ExamplePartial) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *ExamplePostForm) FastReadField2(buf []byte) (int, error) { - offset := 0 + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 +} - p.Form = v +func (p *ExamplePartial) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *ExamplePartial) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} + off := 0 -func (p *ExamplePostForm) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.JSON = NewInnerJSON() - if l, err := p.JSON.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) -// for compatibility -func (p *ExamplePostForm) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *ExamplePostForm) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExamplePostForm") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) +func (p *ExamplePartial) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExamplePartial[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExamplePostForm) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExamplePostForm") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() +func (p *ExamplePartial2) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Msg ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + off += 3 + off += 8 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExamplePostForm) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Query) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePostForm) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Form", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Form) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePostForm) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "JSON", thrift.STRUCT, 3) - offset += p.JSON.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExamplePostForm) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Query", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Query) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExamplePostForm) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Form", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Form) - - l += bthrift.Binary.FieldEndLength() - return l -} -func (p *ExamplePostForm) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("JSON", thrift.STRUCT, 3) - l += p.JSON.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Status ID:3 thrift.I32 + off += 3 + off += 4 + + // p.Header ID:4 thrift.BOOL + if p.Header != nil { + off += 3 + off += 1 + } + + // p.Code ID:6 thrift.I64 + off += 3 + off += 8 + + // p.InnerBase ID:7 thrift.STRUCT + off += 3 + off += p.InnerBase.BLength() + + // p.BaseResp ID:255 thrift.STRUCT + off += 3 + off += p.BaseResp.BLength() + + // p.Subfix ID:32767 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 +} + +func (p *ExamplePartial2) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExamplePartial2) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Msg ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) + + // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie != nil { + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(p.Cookie))) + off += 8 + } + + // p.Status ID:3 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Status)) + off += 4 + + // p.Header ID:4 thrift.BOOL + if p.Header != nil { + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(p.Header))) + off++ + } + + // p.Code ID:6 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Code)) + off += 8 + + // p.InnerBase ID:7 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 7) + off += 3 + off += p.InnerBase.FastWriteNocopy(b[off:], w) + + // p.BaseResp ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.BaseResp.FastWriteNocopy(b[off:], w) -func (p *InnerStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int + // p.Subfix ID:32767 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 32767) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.Subfix))) + off += 8 + + b[off] = 0 + return off + 1 +} + +func (p *ExamplePartial2) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetMust bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Msg ID:1 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x204: // p.Cookie ID:2 thrift.DOUBLE + if p.Cookie == nil { + p.Cookie = new(float64) + } + *p.Cookie, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x308: // p.Status ID:3 thrift.I32 + p.Status, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x402: // p.Header ID:4 thrift.BOOL + if p.Header == nil { + p.Header = new(bool) + } + *p.Header, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetMust = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x60a: // p.Code ID:6 thrift.I64 + p.Code, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x70c: // p.InnerBase ID:7 thrift.STRUCT + p.InnerBase = NewInnerBasePartial() + l, err = p.InnerBase.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0c: // p.BaseResp ID:255 thrift.STRUCT + p.BaseResp = base.NewBaseResp() + l, err = p.BaseResp.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE + p.Subfix, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - if !issetMust { - fieldId = 2 + if isset&0x1 == 0 { + fid = 3 // Status goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_InnerStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExamplePartial2[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_InnerStruct[fieldId])) + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExamplePartial2[fid])) } -func (p *InnerStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.InnerJSON = v - +func (p *InnerBasePartial) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *InnerStruct) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + off := 0 - p.Must = v + // p.Bool ID:1 thrift.BOOL + off += 3 + off += 1 - } - return offset, nil -} - -// for compatibility -func (p *InnerStruct) FastWrite(buf []byte) int { - return 0 + // p.Base ID:255 thrift.STRUCT + off += 3 + off += p.Base.BLength() + return off + 1 } -func (p *InnerStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "InnerStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *InnerBasePartial) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *InnerStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("InnerStruct") - if p != nil { - l += p.field1Length() - l += p.field2Length() +func (p *InnerBasePartial) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *InnerStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerJSON", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.InnerJSON) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *InnerStruct) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Must", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Must) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Bool ID:1 thrift.BOOL + b[off] = 2 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = *((*byte)(unsafe.Pointer(&p.Bool))) + off++ -func (p *InnerStruct) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerJSON", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.InnerJSON) + // p.Base ID:255 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += p.Base.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *InnerStruct) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Must", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.Must) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDynamicStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *InnerBasePartial) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetQuery bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetQuery = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x102: // p.Bool ID:1 thrift.BOOL + p.Bool, l, err = x.ReadBool(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0xff0c: // p.Base ID:255 thrift.STRUCT + p.Base = base.NewBase() + l, err = p.Base.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetQuery { - fieldId = 1 - goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDynamicStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerBasePartial[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleDynamicStruct[fieldId])) -} - -func (p *ExampleDynamicStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Query = v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleDynamicStruct) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.JSON = v - +func (p *ExampleFallback) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleDynamicStruct) FastReadField3(buf []byte) (int, error) { - offset := 0 - p.InnerStruct = NewInnerStruct() - if l, err := p.InnerStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} + // p.Msg ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Msg) -// for compatibility -func (p *ExampleDynamicStruct) FastWrite(buf []byte) int { - return 0 + // p.Heeader ID:3 thrift.STRING + off += 3 + off += 4 + len(p.Heeader) + return off + 1 } -func (p *ExampleDynamicStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDynamicStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleFallback) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleDynamicStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDynamicStruct") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() +func (p *ExampleFallback) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleDynamicStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Query", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Query) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDynamicStruct) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "JSON", thrift.STRING, 2) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.JSON) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDynamicStruct) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "InnerStruct", thrift.STRUCT, 3) - offset += p.InnerStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDynamicStruct) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Query", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Query) + // p.Msg ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDynamicStruct) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("JSON", thrift.STRING, 2) - l += bthrift.Binary.StringLengthNocopy(p.JSON) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Heeader ID:3 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Heeader) -func (p *ExampleDynamicStruct) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("InnerStruct", thrift.STRUCT, 3) - l += p.InnerStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleBase64Binary) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleFallback) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x20b: // p.Msg ID:2 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30b: // p.Heeader ID:3 thrift.STRING + p.Heeader, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleBase64Binary[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleFallback[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleBase64Binary) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - +func (p *InnerCode) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleBase64Binary) FastReadField2(buf []byte) (int, error) { - offset := 0 + // p.C1 ID:1 thrift.I64 + off += 3 + off += 8 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary2 = []byte(v) + // p.C2 ID:2 thrift.I16 + off += 3 + off += 2 + // p.C3 ID:3 thrift.LIST + off += 3 + off += 5 + for _, v := range p.C3 { + off += v.BLength() } - return offset, nil -} - -// for compatibility -func (p *ExampleBase64Binary) FastWrite(buf []byte) int { - return 0 + return off + 1 } -func (p *ExampleBase64Binary) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleBase64Binary") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *InnerCode) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleBase64Binary) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleBase64Binary") - if p != nil { - l += p.field1Length() - l += p.field2Length() +func (p *InnerCode) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleBase64Binary) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 1) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) + // p.C1 ID:1 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.C1)) + off += 8 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleBase64Binary) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary2", thrift.STRING, 2) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary2)) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.C2 ID:2 thrift.I16 + b[off] = 6 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint16(b[off:], uint16(p.C2)) + off += 2 -func (p *ExampleBase64Binary) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 1) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleBase64Binary) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary2", thrift.STRING, 2) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary2)) + // p.C3 ID:3 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + b[off] = 12 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.C3))) + off += 5 + for _, v := range p.C3 { + off += v.FastWriteNocopy(b[off:], w) + } - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleDefaultValue) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *InnerCode) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10a: // p.C1 ID:1 thrift.I64 + p.C1, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x206: // p.C2 ID:2 thrift.I16 + p.C2, l, err = x.ReadI16(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30f: // p.C3 ID:3 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l + p.C3 = make([]*InnerCode, sz) + for i := 0; i < sz; i++ { + p.C3[i] = NewInnerCode() + l, err = p.C3[i].FastRead(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleDefaultValue[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerCode[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleDefaultValue) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.A = v - - } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.B = v - - } - return offset, nil + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleDefaultValue) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.C = v - +func (p *ExampleApiBody) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -func (p *ExampleDefaultValue) FastReadField4(buf []byte) (int, error) { - offset := 0 + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Code ID:1 thrift.I64 + off += 3 + off += 8 - p.D = v - - } - return offset, nil -} + // p.Code2 ID:2 thrift.I16 + off += 3 + off += 2 -// for compatibility -func (p *ExampleDefaultValue) FastWrite(buf []byte) int { - return 0 + // p.InnerCode ID:3 thrift.STRUCT + off += 3 + off += p.InnerCode.BLength() + return off + 1 } -func (p *ExampleDefaultValue) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleDefaultValue") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleApiBody) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleDefaultValue) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleDefaultValue") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() +func (p *ExampleApiBody) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleDefaultValue) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.A) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleDefaultValue) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "B", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], p.B) + // p.Code ID:1 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Code)) + off += 8 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.C) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "D", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.D) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *ExampleDefaultValue) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("A", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.A) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("B", thrift.I32, 2) - l += bthrift.Binary.I32Length(p.B) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *ExampleDefaultValue) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("C", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.C) - - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Code2 ID:2 thrift.I16 + b[off] = 6 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint16(b[off:], uint16(p.Code2)) + off += 2 -func (p *ExampleDefaultValue) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("D", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.D) + // p.InnerCode ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.InnerCode.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleOptionalDefaultValue) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleApiBody) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetB bool = false - var issetD bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetB = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.DOUBLE { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetD = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10a: // p.Code ID:1 thrift.I64 + p.Code, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 5: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x206: // p.Code2 ID:2 thrift.I16 + p.Code2, l, err = x.ReadI16(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x30c: // p.InnerCode ID:3 thrift.STRUCT + p.InnerCode = NewInnerCode() + l, err = p.InnerCode.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetB { - fieldId = 2 - goto RequiredFieldNotSetError - } - - if !issetD { - fieldId = 4 - goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleOptionalDefaultValue[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleApiBody[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ExampleOptionalDefaultValue[fieldId])) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleOptionalDefaultValue) FastReadField1(buf []byte) (int, error) { - offset := 0 +func (p *InnerJSON) BLength() int { + if p == nil { + return 1 + } + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.A ID:1 thrift.STRING + off += 3 + off += 4 + len(p.A) - p.A = v + // p.B ID:2 thrift.I64 + off += 3 + off += 8 - } - return offset, nil + // p.InnerForm ID:3 thrift.DOUBLE + off += 3 + off += 8 + return off + 1 } -func (p *ExampleOptionalDefaultValue) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.B = v +func (p *InnerJSON) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *InnerJSON) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} + off := 0 + + // p.A ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.A) -func (p *ExampleOptionalDefaultValue) FastReadField3(buf []byte) (int, error) { - offset := 0 + // p.B ID:2 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.B)) + off += 8 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.InnerForm ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.InnerForm))) + off += 8 - p.C = v + b[off] = 0 + return off + 1 +} +func (p *InnerJSON) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.A ID:1 thrift.STRING + p.A, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20a: // p.B ID:2 thrift.I64 + p.B, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x304: // p.InnerForm ID:3 thrift.DOUBLE + p.InnerForm, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - return offset, nil + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerJSON[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleOptionalDefaultValue) FastReadField4(buf []byte) (int, error) { - offset := 0 +func (p *ExamplePostForm) BLength() int { + if p == nil { + return 1 + } + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Query ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Query) - p.D = v + // p.Form ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Form) - } - return offset, nil + // p.JSON ID:3 thrift.STRUCT + off += 3 + off += p.JSON.BLength() + return off + 1 } -func (p *ExampleOptionalDefaultValue) FastReadField5(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.E = &v +func (p *ExamplePostForm) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } +func (p *ExamplePostForm) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleOptionalDefaultValue) FastReadField6(buf []byte) (int, error) { - offset := 0 + // p.Query ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Query) - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.F = &v + // p.Form ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Form) - } - return offset, nil -} + // p.JSON ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.JSON.FastWriteNocopy(b[off:], w) -// for compatibility -func (p *ExampleOptionalDefaultValue) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *ExampleOptionalDefaultValue) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleOptionalDefaultValue") - if p != nil { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) +func (p *ExamplePostForm) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Query ID:1 thrift.STRING + p.Query, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20b: // p.Form ID:2 thrift.STRING + p.Form, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30c: // p.JSON ID:3 thrift.STRUCT + p.JSON = NewInnerJSON() + l, err = p.JSON.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExamplePostForm[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleOptionalDefaultValue) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleOptionalDefaultValue") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() +func (p *InnerStruct) BLength() int { + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + off := 0 + + // p.InnerJSON ID:1 thrift.STRING + off += 3 + off += 4 + len(p.InnerJSON) + + // p.Must ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Must) + return off + 1 } -func (p *ExampleOptionalDefaultValue) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetA() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.A) +func (p *InnerStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *InnerStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleOptionalDefaultValue) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "B", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], p.B) + // p.InnerJSON ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.InnerJSON) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Must ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Must) -func (p *ExampleOptionalDefaultValue) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetC() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.C) + b[off] = 0 + return off + 1 +} - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *InnerStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.InnerJSON ID:1 thrift.STRING + p.InnerJSON, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20b: // p.Must ID:2 thrift.STRING + p.Must, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + if isset&0x1 == 0 { + fid = 2 // Must + goto RequiredFieldNotSetError } - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_InnerStruct[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_InnerStruct[fid])) } -func (p *ExampleOptionalDefaultValue) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "D", thrift.STRING, 4) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.D) +func (p *ExampleDynamicStruct) BLength() int { + if p == nil { + return 1 + } + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Query ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Query) -func (p *ExampleOptionalDefaultValue) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetE() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "E", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.E) + // p.JSON ID:2 thrift.STRING + off += 3 + off += 4 + len(p.JSON) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset + // p.InnerStruct ID:3 thrift.STRUCT + off += 3 + off += p.InnerStruct.BLength() + return off + 1 } -func (p *ExampleOptionalDefaultValue) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetF() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "F", thrift.STRING, 6) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.F) +func (p *ExampleDynamicStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleDynamicStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleOptionalDefaultValue) field1Length() int { - l := 0 - if p.IsSetA() { - l += bthrift.Binary.FieldBeginLength("A", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.A) + // p.Query ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Query) - l += bthrift.Binary.FieldEndLength() - } - return l -} + // p.JSON ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.JSON) -func (p *ExampleOptionalDefaultValue) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("B", thrift.I32, 2) - l += bthrift.Binary.I32Length(p.B) + // p.InnerStruct ID:3 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + off += p.InnerStruct.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleOptionalDefaultValue) field3Length() int { - l := 0 - if p.IsSetC() { - l += bthrift.Binary.FieldBeginLength("C", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.C) - - l += bthrift.Binary.FieldEndLength() +func (p *ExampleDynamicStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Query ID:1 thrift.STRING + p.Query, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x20b: // p.JSON ID:2 thrift.STRING + p.JSON, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30c: // p.InnerStruct ID:3 thrift.STRUCT + p.InnerStruct = NewInnerStruct() + l, err = p.InnerStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + if isset&0x1 == 0 { + fid = 1 // Query + goto RequiredFieldNotSetError } - return l + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleDynamicStruct[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleDynamicStruct[fid])) } -func (p *ExampleOptionalDefaultValue) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("D", thrift.STRING, 4) - l += bthrift.Binary.StringLengthNocopy(p.D) +func (p *ExampleBase64Binary) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Binary ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Binary) - l += bthrift.Binary.FieldEndLength() - return l + // p.Binary2 ID:2 thrift.STRING + off += 3 + off += 4 + len(p.Binary2) + return off + 1 } -func (p *ExampleOptionalDefaultValue) field5Length() int { - l := 0 - if p.IsSetE() { - l += bthrift.Binary.FieldBeginLength("E", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(*p.E) +func (p *ExampleBase64Binary) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += bthrift.Binary.FieldEndLength() +func (p *ExampleBase64Binary) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l -} + off := 0 -func (p *ExampleOptionalDefaultValue) field6Length() int { - l := 0 - if p.IsSetF() { - l += bthrift.Binary.FieldBeginLength("F", thrift.STRING, 6) - l += bthrift.Binary.StringLengthNocopy(*p.F) + // p.Binary ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary) - l += bthrift.Binary.FieldEndLength() - } - return l + // p.Binary2 ID:2 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + off += thrift.Binary.WriteBinaryNocopy(b[off:], w, p.Binary2) + + b[off] = 0 + return off + 1 } -func (p *ExampleNoBodyStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleBase64Binary) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Binary ID:1 thrift.STRING + p.Binary, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x20b: // p.Binary2 ID:2 thrift.STRING + p.Binary2, l, err = x.ReadBinary(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleNoBodyStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleBase64Binary[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleNoBodyStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.NoBodyStruct = NewNoBodyStruct() - if l, err := p.NoBodyStruct.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleDefaultValue) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleNoBodyStruct) FastWrite(buf []byte) int { - return 0 -} + // p.A ID:1 thrift.STRING + off += 3 + off += 4 + len(p.A) -func (p *ExampleNoBodyStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleNoBodyStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + // p.B ID:2 thrift.I32 + off += 3 + off += 4 + + // p.C ID:3 thrift.DOUBLE + off += 3 + off += 8 + + // p.D ID:4 thrift.STRING + off += 3 + off += 4 + len(p.D) + return off + 1 } -func (p *ExampleNoBodyStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleNoBodyStruct") - if p != nil { - l += p.field1Length() +func (p *ExampleDefaultValue) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *ExampleDefaultValue) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleNoBodyStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "NoBodyStruct", thrift.STRUCT, 1) - offset += p.NoBodyStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.A ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.A) + + // p.B ID:2 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.B)) + off += 4 + + // p.C ID:3 thrift.DOUBLE + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.C))) + off += 8 -func (p *ExampleNoBodyStruct) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("NoBodyStruct", thrift.STRUCT, 1) - l += p.NoBodyStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l + // p.D ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.D) + + b[off] = 0 + return off + 1 } -func (p *NoBodyStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleDefaultValue) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.A ID:1 thrift.STRING + p.A, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x208: // p.B ID:2 thrift.I32 + p.B, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 3: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x304: // p.C ID:3 thrift.DOUBLE + p.C, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x40b: // p.D ID:4 thrift.STRING + p.D, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NoBodyStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleDefaultValue[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *NoBodyStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.A = &v - +func (p *ExampleOptionalDefaultValue) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *NoBodyStruct) FastReadField2(buf []byte) (int, error) { - offset := 0 + // p.A ID:1 thrift.STRING + if p.A != "hello" { + off += 3 + off += 4 + len(p.A) + } - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.B = &v + // p.B ID:2 thrift.I32 + off += 3 + off += 4 + // p.C ID:3 thrift.DOUBLE + if p.C != 1.2 { + off += 3 + off += 8 } - return offset, nil -} -func (p *NoBodyStruct) FastReadField3(buf []byte) (int, error) { - offset := 0 + // p.D ID:4 thrift.STRING + off += 3 + off += 4 + len(p.D) - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.C = v + // p.E ID:5 thrift.STRING + if p.E != nil { + off += 3 + off += 4 + len(*p.E) + } + // p.F ID:6 thrift.STRING + if p.F != nil { + off += 3 + off += 4 + len(*p.F) } - return offset, nil + return off + 1 } -// for compatibility -func (p *NoBodyStruct) FastWrite(buf []byte) int { - return 0 -} +func (p *ExampleOptionalDefaultValue) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *NoBodyStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NoBodyStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) +func (p *ExampleOptionalDefaultValue) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *NoBodyStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NoBodyStruct") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() + // p.A ID:1 thrift.STRING + if p.A != "hello" { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.A) } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} -func (p *NoBodyStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetA() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "A", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], *p.A) + // p.B ID:2 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.B)) + off += 4 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.C ID:3 thrift.DOUBLE + if p.C != 1.2 { + b[off] = 4 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], *(*uint64)(unsafe.Pointer(&p.C))) + off += 8 } - return offset -} -func (p *NoBodyStruct) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetB() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "B", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], *p.B) + // p.D ID:4 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.D) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.E ID:5 thrift.STRING + if p.E != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.E) } - return offset -} -func (p *NoBodyStruct) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetC() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "C", thrift.I32, 3) - offset += bthrift.Binary.WriteI32(buf[offset:], p.C) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.F ID:6 thrift.STRING + if p.F != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.F) } - return offset -} -func (p *NoBodyStruct) field1Length() int { - l := 0 - if p.IsSetA() { - l += bthrift.Binary.FieldBeginLength("A", thrift.I32, 1) - l += bthrift.Binary.I32Length(*p.A) + b[off] = 0 + return off + 1 +} - l += bthrift.Binary.FieldEndLength() +func (p *ExampleOptionalDefaultValue) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.A ID:1 thrift.STRING + p.A, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x208: // p.B ID:2 thrift.I32 + p.B, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x304: // p.C ID:3 thrift.DOUBLE + p.C, l, err = x.ReadDouble(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x40b: // p.D ID:4 thrift.STRING + p.D, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x2 + case 0x50b: // p.E ID:5 thrift.STRING + if p.E == nil { + p.E = new(string) + } + *p.E, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x60b: // p.F ID:6 thrift.STRING + if p.F == nil { + p.F = new(string) + } + *p.F, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } + } + if isset&0x1 == 0 { + fid = 2 // B + goto RequiredFieldNotSetError + } + if isset&0x2 == 0 { + fid = 4 // D + goto RequiredFieldNotSetError } - return l + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleOptionalDefaultValue[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) +RequiredFieldNotSetError: + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_ExampleOptionalDefaultValue[fid])) } -func (p *NoBodyStruct) field2Length() int { - l := 0 - if p.IsSetB() { - l += bthrift.Binary.FieldBeginLength("B", thrift.I32, 2) - l += bthrift.Binary.I32Length(*p.B) - - l += bthrift.Binary.FieldEndLength() +func (p *ExampleNoBodyStruct) BLength() int { + if p == nil { + return 1 } - return l + off := 0 + + // p.NoBodyStruct ID:1 thrift.STRUCT + off += 3 + off += p.NoBodyStruct.BLength() + return off + 1 } -func (p *NoBodyStruct) field3Length() int { - l := 0 - if p.IsSetC() { - l += bthrift.Binary.FieldBeginLength("C", thrift.I32, 3) - l += bthrift.Binary.I32Length(p.C) +func (p *ExampleNoBodyStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += bthrift.Binary.FieldEndLength() +func (p *ExampleNoBodyStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l + off := 0 + + // p.NoBodyStruct ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.NoBodyStruct.FastWriteNocopy(b[off:], w) + + b[off] = 0 + return off + 1 } -func (p *Exception) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleNoBodyStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 255: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField255(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.NoBodyStruct ID:1 thrift.STRUCT + p.NoBodyStruct = NewNoBodyStruct() + l, err = p.NoBodyStruct.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleNoBodyStruct[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *Exception) FastReadField1(buf []byte) (int, error) { - offset := 0 +func (p *NoBodyStruct) BLength() int { + if p == nil { + return 1 + } + off := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.A ID:1 thrift.I32 + if p.A != nil { + off += 3 + off += 4 + } - p.Code = v + // p.B ID:2 thrift.I32 + if p.B != nil { + off += 3 + off += 4 + } + // p.C ID:3 thrift.I32 + if p.C != 1 { + off += 3 + off += 4 } - return offset, nil + return off + 1 } -func (p *Exception) FastReadField255(buf []byte) (int, error) { - offset := 0 +func (p *NoBodyStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *NoBodyStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.A ID:1 thrift.I32 + if p.A != nil { + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(*p.A)) + off += 4 + } - p.Msg = v + // p.B ID:2 thrift.I32 + if p.B != nil { + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(*p.B)) + off += 4 + } + // p.C ID:3 thrift.I32 + if p.C != 1 { + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.C)) + off += 4 } - return offset, nil -} -// for compatibility -func (p *Exception) FastWrite(buf []byte) int { - return 0 + b[off] = 0 + return off + 1 } -func (p *Exception) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Exception") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField255(buf[offset:], binaryWriter) +func (p *NoBodyStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x108: // p.A ID:1 thrift.I32 + if p.A == nil { + p.A = new(int32) + } + *p.A, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x208: // p.B ID:2 thrift.I32 + if p.B == nil { + p.B = new(int32) + } + *p.B, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x308: // p.C ID:3 thrift.I32 + p.C, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_NoBodyStruct[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *Exception) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Exception") - if p != nil { - l += p.field1Length() - l += p.field255Length() + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *Exception) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I32, 1) - offset += bthrift.Binary.WriteI32(buf[offset:], p.Code) + // p.Code ID:1 thrift.I32 + off += 3 + off += 4 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + // p.Msg ID:255 thrift.STRING + off += 3 + off += 4 + len(p.Msg) + return off + 1 } -func (p *Exception) fastWriteField255(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 255) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg) +func (p *Exception) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Exception) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("code", thrift.I32, 1) - l += bthrift.Binary.I32Length(p.Code) +func (p *Exception) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 - l += bthrift.Binary.FieldEndLength() - return l -} + // p.Code ID:1 thrift.I32 + b[off] = 8 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint32(b[off:], uint32(p.Code)) + off += 4 -func (p *Exception) field255Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 255) - l += bthrift.Binary.StringLengthNocopy(p.Msg) + // p.Msg ID:255 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 255) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Msg) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *Exception) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x108: // p.Code ID:1 thrift.I32 + p.Code, l, err = x.ReadI32(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0xff0b: // p.Msg ID:255 thrift.STRING + p.Msg, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_Exception[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleReq() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceExampleMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceExampleMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceExampleMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceExampleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceExampleMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceExampleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleReq() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceExampleMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceExampleMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleResp() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceExampleMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -func (p *ExampleServiceExampleMethodResult) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Err = NewException() - if l, err := p.Err.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - return offset, nil -} -// for compatibility -func (p *ExampleServiceExampleMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ExampleMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + off += 3 + off += p.Err.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceExampleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ExampleMethod_result") - if p != nil { - l += p.field0Length() - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceExampleMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceExampleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceExampleMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceExampleMethodResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetErr() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "err", thrift.STRUCT, 1) - offset += p.Err.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return offset -} -func (p *ExampleServiceExampleMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Err ID:1 thrift.STRUCT + if p.Err != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Err.FastWriteNocopy(b[off:], w) } - return l -} -func (p *ExampleServiceExampleMethodResult) field1Length() int { - l := 0 - if p.IsSetErr() { - l += bthrift.Binary.FieldBeginLength("err", thrift.STRUCT, 1) - l += p.Err.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceErrorMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceExampleMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleResp() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x10c: // p.Err ID:1 thrift.STRUCT + p.Err = NewException() + l, err = p.Err.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceErrorMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceExampleMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceErrorMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleError() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceErrorMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceErrorMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceErrorMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ErrorMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceErrorMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceErrorMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ErrorMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceErrorMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceErrorMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceErrorMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceErrorMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceErrorMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleError() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceErrorMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceErrorMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceErrorMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleErrorResp() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceErrorMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceErrorMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceErrorMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ErrorMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceErrorMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ErrorMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceErrorMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceErrorMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceErrorMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceErrorMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceInt2FloatMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceErrorMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleErrorResp() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceInt2FloatMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceErrorMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceInt2FloatMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleInt2Float() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceInt2FloatMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceInt2FloatMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceInt2FloatMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Int2FloatMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceInt2FloatMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceInt2FloatMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Int2FloatMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceInt2FloatMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceInt2FloatMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceInt2FloatMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceInt2FloatMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceInt2FloatMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleInt2Float() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceInt2FloatMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceInt2FloatMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceInt2FloatMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleInt2Float() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceInt2FloatMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceInt2FloatMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceInt2FloatMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Int2FloatMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceInt2FloatMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Int2FloatMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceInt2FloatMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceInt2FloatMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceInt2FloatMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceInt2FloatMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceJSONStringMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceInt2FloatMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleInt2Float() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceJSONStringMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceInt2FloatMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceJSONStringMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleJSONString() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceJSONStringMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceJSONStringMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceJSONStringMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "JSONStringMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceJSONStringMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceJSONStringMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("JSONStringMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceJSONStringMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceJSONStringMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceJSONStringMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceJSONStringMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceJSONStringMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleJSONString() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceJSONStringMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceJSONStringMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceJSONStringMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleJSONString() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceJSONStringMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceJSONStringMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceJSONStringMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "JSONStringMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceJSONStringMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("JSONStringMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceJSONStringMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceJSONStringMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceJSONStringMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceJSONStringMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServicePartialMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceJSONStringMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleJSONString() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePartialMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceJSONStringMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePartialMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExamplePartial2() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServicePartialMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServicePartialMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServicePartialMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServicePartialMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePartialMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServicePartialMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServicePartialMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServicePartialMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServicePartialMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePartialMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExamplePartial2() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePartialMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePartialMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePartialMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExamplePartial() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServicePartialMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServicePartialMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServicePartialMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServicePartialMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServicePartialMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePartialMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServicePartialMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServicePartialMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFallbackMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePartialMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExamplePartial() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFallbackMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePartialMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFallbackMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleFallback() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFallbackMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceFallbackMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceFallbackMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "FallbackMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceFallbackMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFallbackMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("FallbackMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceFallbackMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceFallbackMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceFallbackMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceFallbackMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFallbackMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleFallback() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceFallbackMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFallbackMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceFallbackMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleFallback() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceFallbackMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceFallbackMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceFallbackMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "FallbackMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceFallbackMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("FallbackMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceFallbackMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceFallbackMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceFallbackMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceFallbackMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceApiBodyMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceFallbackMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleFallback() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceApiBodyMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceFallbackMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceApiBodyMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleApiBody() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceApiBodyMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceApiBodyMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceApiBodyMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ApiBodyMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceApiBodyMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceApiBodyMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ApiBodyMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceApiBodyMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceApiBodyMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceApiBodyMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceApiBodyMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceApiBodyMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleApiBody() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceApiBodyMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceApiBodyMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceApiBodyMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleApiBody() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceApiBodyMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceApiBodyMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceApiBodyMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "ApiBodyMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceApiBodyMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("ApiBodyMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *ExampleServiceApiBodyMethodResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceApiBodyMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceApiBodyMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceApiBodyMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServicePostFormMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceApiBodyMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleApiBody() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePostFormMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceApiBodyMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePostFormMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExamplePostForm() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServicePostFormMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServicePostFormMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServicePostFormMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PostFormMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServicePostFormMethodArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePostFormMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PostFormMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServicePostFormMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServicePostFormMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServicePostFormMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServicePostFormMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePostFormMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExamplePostForm() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServicePostFormMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePostFormMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServicePostFormMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExamplePostForm() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServicePostFormMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServicePostFormMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServicePostFormMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PostFormMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServicePostFormMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PostFormMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServicePostFormMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServicePostFormMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServicePostFormMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServicePostFormMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceDynamicStructMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServicePostFormMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExamplePostForm() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDynamicStructMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServicePostFormMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceDynamicStructMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleDynamicStruct() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceDynamicStructMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceDynamicStructMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceDynamicStructMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DynamicStructMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceDynamicStructMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceDynamicStructMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("DynamicStructMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceDynamicStructMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceDynamicStructMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceDynamicStructMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceDynamicStructMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceDynamicStructMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleDynamicStruct() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDynamicStructMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceDynamicStructMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceDynamicStructMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleDynamicStruct() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceDynamicStructMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceDynamicStructMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceDynamicStructMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DynamicStructMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceDynamicStructMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("DynamicStructMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceDynamicStructMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceDynamicStructMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceDynamicStructMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceDynamicStructMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceBase64BinaryMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceDynamicStructMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleDynamicStruct() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceBase64BinaryMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceDynamicStructMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceBase64BinaryMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleBase64Binary() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceBase64BinaryMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceBase64BinaryMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceBase64BinaryMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Base64BinaryMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceBase64BinaryMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceBase64BinaryMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Base64BinaryMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceBase64BinaryMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceBase64BinaryMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceBase64BinaryMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceBase64BinaryMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceBase64BinaryMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleBase64Binary() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceBase64BinaryMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceBase64BinaryMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceBase64BinaryMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleBase64Binary() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceBase64BinaryMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceBase64BinaryMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceBase64BinaryMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Base64BinaryMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceBase64BinaryMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Base64BinaryMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceBase64BinaryMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceBase64BinaryMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceBase64BinaryMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceBase64BinaryMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceDefaultValueMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceBase64BinaryMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleBase64Binary() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDefaultValueMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceBase64BinaryMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceDefaultValueMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleDefaultValue() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceDefaultValueMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceDefaultValueMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceDefaultValueMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DefaultValueMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceDefaultValueMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceDefaultValueMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("DefaultValueMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceDefaultValueMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceDefaultValueMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceDefaultValueMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceDefaultValueMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceDefaultValueMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleDefaultValue() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceDefaultValueMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceDefaultValueMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceDefaultValueMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleDefaultValue() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceDefaultValueMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceDefaultValueMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceDefaultValueMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "DefaultValueMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceDefaultValueMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("DefaultValueMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceDefaultValueMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceDefaultValueMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceDefaultValueMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceDefaultValueMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceDefaultValueMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleDefaultValue() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOptionalDefaultValueMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceDefaultValueMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleOptionalDefaultValue() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceOptionalDefaultValueMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "OptionalDefaultValueMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceOptionalDefaultValueMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("OptionalDefaultValueMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceOptionalDefaultValueMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceOptionalDefaultValueMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceOptionalDefaultValueMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceOptionalDefaultValueMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleOptionalDefaultValue() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceOptionalDefaultValueMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceOptionalDefaultValueMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceOptionalDefaultValueMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleOptionalDefaultValue() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceOptionalDefaultValueMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceOptionalDefaultValueMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceOptionalDefaultValueMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "OptionalDefaultValueMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceOptionalDefaultValueMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("OptionalDefaultValueMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceOptionalDefaultValueMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceOptionalDefaultValueMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceOptionalDefaultValueMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceOptionalDefaultValueMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceNoBodyStructMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceOptionalDefaultValueMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleOptionalDefaultValue() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceNoBodyStructMethodArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceOptionalDefaultValueMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceNoBodyStructMethodArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewExampleNoBodyStruct() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceNoBodyStructMethodArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceNoBodyStructMethodArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *ExampleServiceNoBodyStructMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NoBodyStructMethod_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset +func (p *ExampleServiceNoBodyStructMethodArgs) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceNoBodyStructMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NoBodyStructMethod_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceNoBodyStructMethodArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *ExampleServiceNoBodyStructMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) -func (p *ExampleServiceNoBodyStructMethodArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceNoBodyStructMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceNoBodyStructMethodArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewExampleNoBodyStruct() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceNoBodyStructMethodResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceNoBodyStructMethodArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceNoBodyStructMethodResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewExampleNoBodyStruct() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *ExampleServiceNoBodyStructMethodResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceNoBodyStructMethodResult) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *ExampleServiceNoBodyStructMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NoBodyStructMethod_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *ExampleServiceNoBodyStructMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NoBodyStructMethod_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l +func (p *ExampleServiceNoBodyStructMethodResult) FastWrite(b []byte) int { + return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceNoBodyStructMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceNoBodyStructMethodResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} + off := 0 -func (p *ExampleServiceNoBodyStructMethodResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceStringArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceNoBodyStructMethodResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewExampleNoBodyStruct() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceStringArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceNoBodyStructMethodResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceStringArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Req = v - +func (p *ExampleServiceStringArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceStringArgs) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRING + off += 3 + off += 4 + len(p.Req) + return off + 1 } -func (p *ExampleServiceStringArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "String_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceStringArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceStringArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("String_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceStringArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleServiceStringArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Req) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceStringArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Req) + // p.Req ID:1 thrift.STRING + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, p.Req) - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceStringResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceStringArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10b: // p.Req ID:1 thrift.STRING + p.Req, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceStringResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceStringArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceStringResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Success = &v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceStringResult) FastWrite(buf []byte) int { - return 0 + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceStringResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "String_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) +func (p *ExampleServiceStringResult) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceStringResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("String_result") - if p != nil { - l += p.field0Length() + // p.Success ID:0 thrift.STRING + if p.Success != nil { + off += 3 + off += 4 + len(*p.Success) } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l + return off + 1 } -func (p *ExampleServiceStringResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRING, 0) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, *p.Success) +func (p *ExampleServiceStringResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) +func (p *ExampleServiceStringResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return offset -} - -func (p *ExampleServiceStringResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRING, 0) - l += bthrift.Binary.StringLengthNocopy(*p.Success) + off := 0 - l += bthrift.Binary.FieldEndLength() + // p.Success ID:0 thrift.STRING + if p.Success != nil { + b[off] = 11 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += thrift.Binary.WriteStringNocopy(b[off:], w, *p.Success) } - return l + + b[off] = 0 + return off + 1 } -func (p *ExampleServiceI64Args) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceStringResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xb: // p.Success ID:0 thrift.STRING + if p.Success == nil { + p.Success = new(string) + } + *p.Success, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceI64Args[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceStringResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *ExampleServiceI64Args) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Req = v - +func (p *ExampleServiceI64Args) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *ExampleServiceI64Args) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.I64 + off += 3 + off += 8 + return off + 1 } -func (p *ExampleServiceI64Args) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "I64_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *ExampleServiceI64Args) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *ExampleServiceI64Args) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("I64_args") - if p != nil { - l += p.field1Length() +func (p *ExampleServiceI64Args) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleServiceI64Args) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Req) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + off := 0 -func (p *ExampleServiceI64Args) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Req) + // p.Req ID:1 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Req)) + off += 8 - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *ExampleServiceI64Result) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *ExampleServiceI64Args) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10a: // p.Req ID:1 thrift.I64 + p.Req, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ExampleServiceI64Result[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceI64Args[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *ExampleServiceI64Result) FastReadField0(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Success = &v - - } - return offset, nil -} - -// for compatibility -func (p *ExampleServiceI64Result) FastWrite(buf []byte) int { - return 0 -} - -func (p *ExampleServiceI64Result) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "I64_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } func (p *ExampleServiceI64Result) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("I64_result") - if p != nil { - l += p.field0Length() + if p == nil { + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *ExampleServiceI64Result) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.I64, 0) - offset += bthrift.Binary.WriteI64(buf[offset:], *p.Success) + off := 0 - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + // p.Success ID:0 thrift.I64 + if p.Success != nil { + off += 3 + off += 8 } - return offset + return off + 1 } -func (p *ExampleServiceI64Result) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.I64, 0) - l += bthrift.Binary.I64Length(*p.Success) +func (p *ExampleServiceI64Result) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += bthrift.Binary.FieldEndLength() +func (p *ExampleServiceI64Result) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l -} - -func (p *ExampleServiceExampleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceExampleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceErrorMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceErrorMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceInt2FloatMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceInt2FloatMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceJSONStringMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceJSONStringMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServicePartialMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServicePartialMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceFallbackMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceFallbackMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceApiBodyMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceApiBodyMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServicePostFormMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServicePostFormMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceDynamicStructMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceDynamicStructMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceBase64BinaryMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceBase64BinaryMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceDefaultValueMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceDefaultValueMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceOptionalDefaultValueMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceOptionalDefaultValueMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceNoBodyStructMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceNoBodyStructMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceStringArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceStringResult) GetResult() interface{} { - return p.Success -} - -func (p *ExampleServiceI64Args) GetFirstArgument() interface{} { - return p.Req -} - -func (p *ExampleServiceI64Result) GetResult() interface{} { - return p.Success -} + off := 0 -func (p *InnerBase) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} -func (p *ExampleReq) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() - } - return p.Base -} -func (p *InnerBasePartial) GetOrSetBase() interface{} { - if p.Base == nil { - p.Base = base.NewBase() + // p.Success ID:0 thrift.I64 + if p.Success != nil { + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(*p.Success)) + off += 8 } - return p.Base -} -func (p *ExampleResp) GetOrSetBaseResp() interface{} { - if p.BaseResp == nil { - p.BaseResp = base.NewBaseResp() - } - return p.BaseResp + b[off] = 0 + return off + 1 } -func (p *ExamplePartial2) GetOrSetBaseResp() interface{} { - if p.BaseResp == nil { - p.BaseResp = base.NewBaseResp() + +func (p *ExampleServiceI64Result) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} + for { + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldBeginError + } + if ftyp == thrift.STOP { + break + } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xa: // p.Success ID:0 thrift.I64 + if p.Success == nil { + p.Success = new(int64) + } + *p.Success, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + default: + l, err = x.Skip(b[off:], ftyp) + off += l + if err != nil { + goto SkipFieldError + } + } } - return p.BaseResp + return +ReadFieldBeginError: + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) +ReadFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleServiceI64Result[fid]), err) +SkipFieldError: + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/null/k-null.go b/testdata/kitex_gen/null/k-null.go index 08b01977..52495862 100644 --- a/testdata/kitex_gen/null/k-null.go +++ b/testdata/kitex_gen/null/k-null.go @@ -1,765 +1,392 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package null import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/dynamicgo/internal/bthrift" -) -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) + "github.com/cloudwego/gopkg/protocol/thrift" ) -func (p *NullStruct) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetNull3 bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError +func (p *NullStruct) BLength() int { + if p == nil { + return 1 + } + off := 0 + + // p.Null1 ID:1 thrift.I64 + off += 3 + off += 8 + + // p.Null2 ID:2 thrift.I64 + if p.Null2 != nil { + off += 3 + off += 8 + } + + // p.Null3 ID:3 thrift.I64 + off += 3 + off += 8 + + // p.Null4 ID:4 thrift.LIST + off += 3 + off += 5 + off += len(p.Null4) * 8 + + // p.Null5 ID:5 thrift.MAP + off += 3 + off += 6 + off += len(p.Null5) * 8 + for k, _ := range p.Null5 { + off += 4 + len(k) + } + + // p.Null6 ID:6 thrift.MAP + off += 3 + off += 6 + off += len(p.Null6) * (8 + 8) + return off + 1 +} + +func (p *NullStruct) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *NullStruct) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Null1 ID:1 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Null1)) + off += 8 + + // p.Null2 ID:2 thrift.I64 + if p.Null2 != nil { + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 2) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(*p.Null2)) + off += 8 + } + + // p.Null3 ID:3 thrift.I64 + b[off] = 10 + binary.BigEndian.PutUint16(b[off+1:], 3) + off += 3 + binary.BigEndian.PutUint64(b[off:], uint64(p.Null3)) + off += 8 + + // p.Null4 ID:4 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 4) + off += 3 + b[off] = 10 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.Null4))) + off += 5 + for _, v := range p.Null4 { + binary.BigEndian.PutUint64(b[off:], uint64(v)) + off += 8 + } + + // p.Null5 ID:5 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 5) + off += 3 + b[off] = 11 + b[off+1] = 10 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Null5))) + off += 6 + for k, v := range p.Null5 { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k) + binary.BigEndian.PutUint64(b[off:], uint64(v)) + off += 8 + } + + // p.Null6 ID:6 thrift.MAP + b[off] = 13 + binary.BigEndian.PutUint16(b[off+1:], 6) + off += 3 + b[off] = 10 + b[off+1] = 10 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(p.Null6))) + off += 6 + for k, v := range p.Null6 { + binary.BigEndian.PutUint64(b[off:], uint64(k)) + off += 8 + binary.BigEndian.PutUint64(b[off:], uint64(v)) + off += 8 } + b[off] = 0 + return off + 1 +} + +func (p *NullStruct) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + var isset uint8 + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10a: // p.Null1 ID:1 thrift.I64 + p.Null1, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 2: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + case 0x20a: // p.Null2 ID:2 thrift.I64 + if p.Null2 == nil { + p.Null2 = new(int64) } - case 3: - if fieldTypeId == thrift.I64 { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetNull3 = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + *p.Null2, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + case 0x30a: // p.Null3 ID:3 thrift.I64 + p.Null3, l, err = x.ReadI64(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + isset |= 0x1 + case 0x40f: // p.Null4 ID:4 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 4: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField4(buf[offset:]) - offset += l + p.Null4 = make([]int64, sz) + for i := 0; i < sz; i++ { + p.Null4[i], l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } } - case 5: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField5(buf[offset:]) - offset += l + case 0x50d: // p.Null5 ID:5 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.Null5 = make(map[string]int64, sz) + for i := 0; i < sz; i++ { + var k string + var v int64 + k, l, err = x.ReadString(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadI64(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.Null5[k] = v + } + case 0x60d: // p.Null6 ID:6 thrift.MAP + var sz int + _, _, sz, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError } - case 6: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField6(buf[offset:]) - offset += l + p.Null6 = make(map[int64]int64, sz) + for i := 0; i < sz; i++ { + var k int64 + var v int64 + k, l, err = x.ReadI64(b[off:]) + off += l if err != nil { goto ReadFieldError } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + v, l, err = x.ReadI64(b[off:]) + off += l if err != nil { - goto SkipFieldError + goto ReadFieldError } + p.Null6[k] = v } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - if !issetNull3 { - fieldId = 3 + if isset&0x1 == 0 { + fid = 3 // Null3 goto RequiredFieldNotSetError } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullStruct[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_NullStruct[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_NullStruct[fieldId])) -} - -func (p *NullStruct) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Null1 = v - - } - return offset, nil -} - -func (p *NullStruct) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - p.Null2 = &v - - } - return offset, nil -} - -func (p *NullStruct) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Null3 = v - - } - return offset, nil -} - -func (p *NullStruct) FastReadField4(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Null4 = make([]int64, 0, size) - for i := 0; i < size; i++ { - var _elem int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.Null4 = append(p.Null4, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *NullStruct) FastReadField5(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Null5 = make(map[string]int64, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Null5[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *NullStruct) FastReadField6(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Null6 = make(map[int64]int64, size) - for i := 0; i < size; i++ { - var _key int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Null6[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *NullStruct) FastWrite(buf []byte) int { - return 0 -} - -func (p *NullStruct) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NullStruct") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - offset += p.fastWriteField3(buf[offset:], binaryWriter) - offset += p.fastWriteField4(buf[offset:], binaryWriter) - offset += p.fastWriteField5(buf[offset:], binaryWriter) - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *NullStruct) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NullStruct") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *NullStruct) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null1", thrift.I64, 1) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Null1) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *NullStruct) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetNull2() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null2", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], *p.Null2) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *NullStruct) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null3", thrift.I64, 3) - offset += bthrift.Binary.WriteI64(buf[offset:], p.Null3) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *NullStruct) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null4", thrift.LIST, 4) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.I64, len(p.Null4)) - for _, v := range p.Null4 { - offset += bthrift.Binary.WriteI64(buf[offset:], v) - - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *NullStruct) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null5", thrift.MAP, 5) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.I64, len(p.Null5)) - for k, v := range p.Null5 { - - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - - offset += bthrift.Binary.WriteI64(buf[offset:], v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + return off, thrift.NewProtocolException(thrift.INVALID_DATA, fmt.Sprintf("required field %s is not set", fieldIDToName_NullStruct[fid])) } -func (p *NullStruct) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Null6", thrift.MAP, 6) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.I64, thrift.I64, len(p.Null6)) - for k, v := range p.Null6 { - - offset += bthrift.Binary.WriteI64(buf[offset:], k) - - offset += bthrift.Binary.WriteI64(buf[offset:], v) - +func (p *NullServiceNullTestArgs) BLength() int { + if p == nil { + return 1 } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *NullStruct) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Null1", thrift.I64, 1) - l += bthrift.Binary.I64Length(p.Null1) + off := 0 - l += bthrift.Binary.FieldEndLength() - return l + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *NullStruct) field2Length() int { - l := 0 - if p.IsSetNull2() { - l += bthrift.Binary.FieldBeginLength("Null2", thrift.I64, 2) - l += bthrift.Binary.I64Length(*p.Null2) +func (p *NullServiceNullTestArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } - l += bthrift.Binary.FieldEndLength() +func (p *NullServiceNullTestArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - return l -} - -func (p *NullStruct) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Null3", thrift.I64, 3) - l += bthrift.Binary.I64Length(p.Null3) - - l += bthrift.Binary.FieldEndLength() - return l -} + off := 0 -func (p *NullStruct) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Null4", thrift.LIST, 4) - l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.Null4)) - var tmpV int64 - l += bthrift.Binary.I64Length(int64(tmpV)) * len(p.Null4) - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *NullStruct) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Null5", thrift.MAP, 5) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.I64, len(p.Null5)) - for k, v := range p.Null5 { - - l += bthrift.Binary.StringLength(k) + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) - l += bthrift.Binary.I64Length(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *NullStruct) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Null6", thrift.MAP, 6) - l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.I64, len(p.Null6)) - var tmpK int64 - var tmpV int64 - l += (bthrift.Binary.I64Length(int64(tmpK)) + bthrift.Binary.I64Length(int64(tmpV))) * len(p.Null6) - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *NullServiceNullTestArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *NullServiceNullTestArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewNullStruct() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_NullServiceNullTestArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *NullServiceNullTestArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewNullStruct() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *NullServiceNullTestResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *NullServiceNullTestArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *NullServiceNullTestArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NullTest_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *NullServiceNullTestArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NullTest_args") - if p != nil { - l += p.field1Length() +func (p *NullServiceNullTestResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *NullServiceNullTestResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} + off := 0 -func (p *NullServiceNullTestArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) + } -func (p *NullServiceNullTestArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *NullServiceNullTestResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *NullServiceNullTestResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewNullStruct() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_NullServiceNullTestResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *NullServiceNullTestResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewNullStruct() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *NullServiceNullTestResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *NullServiceNullTestResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NullTest_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *NullServiceNullTestResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NullTest_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *NullServiceNullTestResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *NullServiceNullTestResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *NullServiceNullTestArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *NullServiceNullTestResult) GetResult() interface{} { - return p.Success + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/null/null.go b/testdata/kitex_gen/null/null.go index aef0aefd..a52381a7 100644 --- a/testdata/kitex_gen/null/null.go +++ b/testdata/kitex_gen/null/null.go @@ -1,16 +1,15 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package null import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) type NullStruct struct { Null1 int64 `thrift:"Null1,1" json:"Null1"` - Null2 *int64 `thrift:"Null2,2" json:"Null2,omitempty"` + Null2 *int64 `thrift:"Null2,2,optional" json:"Null2,omitempty"` Null3 int64 `thrift:"Null3,3,required" json:"Null3"` Null4 []int64 `thrift:"Null4,4" json:"Null4"` Null5 map[string]int64 `thrift:"Null5,5" json:"Null5"` @@ -21,6 +20,9 @@ func NewNullStruct() *NullStruct { return &NullStruct{} } +func (p *NullStruct) InitDefault() { +} + func (p *NullStruct) GetNull1() (v int64) { return p.Null1 } @@ -49,449 +51,11 @@ func (p *NullStruct) GetNull5() (v map[string]int64) { func (p *NullStruct) GetNull6() (v map[int64]int64) { return p.Null6 } -func (p *NullStruct) SetNull1(val int64) { - p.Null1 = val -} -func (p *NullStruct) SetNull2(val *int64) { - p.Null2 = val -} -func (p *NullStruct) SetNull3(val int64) { - p.Null3 = val -} -func (p *NullStruct) SetNull4(val []int64) { - p.Null4 = val -} -func (p *NullStruct) SetNull5(val map[string]int64) { - p.Null5 = val -} -func (p *NullStruct) SetNull6(val map[int64]int64) { - p.Null6 = val -} - -var fieldIDToName_NullStruct = map[int16]string{ - 1: "Null1", - 2: "Null2", - 3: "Null3", - 4: "Null4", - 5: "Null5", - 6: "Null6", -} func (p *NullStruct) IsSetNull2() bool { return p.Null2 != nil } -func (p *NullStruct) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetNull3 bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I64 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.I64 { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - issetNull3 = true - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.LIST { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.MAP { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetNull3 { - fieldId = 3 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullStruct[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_NullStruct[fieldId])) -} - -func (p *NullStruct) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Null1 = v - } - return nil -} - -func (p *NullStruct) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Null2 = &v - } - return nil -} - -func (p *NullStruct) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.Null3 = v - } - return nil -} - -func (p *NullStruct) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.Null4 = make([]int64, 0, size) - for i := 0; i < size; i++ { - var _elem int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _elem = v - } - - p.Null4 = append(p.Null4, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *NullStruct) ReadField5(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Null5 = make(map[string]int64, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _val = v - } - - p.Null5[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *NullStruct) ReadField6(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Null6 = make(map[int64]int64, size) - for i := 0; i < size; i++ { - var _key int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _key = v - } - - var _val int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _val = v - } - - p.Null6[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *NullStruct) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NullStruct"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *NullStruct) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Null1", thrift.I64, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Null1); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *NullStruct) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetNull2() { - if err = oprot.WriteFieldBegin("Null2", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(*p.Null2); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *NullStruct) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Null3", thrift.I64, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.Null3); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *NullStruct) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Null4", thrift.LIST, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.I64, len(p.Null4)); err != nil { - return err - } - for _, v := range p.Null4 { - if err := oprot.WriteI64(v); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *NullStruct) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Null5", thrift.MAP, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I64, len(p.Null5)); err != nil { - return err - } - for k, v := range p.Null5 { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteI64(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *NullStruct) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Null6", thrift.MAP, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.I64, thrift.I64, len(p.Null6)); err != nil { - return err - } - for k, v := range p.Null6 { - - if err := oprot.WriteI64(k); err != nil { - return err - } - - if err := oprot.WriteI64(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - func (p *NullStruct) String() string { if p == nil { return "" @@ -499,228 +63,19 @@ func (p *NullStruct) String() string { return fmt.Sprintf("NullStruct(%+v)", *p) } -func (p *NullStruct) DeepEqual(ano *NullStruct) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Null1) { - return false - } - if !p.Field2DeepEqual(ano.Null2) { - return false - } - if !p.Field3DeepEqual(ano.Null3) { - return false - } - if !p.Field4DeepEqual(ano.Null4) { - return false - } - if !p.Field5DeepEqual(ano.Null5) { - return false - } - if !p.Field6DeepEqual(ano.Null6) { - return false - } - return true -} - -func (p *NullStruct) Field1DeepEqual(src int64) bool { - - if p.Null1 != src { - return false - } - return true -} -func (p *NullStruct) Field2DeepEqual(src *int64) bool { - - if p.Null2 == src { - return true - } else if p.Null2 == nil || src == nil { - return false - } - if *p.Null2 != *src { - return false - } - return true -} -func (p *NullStruct) Field3DeepEqual(src int64) bool { - - if p.Null3 != src { - return false - } - return true -} -func (p *NullStruct) Field4DeepEqual(src []int64) bool { - - if len(p.Null4) != len(src) { - return false - } - for i, v := range p.Null4 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *NullStruct) Field5DeepEqual(src map[string]int64) bool { - - if len(p.Null5) != len(src) { - return false - } - for k, v := range p.Null5 { - _src := src[k] - if v != _src { - return false - } - } - return true -} -func (p *NullStruct) Field6DeepEqual(src map[int64]int64) bool { - - if len(p.Null6) != len(src) { - return false - } - for k, v := range p.Null6 { - _src := src[k] - if v != _src { - return false - } - } - return true +var fieldIDToName_NullStruct = map[int16]string{ + 1: "Null1", + 2: "Null2", + 3: "Null3", + 4: "Null4", + 5: "Null5", + 6: "Null6", } type NullService interface { NullTest(ctx context.Context, req *NullStruct) (r *NullStruct, err error) } -type NullServiceClient struct { - c thrift.TClient -} - -func NewNullServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *NullServiceClient { - return &NullServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewNullServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *NullServiceClient { - return &NullServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewNullServiceClient(c thrift.TClient) *NullServiceClient { - return &NullServiceClient{ - c: c, - } -} - -func (p *NullServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *NullServiceClient) NullTest(ctx context.Context, req *NullStruct) (r *NullStruct, err error) { - var _args NullServiceNullTestArgs - _args.Req = req - var _result NullServiceNullTestResult - if err = p.Client_().Call(ctx, "NullTest", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type NullServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler NullService -} - -func (p *NullServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *NullServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *NullServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewNullServiceProcessor(handler NullService) *NullServiceProcessor { - self := &NullServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("NullTest", &nullServiceProcessorNullTest{handler: handler}) - return self -} -func (p *NullServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type nullServiceProcessorNullTest struct { - handler NullService -} - -func (p *nullServiceProcessorNullTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := NullServiceNullTestArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("NullTest", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := NullServiceNullTestResult{} - var retval *NullStruct - if retval, err2 = p.handler.NullTest(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NullTest: "+err2.Error()) - oprot.WriteMessageBegin("NullTest", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("NullTest", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - type NullServiceNullTestArgs struct { Req *NullStruct `thrift:"req,1" json:"req"` } @@ -729,6 +84,9 @@ func NewNullServiceNullTestArgs() *NullServiceNullTestArgs { return &NullServiceNullTestArgs{} } +func (p *NullServiceNullTestArgs) InitDefault() { +} + var NullServiceNullTestArgs_Req_DEFAULT *NullStruct func (p *NullServiceNullTestArgs) GetReq() (v *NullStruct) { @@ -737,131 +95,11 @@ func (p *NullServiceNullTestArgs) GetReq() (v *NullStruct) { } return p.Req } -func (p *NullServiceNullTestArgs) SetReq(val *NullStruct) { - p.Req = val -} - -var fieldIDToName_NullServiceNullTestArgs = map[int16]string{ - 1: "req", -} func (p *NullServiceNullTestArgs) IsSetReq() bool { return p.Req != nil } -func (p *NullServiceNullTestArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *NullServiceNullTestArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewNullStruct() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *NullServiceNullTestArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NullTest_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *NullServiceNullTestArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *NullServiceNullTestArgs) String() string { if p == nil { return "" @@ -869,34 +107,21 @@ func (p *NullServiceNullTestArgs) String() string { return fmt.Sprintf("NullServiceNullTestArgs(%+v)", *p) } -func (p *NullServiceNullTestArgs) DeepEqual(ano *NullServiceNullTestArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *NullServiceNullTestArgs) Field1DeepEqual(src *NullStruct) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_NullServiceNullTestArgs = map[int16]string{ + 1: "req", } type NullServiceNullTestResult struct { - Success *NullStruct `thrift:"success,0" json:"success,omitempty"` + Success *NullStruct `thrift:"success,0,optional" json:"success,omitempty"` } func NewNullServiceNullTestResult() *NullServiceNullTestResult { return &NullServiceNullTestResult{} } +func (p *NullServiceNullTestResult) InitDefault() { +} + var NullServiceNullTestResult_Success_DEFAULT *NullStruct func (p *NullServiceNullTestResult) GetSuccess() (v *NullStruct) { @@ -905,133 +130,11 @@ func (p *NullServiceNullTestResult) GetSuccess() (v *NullStruct) { } return p.Success } -func (p *NullServiceNullTestResult) SetSuccess(x interface{}) { - p.Success = x.(*NullStruct) -} - -var fieldIDToName_NullServiceNullTestResult = map[int16]string{ - 0: "success", -} func (p *NullServiceNullTestResult) IsSetSuccess() bool { return p.Success != nil } -func (p *NullServiceNullTestResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *NullServiceNullTestResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewNullStruct() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *NullServiceNullTestResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NullTest_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *NullServiceNullTestResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *NullServiceNullTestResult) String() string { if p == nil { return "" @@ -1039,22 +142,6 @@ func (p *NullServiceNullTestResult) String() string { return fmt.Sprintf("NullServiceNullTestResult(%+v)", *p) } -func (p *NullServiceNullTestResult) DeepEqual(ano *NullServiceNullTestResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *NullServiceNullTestResult) Field0DeepEqual(src *NullStruct) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_NullServiceNullTestResult = map[int16]string{ + 0: "success", } diff --git a/testdata/kitex_gen/ref/k-ref.go b/testdata/kitex_gen/ref/k-ref.go index 8f7300e0..eb38aa52 100644 --- a/testdata/kitex_gen/ref/k-ref.go +++ b/testdata/kitex_gen/ref/k-ref.go @@ -1,24 +1,2 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package ref - -import ( - "bytes" - "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/dynamicgo/internal/bthrift" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) diff --git a/testdata/kitex_gen/ref/ref.go b/testdata/kitex_gen/ref/ref.go index 4a62d16c..82e584ab 100644 --- a/testdata/kitex_gen/ref/ref.go +++ b/testdata/kitex_gen/ref/ref.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package ref @@ -40,7 +40,6 @@ func FOOFromString(s string) (FOO, error) { } func FOOPtr(v FOO) *FOO { return &v } - func (p *FOO) Scan(value interface{}) (err error) { var result sql.NullInt64 err = result.Scan(value) diff --git a/testdata/kitex_gen/skip/k-skip.go b/testdata/kitex_gen/skip/k-skip.go index 48344e48..526466c3 100644 --- a/testdata/kitex_gen/skip/k-skip.go +++ b/testdata/kitex_gen/skip/k-skip.go @@ -1,479 +1,269 @@ -// Code generated by Kitex v0.0.3. DO NOT EDIT. - +// Code generated by thriftgo (0.3.15) (fastgo). DO NOT EDIT. package skip import ( - "bytes" + "encoding/binary" "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/dynamicgo/internal/bthrift" + "github.com/cloudwego/gopkg/protocol/thrift" ) -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) +func (p *TestListMap) BLength() int { + if p == nil { + return 1 + } + off := 0 -func (p *TestListMap) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError + // p.ListMap ID:1 thrift.LIST + off += 3 + off += 5 + for _, v := range p.ListMap { + off += 6 + for k0, v0 := range v { + off += 4 + len(k0) + off += 4 + len(v0) + } + } + return off + 1 +} + +func (p *TestListMap) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } + +func (p *TestListMap) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.ListMap ID:1 thrift.LIST + b[off] = 15 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + b[off] = 13 + binary.BigEndian.PutUint32(b[off+1:], uint32(len(p.ListMap))) + off += 5 + for _, v := range p.ListMap { + b[off] = 11 + b[off+1] = 11 + binary.BigEndian.PutUint32(b[off+2:], uint32(len(v))) + off += 6 + for k0, v0 := range v { + off += thrift.Binary.WriteStringNocopy(b[off:], w, k0) + off += thrift.Binary.WriteStringNocopy(b[off:], w, v0) + } } + b[off] = 0 + return off + 1 +} + +func (p *TestListMap) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 + var l int + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.LIST { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10f: // p.ListMap ID:1 thrift.LIST + var sz int + _, sz, l, err = x.ReadListBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListMap = make([]map[string]string, sz) + for i := 0; i < sz; i++ { + { + var sz0 int + _, _, sz0, l, err = x.ReadMapBegin(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListMap[i] = make(map[string]string, sz0) + for i0 := 0; i0 < sz0; i0++ { + var k0 string + var v0 string + k0, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + v0, l, err = x.ReadString(b[off:]) + off += l + if err != nil { + goto ReadFieldError + } + p.ListMap[i][k0] = v0 + } } } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TestListMap[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_TestListMap[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *TestListMap) FastReadField1(buf []byte) (int, error) { - offset := 0 - - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListMap = make([]map[string]string, 0, size) - for i := 0; i < size; i++ { - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - _elem := make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - _elem[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListMap = append(p.ListMap, _elem) - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *SkipTestTestListMapArgs) BLength() int { + if p == nil { + return 1 } - return offset, nil -} + off := 0 -// for compatibility -func (p *TestListMap) FastWrite(buf []byte) int { - return 0 + // p.Req ID:1 thrift.STRUCT + off += 3 + off += p.Req.BLength() + return off + 1 } -func (p *TestListMap) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TestListMap") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} +func (p *SkipTestTestListMapArgs) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *TestListMap) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TestListMap") - if p != nil { - l += p.field1Length() +func (p *SkipTestTestListMapArgs) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *TestListMap) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "listMap", thrift.LIST, 1) - offset += bthrift.Binary.WriteListBegin(buf[offset:], thrift.MAP, len(p.ListMap)) - for _, v := range p.ListMap { - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(v)) - for k, v := range v { + off := 0 - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) + // p.Req ID:1 thrift.STRUCT + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 1) + off += 3 + off += p.Req.FastWriteNocopy(b[off:], w) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - } - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset + b[off] = 0 + return off + 1 } -func (p *TestListMap) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("listMap", thrift.LIST, 1) - l += bthrift.Binary.ListBeginLength(thrift.MAP, len(p.ListMap)) - for _, v := range p.ListMap { - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(v)) - for k, v := range v { - - l += bthrift.Binary.StringLengthNocopy(k) - - l += bthrift.Binary.StringLengthNocopy(v) - - } - l += bthrift.Binary.MapEndLength() - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *SkipTestTestListMapArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *SkipTestTestListMapArgs) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0x10c: // p.Req ID:1 thrift.STRUCT + p.Req = NewTestListMap() + l, err = p.Req.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SkipTestTestListMapArgs[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_SkipTestTestListMapArgs[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } -func (p *SkipTestTestListMapArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - p.Req = NewTestListMap() - if l, err := p.Req.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l +func (p *SkipTestTestListMapResult) BLength() int { + if p == nil { + return 1 } - return offset, nil -} - -// for compatibility -func (p *SkipTestTestListMapArgs) FastWrite(buf []byte) int { - return 0 -} + off := 0 -func (p *SkipTestTestListMapArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TestListMap_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + off += 3 + off += p.Success.BLength() } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset + return off + 1 } -func (p *SkipTestTestListMapArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TestListMap_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} +func (p *SkipTestTestListMapResult) FastWrite(b []byte) int { return p.FastWriteNocopy(b, nil) } -func (p *SkipTestTestListMapArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} +func (p *SkipTestTestListMapResult) FastWriteNocopy(b []byte, w thrift.NocopyWriter) int { + if p == nil { + b[0] = 0 + return 1 + } + off := 0 + + // p.Success ID:0 thrift.STRUCT + if p.Success != nil { + b[off] = 12 + binary.BigEndian.PutUint16(b[off+1:], 0) + off += 3 + off += p.Success.FastWriteNocopy(b[off:], w) + } -func (p *SkipTestTestListMapArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l + b[off] = 0 + return off + 1 } -func (p *SkipTestTestListMapResult) FastRead(buf []byte) (int, error) { - var err error - var offset int +func (p *SkipTestTestListMapResult) FastRead(b []byte) (off int, err error) { + var ftyp thrift.TType + var fid int16 var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - + x := thrift.BinaryProtocol{} for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l + ftyp, fid, l, err = x.ReadFieldBegin(b[off:]) + off += l if err != nil { goto ReadFieldBeginError } - if fieldTypeId == thrift.STOP { + if ftyp == thrift.STOP { break } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } + switch uint32(fid)<<8 | uint32(ftyp) { + case 0xc: // p.Success ID:0 thrift.STRUCT + p.Success = NewTestListMap() + l, err = p.Success.FastRead(b[off:]) + off += l + if err != nil { + goto ReadFieldError } default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l + l, err = x.Skip(b[off:], ftyp) + off += l if err != nil { goto SkipFieldError } } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) + return ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SkipTestTestListMapResult[fieldId]), err) + return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_SkipTestTestListMapResult[fid]), err) SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *SkipTestTestListMapResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - p.Success = NewTestListMap() - if l, err := p.Success.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *SkipTestTestListMapResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *SkipTestTestListMapResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TestListMap_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *SkipTestTestListMapResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TestListMap_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *SkipTestTestListMapResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *SkipTestTestListMapResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *SkipTestTestListMapArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *SkipTestTestListMapResult) GetResult() interface{} { - return p.Success + return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err) } diff --git a/testdata/kitex_gen/skip/skip.go b/testdata/kitex_gen/skip/skip.go index 61bcb88e..6f2e8549 100644 --- a/testdata/kitex_gen/skip/skip.go +++ b/testdata/kitex_gen/skip/skip.go @@ -1,12 +1,10 @@ -// Code generated by thriftgo (0.1.3). DO NOT EDIT. +// Code generated by thriftgo (0.3.15). DO NOT EDIT. package skip import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" - "strings" ) type TestListMap struct { @@ -17,182 +15,11 @@ func NewTestListMap() *TestListMap { return &TestListMap{} } -func (p *TestListMap) GetListMap() (v []map[string]string) { - return p.ListMap -} -func (p *TestListMap) SetListMap(val []map[string]string) { - p.ListMap = val -} - -var fieldIDToName_TestListMap = map[int16]string{ - 1: "listMap", -} - -func (p *TestListMap) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.LIST { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TestListMap[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TestListMap) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListMap = make([]map[string]string, 0, size) - for i := 0; i < size; i++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - _elem := make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - _elem[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - - p.ListMap = append(p.ListMap, _elem) - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} - -func (p *TestListMap) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TestListMap"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +func (p *TestListMap) InitDefault() { } -func (p *TestListMap) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("listMap", thrift.LIST, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteListBegin(thrift.MAP, len(p.ListMap)); err != nil { - return err - } - for _, v := range p.ListMap { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(v)); err != nil { - return err - } - for k, v := range v { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +func (p *TestListMap) GetListMap() (v []map[string]string) { + return p.ListMap } func (p *TestListMap) String() string { @@ -202,167 +29,14 @@ func (p *TestListMap) String() string { return fmt.Sprintf("TestListMap(%+v)", *p) } -func (p *TestListMap) DeepEqual(ano *TestListMap) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.ListMap) { - return false - } - return true -} - -func (p *TestListMap) Field1DeepEqual(src []map[string]string) bool { - - if len(p.ListMap) != len(src) { - return false - } - for i, v := range p.ListMap { - _src := src[i] - if len(v) != len(_src) { - return false - } - for k, v := range v { - _src1 := _src[k] - if strings.Compare(v, _src1) != 0 { - return false - } - } - } - return true +var fieldIDToName_TestListMap = map[int16]string{ + 1: "listMap", } type SkipTest interface { TestListMap(ctx context.Context, req *TestListMap) (r *TestListMap, err error) } -type SkipTestClient struct { - c thrift.TClient -} - -func NewSkipTestClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *SkipTestClient { - return &SkipTestClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewSkipTestClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *SkipTestClient { - return &SkipTestClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewSkipTestClient(c thrift.TClient) *SkipTestClient { - return &SkipTestClient{ - c: c, - } -} - -func (p *SkipTestClient) Client_() thrift.TClient { - return p.c -} - -func (p *SkipTestClient) TestListMap(ctx context.Context, req *TestListMap) (r *TestListMap, err error) { - var _args SkipTestTestListMapArgs - _args.Req = req - var _result SkipTestTestListMapResult - if err = p.Client_().Call(ctx, "TestListMap", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type SkipTestProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler SkipTest -} - -func (p *SkipTestProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *SkipTestProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *SkipTestProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewSkipTestProcessor(handler SkipTest) *SkipTestProcessor { - self := &SkipTestProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("TestListMap", &skipTestProcessorTestListMap{handler: handler}) - return self -} -func (p *SkipTestProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type skipTestProcessorTestListMap struct { - handler SkipTest -} - -func (p *skipTestProcessorTestListMap) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := SkipTestTestListMapArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("TestListMap", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := SkipTestTestListMapResult{} - var retval *TestListMap - if retval, err2 = p.handler.TestListMap(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing TestListMap: "+err2.Error()) - oprot.WriteMessageBegin("TestListMap", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("TestListMap", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - type SkipTestTestListMapArgs struct { Req *TestListMap `thrift:"req,1" json:"req"` } @@ -371,6 +45,9 @@ func NewSkipTestTestListMapArgs() *SkipTestTestListMapArgs { return &SkipTestTestListMapArgs{} } +func (p *SkipTestTestListMapArgs) InitDefault() { +} + var SkipTestTestListMapArgs_Req_DEFAULT *TestListMap func (p *SkipTestTestListMapArgs) GetReq() (v *TestListMap) { @@ -379,131 +56,11 @@ func (p *SkipTestTestListMapArgs) GetReq() (v *TestListMap) { } return p.Req } -func (p *SkipTestTestListMapArgs) SetReq(val *TestListMap) { - p.Req = val -} - -var fieldIDToName_SkipTestTestListMapArgs = map[int16]string{ - 1: "req", -} func (p *SkipTestTestListMapArgs) IsSetReq() bool { return p.Req != nil } -func (p *SkipTestTestListMapArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SkipTestTestListMapArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *SkipTestTestListMapArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewTestListMap() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *SkipTestTestListMapArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TestListMap_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *SkipTestTestListMapArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - func (p *SkipTestTestListMapArgs) String() string { if p == nil { return "" @@ -511,34 +68,21 @@ func (p *SkipTestTestListMapArgs) String() string { return fmt.Sprintf("SkipTestTestListMapArgs(%+v)", *p) } -func (p *SkipTestTestListMapArgs) DeepEqual(ano *SkipTestTestListMapArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *SkipTestTestListMapArgs) Field1DeepEqual(src *TestListMap) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true +var fieldIDToName_SkipTestTestListMapArgs = map[int16]string{ + 1: "req", } type SkipTestTestListMapResult struct { - Success *TestListMap `thrift:"success,0" json:"success,omitempty"` + Success *TestListMap `thrift:"success,0,optional" json:"success,omitempty"` } func NewSkipTestTestListMapResult() *SkipTestTestListMapResult { return &SkipTestTestListMapResult{} } +func (p *SkipTestTestListMapResult) InitDefault() { +} + var SkipTestTestListMapResult_Success_DEFAULT *TestListMap func (p *SkipTestTestListMapResult) GetSuccess() (v *TestListMap) { @@ -547,133 +91,11 @@ func (p *SkipTestTestListMapResult) GetSuccess() (v *TestListMap) { } return p.Success } -func (p *SkipTestTestListMapResult) SetSuccess(x interface{}) { - p.Success = x.(*TestListMap) -} - -var fieldIDToName_SkipTestTestListMapResult = map[int16]string{ - 0: "success", -} func (p *SkipTestTestListMapResult) IsSetSuccess() bool { return p.Success != nil } -func (p *SkipTestTestListMapResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SkipTestTestListMapResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *SkipTestTestListMapResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewTestListMap() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *SkipTestTestListMapResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TestListMap_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *SkipTestTestListMapResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - func (p *SkipTestTestListMapResult) String() string { if p == nil { return "" @@ -681,22 +103,6 @@ func (p *SkipTestTestListMapResult) String() string { return fmt.Sprintf("SkipTestTestListMapResult(%+v)", *p) } -func (p *SkipTestTestListMapResult) DeepEqual(ano *SkipTestTestListMapResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *SkipTestTestListMapResult) Field0DeepEqual(src *TestListMap) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true +var fieldIDToName_SkipTestTestListMapResult = map[int16]string{ + 0: "success", } diff --git a/testdata/sample/example2.go b/testdata/sample/example2.go index af92e40b..175a42cc 100644 --- a/testdata/sample/example2.go +++ b/testdata/sample/example2.go @@ -54,7 +54,7 @@ func GetExample2Req() *example2.ExampleReq { obj.InnerBase.Double = math.MaxFloat64 obj.InnerBase.String_ = "你好" obj.InnerBase.ListInt32 = []int32{math.MinInt32, 0, math.MaxInt32} - obj.InnerBase.SetInt32_ = []int32{math.MinInt32, 0, math.MaxInt32} + obj.InnerBase.SetInt32 = []int32{math.MinInt32, 0, math.MaxInt32} obj.InnerBase.MapStringString = map[string]string{"a": "A", "c": "C", "b": "B"} obj.InnerBase.Foo = 1 obj.InnerBase.MapInt8String = map[int8]string{1: "A", 2: "B", 3: "C"} diff --git a/testdata/sample/example3.go b/testdata/sample/example3.go index a69092d0..a9fe2f08 100644 --- a/testdata/sample/example3.go +++ b/testdata/sample/example3.go @@ -27,7 +27,7 @@ func GetEmptyInnerBase3() *example3.InnerBase { return &example3.InnerBase{ ListInt32: []int32{}, MapStringString: map[string]string{}, - SetInt32_: []int32{}, + SetInt32: []int32{}, MapInt32String: map[int32]string{}, Binary: []byte{}, MapInt8String: map[int8]string{}, @@ -50,7 +50,7 @@ func GetInnerBase3() *example3.InnerBase { in.Double = math.MaxFloat64 in.String_ = "hello" in.ListInt32 = []int32{math.MinInt32, 0, math.MaxInt32} - in.SetInt32_ = []int32{math.MinInt32, 0, math.MaxInt32} + in.SetInt32 = []int32{math.MinInt32, 0, math.MaxInt32} in.MapStringString = map[string]string{"a": "A", "c": "C", "b": "B"} in.Foo = 1 in.MapInt8String = map[int8]string{1: "A", 2: "B", 3: "C"} diff --git a/thrift/base/base.go b/thrift/base/base.go index 042dbddf..3a19a50a 100644 --- a/thrift/base/base.go +++ b/thrift/base/base.go @@ -17,1084 +17,35 @@ package base import ( - "fmt" - "strings" - - "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/gopkg/protocol/thrift/base" ) -type TrafficEnv struct { - Open bool `thrift:"Open,1" json:"Open"` - Env string `thrift:"Env,2" json:"Env"` -} +// TrafficEnv ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base +type TrafficEnv = base.TrafficEnv +// NewTrafficEnv ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base func NewTrafficEnv() *TrafficEnv { - return &TrafficEnv{ - - Open: false, - Env: "", - } -} - -func (p *TrafficEnv) GetOpen() (v bool) { - return p.Open -} - -func (p *TrafficEnv) GetEnv() (v string) { - return p.Env -} -func (p *TrafficEnv) SetOpen(val bool) { - p.Open = val -} -func (p *TrafficEnv) SetEnv(val string) { - p.Env = val + return base.NewTrafficEnv() } -var fieldIDToName_TrafficEnv = map[int16]string{ - 1: "Open", - 2: "Env", -} - -func (p *TrafficEnv) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TrafficEnv) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return err - } else { - p.Open = v - } - return nil -} - -func (p *TrafficEnv) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Env = v - } - return nil -} - -func (p *TrafficEnv) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("TrafficEnv"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *TrafficEnv) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Open", thrift.BOOL, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBool(p.Open); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *TrafficEnv) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Env", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Env); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *TrafficEnv) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TrafficEnv(%+v)", *p) -} - -func (p *TrafficEnv) DeepEqual(ano *TrafficEnv) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Open) { - return false - } - if !p.Field2DeepEqual(ano.Env) { - return false - } - return true -} - -func (p *TrafficEnv) Field1DeepEqual(src bool) bool { - - if p.Open != src { - return false - } - return true -} -func (p *TrafficEnv) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Env, src) != 0 { - return false - } - return true -} - -type Base struct { - LogID string `thrift:"LogID,1" json:"LogID"` - Caller string `thrift:"Caller,2" json:"Caller"` - Addr string `thrift:"Addr,3" json:"Addr"` - Client string `thrift:"Client,4" json:"Client"` - TrafficEnv *TrafficEnv `thrift:"TrafficEnv,5" json:"TrafficEnv,omitempty"` - Extra map[string]string `thrift:"Extra,6" json:"Extra,omitempty"` -} +// Base ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base +type Base = base.Base +// NewBase ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base func NewBase() *Base { - return &Base{ - LogID: "", - Caller: "", - Addr: "", - Client: "", - Extra: map[string]string{}, - } -} - -func (p *Base) GetLogID() (v string) { - return p.LogID -} - -func (p *Base) GetCaller() (v string) { - return p.Caller -} - -func (p *Base) GetAddr() (v string) { - return p.Addr -} - -func (p *Base) GetClient() (v string) { - return p.Client -} - -var Base_TrafficEnv_DEFAULT *TrafficEnv - -func (p *Base) GetTrafficEnv() (v *TrafficEnv) { - if !p.IsSetTrafficEnv() { - return Base_TrafficEnv_DEFAULT - } - return p.TrafficEnv -} - -var Base_Extra_DEFAULT map[string]string - -func (p *Base) GetExtra() (v map[string]string) { - if !p.IsSetExtra() { - return Base_Extra_DEFAULT - } - return p.Extra -} -func (p *Base) SetLogID(val string) { - p.LogID = val -} -func (p *Base) SetCaller(val string) { - p.Caller = val -} -func (p *Base) SetAddr(val string) { - p.Addr = val -} -func (p *Base) SetClient(val string) { - p.Client = val -} -func (p *Base) SetTrafficEnv(val *TrafficEnv) { - p.TrafficEnv = val -} -func (p *Base) SetExtra(val map[string]string) { - p.Extra = val -} - -var fieldIDToName_Base = map[int16]string{ - 1: "LogID", - 2: "Caller", - 3: "Addr", - 4: "Client", - 5: "TrafficEnv", - 6: "Extra", -} - -func (p *Base) IsSetTrafficEnv() bool { - return p.TrafficEnv != nil -} - -func (p *Base) IsSetExtra() bool { - return p.Extra != nil -} - -func (p *Base) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Base) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.LogID = v - } - return nil -} - -func (p *Base) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Caller = v - } - return nil -} - -func (p *Base) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Addr = v - } - return nil -} - -func (p *Base) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Client = v - } - return nil -} - -func (p *Base) ReadField5(iprot thrift.TProtocol) error { - p.TrafficEnv = NewTrafficEnv() - if err := p.TrafficEnv.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *Base) ReadField6(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Extra[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil + return base.NewBase() } -func (p *Base) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Base"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Base) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("LogID", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.LogID); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Base) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Caller", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Caller); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *Base) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Addr", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Addr); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *Base) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Client", thrift.STRING, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Client); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} - -func (p *Base) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetTrafficEnv() { - if err = oprot.WriteFieldBegin("TrafficEnv", thrift.STRUCT, 5); err != nil { - goto WriteFieldBeginError - } - if err := p.TrafficEnv.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} - -func (p *Base) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetExtra() { - if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil { - return err - } - for k, v := range p.Extra { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *Base) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Base(%+v)", *p) -} - -func (p *Base) DeepEqual(ano *Base) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.LogID) { - return false - } - if !p.Field2DeepEqual(ano.Caller) { - return false - } - if !p.Field3DeepEqual(ano.Addr) { - return false - } - if !p.Field4DeepEqual(ano.Client) { - return false - } - if !p.Field5DeepEqual(ano.TrafficEnv) { - return false - } - if !p.Field6DeepEqual(ano.Extra) { - return false - } - return true -} - -func (p *Base) Field1DeepEqual(src string) bool { - - if strings.Compare(p.LogID, src) != 0 { - return false - } - return true -} -func (p *Base) Field2DeepEqual(src string) bool { - - if strings.Compare(p.Caller, src) != 0 { - return false - } - return true -} -func (p *Base) Field3DeepEqual(src string) bool { - - if strings.Compare(p.Addr, src) != 0 { - return false - } - return true -} -func (p *Base) Field4DeepEqual(src string) bool { - - if strings.Compare(p.Client, src) != 0 { - return false - } - return true -} -func (p *Base) Field5DeepEqual(src *TrafficEnv) bool { - - if !p.TrafficEnv.DeepEqual(src) { - return false - } - return true -} -func (p *Base) Field6DeepEqual(src map[string]string) bool { - - if len(p.Extra) != len(src) { - return false - } - for k, v := range p.Extra { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} - -type BaseResp struct { - StatusMessage string `thrift:"StatusMessage,1" json:"StatusMessage"` - StatusCode int32 `thrift:"StatusCode,2" json:"StatusCode"` - Extra map[string]string `thrift:"Extra,3" json:"Extra,omitempty"` -} +// BaseResp ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base +type BaseResp = base.BaseResp +// NewBaseResp ... +// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base func NewBaseResp() *BaseResp { - return &BaseResp{ - - StatusMessage: "", - StatusCode: 0, - } -} - -func (p *BaseResp) GetStatusMessage() (v string) { - return p.StatusMessage -} - -func (p *BaseResp) GetStatusCode() (v int32) { - return p.StatusCode -} - -var BaseResp_Extra_DEFAULT map[string]string - -func (p *BaseResp) GetExtra() (v map[string]string) { - if !p.IsSetExtra() { - return BaseResp_Extra_DEFAULT - } - return p.Extra -} -func (p *BaseResp) SetStatusMessage(val string) { - p.StatusMessage = val -} -func (p *BaseResp) SetStatusCode(val int32) { - p.StatusCode = val -} -func (p *BaseResp) SetExtra(val map[string]string) { - p.Extra = val -} - -var fieldIDToName_BaseResp = map[int16]string{ - 1: "StatusMessage", - 2: "StatusCode", - 3: "Extra", -} - -func (p *BaseResp) IsSetExtra() bool { - return p.Extra != nil -} - -func (p *BaseResp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.MAP { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else { - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.StatusMessage = v - } - return nil -} - -func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.StatusCode = v - } - return nil -} - -func (p *BaseResp) ReadField3(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.Extra[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *BaseResp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("BaseResp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaseResp) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StatusMessage", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.StatusMessage); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaseResp) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StatusCode", thrift.I32, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.StatusCode); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *BaseResp) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetExtra() { - if err = oprot.WriteFieldBegin("Extra", thrift.MAP, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Extra)); err != nil { - return err - } - for k, v := range p.Extra { - - if err := oprot.WriteString(k); err != nil { - return err - } - - if err := oprot.WriteString(v); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *BaseResp) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaseResp(%+v)", *p) -} - -func (p *BaseResp) DeepEqual(ano *BaseResp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.StatusMessage) { - return false - } - if !p.Field2DeepEqual(ano.StatusCode) { - return false - } - if !p.Field3DeepEqual(ano.Extra) { - return false - } - return true -} - -func (p *BaseResp) Field1DeepEqual(src string) bool { - - if strings.Compare(p.StatusMessage, src) != 0 { - return false - } - return true -} -func (p *BaseResp) Field2DeepEqual(src int32) bool { - - if p.StatusCode != src { - return false - } - return true -} -func (p *BaseResp) Field3DeepEqual(src map[string]string) bool { - - if len(p.Extra) != len(src) { - return false - } - for k, v := range p.Extra { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true + return base.NewBaseResp() } diff --git a/thrift/base/k-base.go b/thrift/base/k-base.go deleted file mode 100644 index 756273bb..00000000 --- a/thrift/base/k-base.go +++ /dev/null @@ -1,887 +0,0 @@ -/** - * Copyright 2023 CloudWeGo Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package base - -import ( - "bytes" - "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/dynamicgo/internal/bthrift" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) - -func (p *TrafficEnv) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.BOOL { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *TrafficEnv) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Open = v - - } - return offset, nil -} - -func (p *TrafficEnv) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Env = v - - } - return offset, nil -} - -// for compatibility -func (p *TrafficEnv) FastWrite(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TrafficEnv") - if p != nil { - offset += p.fastWriteField1(buf[offset:]) - offset += p.fastWriteField2(buf[offset:]) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *TrafficEnv) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("TrafficEnv") - if p != nil { - l += p.field1Length() - l += p.field2Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *TrafficEnv) fastWriteField1(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Open", thrift.BOOL, 1) - offset += bthrift.Binary.WriteBool(buf[offset:], p.Open) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TrafficEnv) fastWriteField2(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Env", thrift.STRING, 2) - offset += bthrift.Binary.WriteString(buf[offset:], p.Env) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *TrafficEnv) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Open", thrift.BOOL, 1) - l += bthrift.Binary.BoolLength(p.Open) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *TrafficEnv) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Env", thrift.STRING, 2) - l += bthrift.Binary.StringLength(p.Env) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 4: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 5: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 6: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Base) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.LogID = v - - } - return offset, nil -} - -func (p *Base) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Caller = v - - } - return offset, nil -} - -func (p *Base) FastReadField3(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Addr = v - - } - return offset, nil -} - -func (p *Base) FastReadField4(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Client = v - - } - return offset, nil -} - -func (p *Base) FastReadField5(buf []byte) (int, error) { - offset := 0 - p.TrafficEnv = NewTrafficEnv() - if l, err := p.TrafficEnv.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Base) FastReadField6(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Extra[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *Base) FastWrite(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Base") - if p != nil { - offset += p.fastWriteField1(buf[offset:]) - offset += p.fastWriteField2(buf[offset:]) - offset += p.fastWriteField3(buf[offset:]) - offset += p.fastWriteField4(buf[offset:]) - offset += p.fastWriteField5(buf[offset:]) - offset += p.fastWriteField6(buf[offset:]) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Base) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Base") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - l += p.field4Length() - l += p.field5Length() - l += p.field6Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Base) fastWriteField1(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "LogID", thrift.STRING, 1) - offset += bthrift.Binary.WriteString(buf[offset:], p.LogID) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField2(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Caller", thrift.STRING, 2) - offset += bthrift.Binary.WriteString(buf[offset:], p.Caller) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField3(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Addr", thrift.STRING, 3) - offset += bthrift.Binary.WriteString(buf[offset:], p.Addr) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField4(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Client", thrift.STRING, 4) - offset += bthrift.Binary.WriteString(buf[offset:], p.Client) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Base) fastWriteField5(buf []byte) int { - offset := 0 - if p.IsSetTrafficEnv() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "TrafficEnv", thrift.STRUCT, 5) - offset += p.TrafficEnv.FastWrite(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *Base) fastWriteField6(buf []byte) int { - offset := 0 - if p.IsSetExtra() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 6) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - offset += bthrift.Binary.WriteString(buf[offset:], k) - - offset += bthrift.Binary.WriteString(buf[offset:], v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *Base) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("LogID", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.LogID) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Caller", thrift.STRING, 2) - l += bthrift.Binary.StringLength(p.Caller) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Addr", thrift.STRING, 3) - l += bthrift.Binary.StringLength(p.Addr) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Client", thrift.STRING, 4) - l += bthrift.Binary.StringLength(p.Client) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Base) field5Length() int { - l := 0 - if p.IsSetTrafficEnv() { - l += bthrift.Binary.FieldBeginLength("TrafficEnv", thrift.STRUCT, 5) - l += p.TrafficEnv.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *Base) field6Length() int { - l := 0 - if p.IsSetExtra() { - l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 6) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaseResp) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.I32 { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 3: - if fieldTypeId == thrift.MAP { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaseResp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.StatusMessage = v - - } - return offset, nil -} - -func (p *BaseResp) FastReadField2(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.StatusCode = v - - } - return offset, nil -} - -func (p *BaseResp) FastReadField3(buf []byte) (int, error) { - offset := 0 - - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.Extra = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.Extra[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *BaseResp) FastWrite(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BaseResp") - if p != nil { - offset += p.fastWriteField2(buf[offset:]) - offset += p.fastWriteField1(buf[offset:]) - offset += p.fastWriteField3(buf[offset:]) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("BaseResp") - if p != nil { - l += p.field1Length() - l += p.field2Length() - l += p.field3Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaseResp) fastWriteField1(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusMessage", thrift.STRING, 1) - offset += bthrift.Binary.WriteString(buf[offset:], p.StatusMessage) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) fastWriteField2(buf []byte) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusCode", thrift.I32, 2) - offset += bthrift.Binary.WriteI32(buf[offset:], p.StatusCode) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaseResp) fastWriteField3(buf []byte) int { - offset := 0 - if p.IsSetExtra() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 3) - offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - offset += bthrift.Binary.WriteString(buf[offset:], k) - - offset += bthrift.Binary.WriteString(buf[offset:], v) - - } - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaseResp) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StatusMessage", thrift.STRING, 1) - l += bthrift.Binary.StringLength(p.StatusMessage) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaseResp) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StatusCode", thrift.I32, 2) - l += bthrift.Binary.I32Length(p.StatusCode) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaseResp) field3Length() int { - l := 0 - if p.IsSetExtra() { - l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 3) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra)) - for k, v := range p.Extra { - - l += bthrift.Binary.StringLength(k) - - l += bthrift.Binary.StringLength(v) - - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} diff --git a/thrift/descriptor.go b/thrift/descriptor.go index b080e3b3..27ec4872 100644 --- a/thrift/descriptor.go +++ b/thrift/descriptor.go @@ -19,7 +19,6 @@ package thrift import ( "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/dynamicgo/http" "github.com/cloudwego/thriftgo/parser" ) @@ -114,16 +113,6 @@ func (p Type) IsComplex() bool { return p == STRUCT || p == MAP || p == SET || p == LIST } -// ToThriftTType converts Type to apache/thrift.TType -func (p Type) ToThriftTType() thrift.TType { - return thrift.TType(p) -} - -// FromThriftTType converts apache/thrift.TType to Type -func FromThriftTType(t thrift.TType) Type { - return Type(t) -} - // TypeDescriptor is the runtime descriptor of a thrift type type TypeDescriptor struct { typ Type diff --git a/thrift/generic/value_test.go b/thrift/generic/value_test.go index 0ae963a0..f0069e93 100644 --- a/thrift/generic/value_test.go +++ b/thrift/generic/value_test.go @@ -327,7 +327,7 @@ func TestGet(t *testing.T) { require.Nil(t, err) require.Equal(t, exp.InnerBase.MapStringString["b"], (mp1)) sp := a.Field(10) - checkHelper(t, exp.InnerBase.SetInt32_, sp.Node, "List") + checkHelper(t, exp.InnerBase.SetInt32, sp.Node, "List") i, err := a.Field(11).Int() require.Nil(t, err) require.Equal(t, int64(exp.InnerBase.Foo), int64(i)) From 4b3127a73d41d1e8f0bdb0a361c794ddd9b30761 Mon Sep 17 00:00:00 2001 From: Kyle Xiao Date: Wed, 31 Jul 2024 17:16:53 +0800 Subject: [PATCH 2/2] ci: rm test that relies on kitex internal pkg --- testdata/test/baseline_j2t_test.go | 146 ------------------ testdata/test/baseline_t2j_test.go | 127 +-------------- testdata/test/baseline_tg_test.go | 238 ----------------------------- testdata/test/go.mod | 13 +- testdata/test/go.sum | 72 ++------- 5 files changed, 23 insertions(+), 573 deletions(-) diff --git a/testdata/test/baseline_j2t_test.go b/testdata/test/baseline_j2t_test.go index a94b3d54..71b9d3bf 100644 --- a/testdata/test/baseline_j2t_test.go +++ b/testdata/test/baseline_j2t_test.go @@ -28,18 +28,12 @@ import ( "sync" "testing" - athrift "github.com/apache/thrift/lib/go/thrift" "github.com/bytedance/sonic" json "github.com/bytedance/sonic/ast" "github.com/cloudwego/dynamicgo/conv" "github.com/cloudwego/dynamicgo/conv/j2t" "github.com/cloudwego/dynamicgo/http" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/baseline" - "github.com/cloudwego/kitex/pkg/generic" - "github.com/cloudwego/kitex/pkg/generic/descriptor" - gthrift "github.com/cloudwego/kitex/pkg/generic/thrift" - "github.com/cloudwego/kitex/pkg/remote" - bthrift "github.com/cloudwego/kitex/pkg/remote/codec/thrift" "github.com/stretchr/testify/require" ) @@ -682,58 +676,6 @@ func TestHTTP2Thrift_Nesting_Parallel(t *testing.T) { const BufferSize = 4096 -func BenchmarkJSON2Thrift_KitexGeneric(b *testing.B) { - p, err := generic.NewThriftFileProvider(idlPath) - if err != nil { - b.Fatal(err) - } - svcDsc := <-p.Provide() - - b.Run("small", func(b *testing.B) { - var _args generic.Args - _args.Method = "SimpleMethod" - _args.Request = simpleJSON - codec, err := gthrift.NewWriteJSON(svcDsc, "SimpleMethod", true) - if err != nil { - b.Fatal(err) - } - var mm = athrift.NewTMemoryBuffer() - bc := athrift.NewTBinaryProtocol(mm, false, true) - if err := codec.Write(context.Background(), bc, simpleJSON, nil); err != nil { - b.Fatal(err) - } - - b.SetBytes(int64(len(mm.Bytes()))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm.Reset() - _ = codec.Write(context.Background(), bc, simpleJSON, nil) - } - }) - - b.Run("medium", func(b *testing.B) { - var _args generic.Args - _args.Method = "NestingMethod" - _args.Request = nestingJSON - codec, err := gthrift.NewWriteJSON(svcDsc, "NestingMethod", true) - if err != nil { - b.Fatal(err) - } - var mm = athrift.NewTMemoryBuffer() - bc := athrift.NewTBinaryProtocol(mm, false, true) - if err := codec.Write(context.Background(), bc, nestingJSON, nil); err != nil { - b.Fatal(err) - } - - b.SetBytes(int64(len(mm.Bytes()))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm.Reset() - _ = codec.Write(context.Background(), bc, nestingJSON, nil) - } - }) -} - func BenchmarkJSON2Thrift_SonicAndKitex(b *testing.B) { b.Run("small", func(b *testing.B) { v := baseline.NewSimple() @@ -893,91 +835,3 @@ func BenchmarkHTTP2Thrift_DynamicGo_Raw(b *testing.B) { // req.Body["Byte"] = int8(req.Body["Byte"].(int64)) // } - -func BenchmarkHTTP2Thrift_KitexGeneric(b *testing.B) { - p, err := generic.NewThriftFileProvider(idlPath) - if err != nil { - b.Fatal(err) - } - svcDsc := <-p.Provide() - svcDsc.Functions["NestingMethod"].Request.Struct.FieldsByName["req"].Type.Struct.FieldsByName["Double"].HTTPMapping = nil - - b.Run("small", func(b *testing.B) { - codec := gthrift.NewWriteHTTPRequest(svcDsc) - req := &descriptor.HTTPRequest{} - req.Request, err = stdh.NewRequest("POST", "/simple", nil) - if err != nil { - b.Fatal(err) - } - jc := sonic.Config{ - UseInt64: true, - }.Froze() - if err := jc.UnmarshalFromString(simpleJSON, &req.Body); err != nil { - b.Fatal(err) - } - req.Body["I32Field"] = int32(req.Body["I32Field"].(int64)) - req.Body["ByteField"] = int8(req.Body["ByteField"].(int64)) - - buf := remote.NewWriterBuffer(BufferSize) - bc := bthrift.NewBinaryProtocol(buf) - if err := codec.Write(context.Background(), bc, req, gthrift.NewBase()); err != nil { - b.Fatal(err) - } - out, _ := buf.Bytes() - exp := baseline.NewSimple() - if _, err := exp.FastRead(out); err != nil { - b.Fatal(err) - } - - b.SetBytes(int64(len(out))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - buf := remote.NewWriterBuffer(BufferSize) - bc := bthrift.NewBinaryProtocol(buf) - if err = codec.Write(context.Background(), bc, req, gthrift.NewBase()); err != nil { - b.Fatal(err) - } - } - }) - - // b.Run("medium", func(b *testing.B) { - // codec := gthrift.NewWriteHTTPRequest(svcDsc) - // jc := sonic.Config{ - // UseInt64: true, - // }.Froze() - // var body map[string]interface{} - // if err := jc.UnmarshalFromString(nestingJSON, &body); err != nil { - // b.Fatal(err) - // } - // req := &descriptor.HTTPRequest{ - // Header: map[string][]string{}, - // Query: map[string][]string{}, - // Cookies: map[string]string{}, - // } - // req.Body = body - // getKitexHttpRequest(req) - // req.Method = "POST" - // req.Path = "/nesting" - - // buf := remote.NewWriterBuffer(BufferSize) - // bc := bthrift.NewBinaryProtocol(buf) - // if err := codec.Write(context.Background(), bc, req, gthrift.NewBase()); err != nil { - // b.Fatal(err) - // } - // out, _ := buf.Bytes() - // exp := baseline.NewNesting() - // if _, err := exp.FastRead(out); err != nil { - // b.Fatal(err) - // } - - // b.SetBytes(int64(len(out))) - // b.ResetTimer() - // for i := 0; i < b.N; i++ { - // buf := remote.NewWriterBuffer(BufferSize) - // bc := bthrift.NewBinaryProtocol(buf) - // if err = codec.Write(context.Background(), bc, req, gthrift.NewBase()); err != nil { - // b.Fatal(err) - // } - // } - // }) -} diff --git a/testdata/test/baseline_t2j_test.go b/testdata/test/baseline_t2j_test.go index bcaa0a67..bff332fb 100644 --- a/testdata/test/baseline_t2j_test.go +++ b/testdata/test/baseline_t2j_test.go @@ -18,7 +18,6 @@ package test import ( - "bytes" "context" "encoding/json" ejson "encoding/json" @@ -32,8 +31,6 @@ import ( "github.com/cloudwego/dynamicgo/http" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/baseline" "github.com/cloudwego/dynamicgo/thrift" - "github.com/cloudwego/kitex/pkg/generic" - gthrift "github.com/cloudwego/kitex/pkg/generic/thrift" "github.com/stretchr/testify/require" ) @@ -260,7 +257,7 @@ func TestThrift2HTTP(t *testing.T) { ls, err := json.Marshal(data.ListI64) require.NoError(t, err) data.ListI64 = nil - + require.Equal(t, data, v) require.Equal(t, dstr, resp.Header.Get("String")) require.Equal(t, int(di32), resp.StatusCode) @@ -359,7 +356,7 @@ func TestThrift2HTTP_Parallel(t *testing.T) { ls, err := json.Marshal(data.ListI64) require.NoError(t, err) data.ListI64 = nil - + require.Equal(t, data, v) require.Equal(t, dstr, resp.Header.Get("String")) require.Equal(t, int(di32), resp.StatusCode) @@ -433,66 +430,6 @@ func wrapKitexGenericResponsePayload(in []byte) []byte { return p.Buf } -func BenchmarkThrift2JSON_KitexGeneric(b *testing.B) { - p, err := generic.NewThriftFileProvider(idlPath) - if err != nil { - b.Fatal(err) - } - svcDsc := <-p.Provide() - - b.Run("small", func(b *testing.B) { - codec := gthrift.NewReadJSON(svcDsc, false) - data := getSimpleValue() - in := make([]byte, data.BLength()) - if err := data.FastWriteNocopy(in, nil); err <= 0 { - b.Fatal(err) - } - in = wrapKitexGenericRequestPayload(in) - var mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - v, err := codec.Read(context.Background(), "SimpleMethod", bc) - if err != nil { - b.Fatal(err) - } - _ = v - // spew.Printf("%#+v\n", v) - - b.SetBytes(int64(len(in))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - var mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(context.Background(), "SimpleMethod", bc) - } - }) - - b.Run("medium", func(b *testing.B) { - codec := gthrift.NewReadJSON(svcDsc, false) - data := getNestingValue() - in := make([]byte, data.BLength()) - if err := data.FastWriteNocopy(in, nil); err <= 0 { - b.Fatal(err) - } - in = wrapKitexGenericRequestPayload(in) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - v, err := codec.Read(context.Background(), "NestingMethod", bc) - if err != nil { - b.Fatal(err) - } - _ = v - // spew.Printf("%#+v\n", v) - - b.SetBytes(int64(len(in))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc = athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(context.Background(), "NestingMethod", bc) - } - }) -} - func BenchmarkThrift2JSON_SonicAndKitex(b *testing.B) { b.Run("small", func(b *testing.B) { v := getSimpleValue() @@ -647,63 +584,3 @@ func BenchmarkThrift2HTTP_DynamicGo(t *testing.B) { } }) } - -func BenchmarkThrift2HTTP_KitexGeneric(b *testing.B) { - p, err := generic.NewThriftFileProvider(idlPath) - if err != nil { - b.Fatal(err) - } - svcDsc := <-p.Provide() - - b.Run("small/http+value_mapping", func(b *testing.B) { - codec := gthrift.NewReadHTTPResponse(svcDsc) - data := getSimpleValue() - in := make([]byte, data.BLength()) - if err := data.FastWriteNocopy(in, nil); err <= 0 { - b.Fatal(err) - } - in = wrapKitexGenericResponsePayload(in) - var mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - v, err := codec.Read(context.Background(), "SimpleMethod", bc) - if err != nil { - b.Fatal(err) - } - _ = v - // spew.Printf("%#+v\n", v) - - b.SetBytes(int64(len(in))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - var mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(context.Background(), "SimpleMethod", bc) - } - }) - - b.Run("medium/http+value_mapping", func(b *testing.B) { - codec := gthrift.NewReadHTTPResponse(svcDsc) - data := getNestingValue() - in := make([]byte, data.BLength()) - if err := data.FastWriteNocopy(in, nil); err <= 0 { - b.Fatal(err) - } - in = wrapKitexGenericResponsePayload(in) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - v, err := codec.Read(context.Background(), "NestingMethod", bc) - if err != nil { - b.Fatal(err) - } - _ = v - // spew.Printf("%#+v\n", v) - - b.SetBytes(int64(len(in))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm = athrift.NewStreamTransportR(bytes.NewBuffer(in)) - bc = athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(context.Background(), "NestingMethod", bc) - } - }) -} diff --git a/testdata/test/baseline_tg_test.go b/testdata/test/baseline_tg_test.go index d2cb011f..455b1ad9 100644 --- a/testdata/test/baseline_tg_test.go +++ b/testdata/test/baseline_tg_test.go @@ -17,19 +17,13 @@ package test import ( - "bytes" - "context" "testing" - athrift "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/dynamicgo/testdata/kitex_gen/baseline" "github.com/cloudwego/dynamicgo/thrift" "github.com/cloudwego/dynamicgo/thrift/generic" kg "github.com/cloudwego/kitex/pkg/generic" kd "github.com/cloudwego/kitex/pkg/generic/descriptor" - gthrift "github.com/cloudwego/kitex/pkg/generic/thrift" - "github.com/cloudwego/kitex/pkg/remote" - bthrift "github.com/cloudwego/kitex/pkg/remote/codec/thrift" "github.com/stretchr/testify/require" ) @@ -55,238 +49,6 @@ func getKitexGenericDesc() *kd.ServiceDescriptor { return <-p.Provide() } -func BenchmarkThriftUnmarshalAll_KitexGeneric(b *testing.B) { - b.Run("small", func(b *testing.B) { - obj := getSimpleValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericResponsePayload(data) - svcDsc := getKitexGenericDesc() - codec := gthrift.NewReadStruct(svcDsc, true) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := codec.Read(ctx, "SimpleMethod", bc) - require.NoError(b, err) - _ = v - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(ctx, "SimpleMethod", bc) - } - }) - b.Run("medium", func(b *testing.B) { - obj := getNestingValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericResponsePayload(data) - svcDsc := getKitexGenericDesc() - codec := gthrift.NewReadStruct(svcDsc, true) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := codec.Read(ctx, "NestingMethod", bc) - require.NoError(b, err) - _ = v - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(ctx, "NestingMethod", bc) - } - }) -} - -func BenchmarkThriftMarshalAll_KitexGeneric(b *testing.B) { - b.Run("small", func(b *testing.B) { - obj := getSimpleValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericRequestPayload(data) - svcDsc := getKitexGenericDesc() - reader := gthrift.NewReadStruct(svcDsc, false) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - ac := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := reader.Read(ctx, "SimpleMethod", ac) - require.NoError(b, err) - - ctx = context.Background() - codec, _ := gthrift.NewWriteStruct(svcDsc, "SimpleMethod", true) - buf := remote.NewWriterBuffer(BufferSize) - bc := bthrift.NewBinaryProtocol(buf) - err = codec.Write(ctx, bc, v, gthrift.NewBase()) - require.NoError(b, err) - - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - buf.Flush() - bc := bthrift.NewBinaryProtocol(buf) - _ = codec.Write(ctx, bc, v, gthrift.NewBase()) - } - }) - b.Run("medium", func(b *testing.B) { - obj := getNestingValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericRequestPayload(data) - svcDsc := getKitexGenericDesc() - reader := gthrift.NewReadStruct(svcDsc, false) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - ac := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := reader.Read(ctx, "NestingMethod", ac) - require.NoError(b, err) - - ctx = context.Background() - codec, _ := gthrift.NewWriteStruct(svcDsc, "NestingMethod", true) - buf := remote.NewWriterBuffer(BufferSize * 10) - bc := bthrift.NewBinaryProtocol(buf) - err = codec.Write(ctx, bc, v, gthrift.NewBase()) - require.NoError(b, err) - - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - buf.Flush() - bc := bthrift.NewBinaryProtocol(buf) - _ = codec.Write(ctx, bc, v, gthrift.NewBase()) - } - }) -} - -func BenchmarkThriftUnmarshalPartial_KitexGeneric(b *testing.B) { - b.Run("small", func(b *testing.B) { - obj := getPartialSimpleValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericResponsePayload(data) - svcDsc := getKitexGenericDesc() - codec := gthrift.NewReadStruct(svcDsc, true) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := codec.Read(ctx, "PartialSimpleMethod", bc) - require.NoError(b, err) - _ = v - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(ctx, "PartialSimpleMethod", bc) - } - }) - b.Run("medium", func(b *testing.B) { - obj := getPartialNestingValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericResponsePayload(data) - svcDsc := getKitexGenericDesc() - codec := gthrift.NewReadStruct(svcDsc, true) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := codec.Read(ctx, "PartialNestingMethod", bc) - require.NoError(b, err) - _ = v - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - bc := athrift.NewTBinaryProtocol(mm, false, false) - _, _ = codec.Read(ctx, "PartialNestingMethod", bc) - } - }) -} - -func BenchmarkThriftMarshalPartial_KitexGeneric(b *testing.B) { - b.Run("small", func(b *testing.B) { - obj := getPartialSimpleValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericRequestPayload(data) - svcDsc := getKitexGenericDesc() - reader := gthrift.NewReadStruct(svcDsc, false) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - ac := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := reader.Read(ctx, "PartialSimpleMethod", ac) - require.NoError(b, err) - - ctx = context.Background() - codec, _ := gthrift.NewWriteStruct(svcDsc, "PartialSimpleMethod", true) - buf := remote.NewWriterBuffer(BufferSize) - bc := bthrift.NewBinaryProtocol(buf) - err = codec.Write(ctx, bc, v, gthrift.NewBase()) - require.NoError(b, err) - - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - buf.Flush() - bc := bthrift.NewBinaryProtocol(buf) - _ = codec.Write(ctx, bc, v, gthrift.NewBase()) - } - }) - b.Run("medium", func(b *testing.B) { - obj := getPartialNestingValue() - data := make([]byte, obj.BLength()) - ret := obj.FastWriteNocopy(data, nil) - if ret < 0 { - b.Fatal(ret) - } - data = wrapKitexGenericRequestPayload(data) - svcDsc := getKitexGenericDesc() - reader := gthrift.NewReadStruct(svcDsc, false) - mm := athrift.NewStreamTransportR(bytes.NewBuffer(data)) - ac := athrift.NewTBinaryProtocol(mm, false, false) - ctx := context.Background() - v, err := reader.Read(ctx, "PartialNestingMethod", ac) - require.NoError(b, err) - - ctx = context.Background() - codec, _ := gthrift.NewWriteStruct(svcDsc, "PartialNestingMethod", true) - buf := remote.NewWriterBuffer(BufferSize * 10) - bc := bthrift.NewBinaryProtocol(buf) - err = codec.Write(ctx, bc, v, gthrift.NewBase()) - require.NoError(b, err) - - b.SetBytes(int64(len(data))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - buf.Flush() - bc := bthrift.NewBinaryProtocol(buf) - _ = codec.Write(ctx, bc, v, gthrift.NewBase()) - } - }) -} - func BenchmarkThriftMarshalAll_KitexFast(b *testing.B) { b.Run("small", func(b *testing.B) { obj := getSimpleValue() diff --git a/testdata/test/go.mod b/testdata/test/go.mod index f677b08d..dd1a6e56 100644 --- a/testdata/test/go.mod +++ b/testdata/test/go.mod @@ -5,8 +5,8 @@ go 1.19 require ( github.com/apache/thrift v0.20.0 github.com/bytedance/sonic v1.12.0 - github.com/cloudwego/dynamicgo v0.2.6 - github.com/cloudwego/kitex v0.9.3-rc2 + github.com/cloudwego/dynamicgo v0.2.9 + github.com/cloudwego/kitex v0.10.4-0.20240731031152-e2ff8eeacaed github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/json-iterator/go v1.1.12 github.com/stretchr/testify v1.9.0 @@ -15,16 +15,17 @@ require ( ) require ( - github.com/bytedance/gopkg v0.0.0-20230728082804-614d0af6619b // indirect + github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect - github.com/choleraehyq/pid v0.0.18 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/configmanager v0.2.2 // indirect github.com/cloudwego/fastpb v0.0.4 // indirect github.com/cloudwego/frugal v0.1.15 // indirect + github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cloudwego/netpoll v0.6.0 // indirect - github.com/cloudwego/thriftgo v0.3.6 // indirect + github.com/cloudwego/netpoll v0.6.3 // indirect + github.com/cloudwego/runtimex v0.1.0 // indirect + github.com/cloudwego/thriftgo v0.3.15 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect diff --git a/testdata/test/go.sum b/testdata/test/go.sum index 2aec8af1..c93d7f5e 100644 --- a/testdata/test/go.sum +++ b/testdata/test/go.sum @@ -12,11 +12,9 @@ github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= -github.com/bytedance/gopkg v0.0.0-20230728082804-614d0af6619b h1:R6PWoQtxEMpWJPHnpci+9LgFxCS7iJCfOGBvCgZeTKI= -github.com/bytedance/gopkg v0.0.0-20230728082804-614d0af6619b/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= -github.com/bytedance/mockey v1.2.7 h1:8j4yCqS5OmMe2dQCxPit4FVkwTK9nrykIgbOZN3s28o= -github.com/bytedance/mockey v1.2.7/go.mod h1:bNrUnI1u7+pAc0TYDgPATM+wF2yzHxmNH+iDXg4AOCU= +github.com/bytedance/gopkg v0.0.0-20240507064146-197ded923ae3/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= +github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8 h1:rDwLxYTMoKHaw4cS0bQhaTZnkXp5e6ediCggGcRD/CA= +github.com/bytedance/gopkg v0.0.0-20240711085056-a03554c296f8/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic v1.12.0 h1:YGPgxF9xzaCNvd/ZKdQ28yRovhfMFZQjuk6fKBzZ3ls= github.com/bytedance/sonic v1.12.0/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= @@ -24,11 +22,6 @@ github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4 github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/choleraehyq/pid v0.0.18 h1:O7LLxPoOyt3YtonlCC8BmNrF9P6Hc8B509UOqlPSVhw= -github.com/choleraehyq/pid v0.0.18/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= @@ -38,22 +31,25 @@ github.com/cloudwego/fastpb v0.0.4 h1:/ROVVfoFtpfc+1pkQLzGs+azjxUbSOsAqSY4tAAx4m github.com/cloudwego/fastpb v0.0.4/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= github.com/cloudwego/frugal v0.1.15 h1:LC55UJKhQPMFVjDPbE+LJcF7etZjSx6uokG1tk0wPK0= github.com/cloudwego/frugal v0.1.15/go.mod h1:26kU1r18vA8vRg12c66XPDlfv1GQHDbE1RpusipXfcI= +github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40 h1:H1D2KkfXUimnvJ1KPkhYLFrJOiOz33iAwTA8Puatvfw= +github.com/cloudwego/gopkg v0.0.0-20240731030152-5e0df5ad4e40/go.mod h1:32yKw2zkpTMtuX6amJR0EMK79f0vGPr67UcArCOlZLU= github.com/cloudwego/iasm v0.0.9/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= -github.com/cloudwego/kitex v0.9.3-rc2 h1:+B1j56Mo92McGNVSxwzZ2CrF7kbPnb9lfbWlTLrFems= -github.com/cloudwego/kitex v0.9.3-rc2/go.mod h1:0EAW3Mm5mmC483T+nqoBrDT96vgWRxtLpjeF8twLsc4= -github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= -github.com/cloudwego/netpoll v0.6.0 h1:JRMkrA1o8k/4quxzg6Q1XM+zIhwZsyoWlq6ef+ht31U= -github.com/cloudwego/netpoll v0.6.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ= -github.com/cloudwego/thriftgo v0.3.6 h1:gHHW8Ag3cAEQ/awP4emTJiRPr5yQjbANhcsmV8/Epbw= -github.com/cloudwego/thriftgo v0.3.6/go.mod h1:29ukiySoAMd0vXMYIduAY9dph/7dmChvOS11YLotFb8= +github.com/cloudwego/kitex v0.10.4-0.20240731031152-e2ff8eeacaed h1:ayI1ge4aXb6DfKm2A36JszyHSZWUvVOZgCw6TgG6eEM= +github.com/cloudwego/kitex v0.10.4-0.20240731031152-e2ff8eeacaed/go.mod h1:DT970flaFfGIObs++ewGMVAUr9j5g9ioKUOMAYND8iw= +github.com/cloudwego/netpoll v0.6.3 h1:t+ndlwBFjQZimUj3ul31DwI45t18eOr2pcK3juZZm+E= +github.com/cloudwego/netpoll v0.6.3/go.mod h1:kaqvfZ70qd4T2WtIIpCOi5Cxyob8viEpzLhCrTrz3HM= +github.com/cloudwego/runtimex v0.1.0 h1:HG+WxWoj5/CDChDZ7D99ROwvSMkuNXAqt6hnhTTZDiI= +github.com/cloudwego/runtimex v0.1.0/go.mod h1:23vL/HGV0W8nSCHbe084AgEBdDV4rvXenEUMnUNvUd8= +github.com/cloudwego/thriftgo v0.3.15 h1:yB/DDGjeSjliyidMVBjKhGl9RgE4M8iVIz5dKpAIyUs= +github.com/cloudwego/thriftgo v0.3.15/go.mod h1:R4a+4aVDI0V9YCTfpNgmvbkq/9ThKgF7Om8Z0I36698= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= @@ -72,12 +68,10 @@ github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2C github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -103,22 +97,16 @@ github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 h1:mpL/HvfIgIejhVwAfx github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3/go.mod h1:gSuNB+gJaOiQKLEZ+q+PK9Mq3SOzhRcw2GsGS/FhYDk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/jhump/protoreflect v1.8.2 h1:k2xE7wcUomeqwY0LDCYA16y4WWfyTcMx5mKhk0d4ua0= github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= @@ -131,7 +119,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5/go.mod h1:I8AX+yW//L8Hshx6+a1m3bYkwXkpsVjA2795vP4f4oQ= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= @@ -150,10 +137,6 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -165,7 +148,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/thrift-iterator/go v0.0.0-20190402154806-9b5a67519118 h1:MIx5ElxAmfKzHGb3ptBbq9YE3weh55cH1Mb7VA4Oxbg= @@ -187,10 +169,8 @@ github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrU github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/arch v0.0.0-20201008161808-52c3e6f60cff/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.2.0 h1:W1sUEHXiJTfjaFJ5SLo0N6lZn+0eO5gWD1MFeTGqQEY= golang.org/x/arch v0.2.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= @@ -199,7 +179,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -229,10 +208,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -244,12 +221,9 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -261,7 +235,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -273,34 +246,23 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -309,21 +271,16 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -362,7 +319,6 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=